等級:25 - 爐火純青 經驗值:0 / 245 魔法值:14142 / 14142 生命值:5%
升級
  100%
TA的每日心情 | 奮斗 4 小時前 |
---|
簽到天數: 5695 天 [LV.Master]伴壇終老
|
發表於 2016-8-5 17:17:14
|
顯示全部樓層
" P% z( V5 |' H2 e9 n- U先進行普通戰鬥
H' s4 D7 ?% U# T/ z% D還有剩餘艦隊與死星
4 W9 H( }7 _1 N便會進行毀月
6 Q& ?: E2 \* |2 F# Nforeach ($fleetAttack as $fleetID => $fleetDetail)
6 A6 P$ @3 }* n- L$ p {$ ^" C& y4 w. [6 n6 j \! L. r/ C
$fleetArray = '';
* E' z9 e6 Q3 d. i $totalCount = 0;
" _6 O/ C2 d* X1 G7 j & ?6 {& f. B6 e7 w
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
+ g/ V0 _4 z }9 \ foreach ($fleetDetail['unit'] as $elementID => $amount)0 `4 S8 L% {1 A O% d/ B
{ 5 v( X* K M6 C7 ?
$fleetArray .= $elementID.','.floattostring($amount).';';
, P5 f6 Z* F* p! C $totalCount += $amount;
7 o) S3 R' m# z* E3 \. D. K5 V0 w }8 x% g2 H, P2 l; ]! P$ U. `# w
, q: l1 v- p. c3 x if($totalCount == 0)
2 Q% J' b2 R# u$ q( x {
! U0 [9 f/ I# R" H5 m if($this->_fleet['fleet_id'] == $fleetID)
. \- i. _- o) B: Z {8 }/ Y) A3 O! ]6 M8 e" x( s w; i
$this->KillFleet();
% x3 Q# v4 w2 v& H0 b2 n& z- \, Z- a }
& ^$ Y; V& a2 S- E( ]! a! C% U else6 m: A1 |9 A0 X% f% l1 i; F O
{
0 r* n) a& P4 l2 B) c $sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";
9 l" Y, z) X5 {$ a$ L: O; y $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";
, k0 w9 S, [* b' \3 G }
; U) C) T: u& f+ z
' r- ~2 U5 o4 H1 G5 ?" F4 G5 Y+ A $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";
; s4 t+ X7 f" E t }
6 y" W* m$ m, t6 K elseif($totalCount > 0)
9 @1 k! K8 ]; S/ Z& W {1 P2 V1 v K. K$ n: K
$sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";
7 U5 y. Q* t5 ]; L" _ I# i $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";( P& _+ U1 Z+ G
}+ t3 w4 n: e) s4 U4 N9 g. S
else* E; R& I( u( d! w" g
{& t) M$ F; P4 S; \$ }' Q6 c
throw new Exception("Negative Fleet amount ....");
8 J( X3 M2 f1 X; O }
1 i7 Z# @, Y6 n: |$ j1 J }
7 \! f: W1 S% a q" }8 ` ' d ]# {5 U- Z; n+ g
foreach ($fleetDefend as $fleetID => $fleetDetail)
8 b/ M$ f$ k* f8 O {
1 j: _3 k! I. t# A" t t if($fleetID != 0)8 U& v. Q; V# D* @. h
{' M. s0 Y5 a( o6 T/ n. R" h
$fleetArray = '';! d9 T" X/ y" U8 t9 C+ I
$totalCount = 0;. j1 L6 X/ `) r$ C) C5 J% |5 F
4 e- ]) M% k! u7 L# C. q3 S
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
m# N9 k/ Z1 d) q, x foreach ($fleetDetail['unit'] as $elementID => $amount)4 a7 Q- S" S6 E5 g, ]( h2 `
{
" b. P5 o) T, a' a' O) P7 w $fleetArray .= $elementID.','.floattostring($amount).';';
7 e- d3 p2 ?, s2 y+ g: A $totalCount += $amount;6 H+ |+ X: ?5 w3 D
}7 D' P6 }) W# h$ \2 D
) L1 g+ d7 w f, R6 ? if($totalCount == 0)
5 P+ E5 g ]+ G( W {
7 `+ W% F( I" E* W* Q. I! w $sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";
% d" i. V0 d9 ?8 b/ z; F $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";
3 @7 D! A, Y' x0 ~4 M+ f $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";
% [7 k1 B9 n9 w7 Y }8 e7 H! E. I& }# k4 u4 x
elseif($totalCount > 0)
; _& e7 i* S( O5 D& Y7 z' N {
( P3 M( {$ i( B. a8 o $sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";1 K: C% `& I! R N
$sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";. f' i3 Z# O+ I
} F4 i/ Q" R: u* q8 |2 \# t9 y
else3 E/ Z4 L; c4 h, S! H2 N4 b
{
9 H$ a% Z3 ?/ @' k$ s7 t4 b throw new Exception("Negative Fleet amount ....");
* \$ M# M1 q+ @) @+ M: J+ b" x }
" j, T8 a/ m) y! o% J1 V6 e }+ o& D& ~3 O3 E5 J( |( o0 a
else
' ?$ `. N8 C1 g- [ {
6 V5 p. c8 u$ P+ M0 F1 j, r $fleetArray = array();- z8 _) q- Z w
foreach ($fleetDetail['unit'] as $elementID => $amount)
' m9 O$ N9 Z0 f- H( V9 P { ) v5 i6 ^7 n5 x: p
$fleetArray[] = $resource[$elementID]." = ".$amount;
& m# ^- E9 c9 k }
) Y6 \# G# `7 [0 x
/ N2 Y& K+ _7 B2 I if(!empty($fleetArray))) m- P7 j# e# s1 b, W
{5 k" d1 o# `" N& R g# |
$sqlQuery .= "UPDATE ".PLANETS." SET ".implode(', ', $fleetArray)." WHERE id = '".$this->_fleet['fleet_end_id']."';";2 A2 A: k7 W. X% B
}# M' ~! ~: W: o) z: W6 O3 [5 J0 S
}' _1 {% }- ?$ ?1 U
}
2 D; x0 m s6 W 6 ~0 v H4 z" q
$GLOBALS['DATABASE']->multi_query($sqlQuery);
8 H, ~7 f1 P' n) W & c$ L9 {2 z4 m, `
if ($combatResult['won'] == "a")
6 w" \) m! ~+ v6 c4 b" K {
# f! p0 T2 z. b' G7 A require_once('calculateSteal.php');
) w; h0 {' K, ^ I9 s $stealResource = calculateSteal($fleetAttack, $targetPlanet);
/ j- M# w" e9 y5 f" V }
9 Q( c4 x: d0 O$ I B
) s& Y/ \9 s# d) F6 H# ` if($this->_fleet['fleet_end_type'] == 3)
" I" N$ H6 |. g0 u8 D7 _9 R {+ k1 @% D& h4 J( u2 |
// Use planet debris, if attack on moons4 t# P9 O* w; K
$targetPlanet = array_merge(( _- W: T7 K; A0 V
$targetPlanet,9 T8 w; c0 V; W
$GLOBALS['DATABASE']->getFirstRow("SELECT der_metal, der_crystal FROM ".PLANETS." WHERE id_luna = ".$this->_fleet['fleet_end_id'].";")8 T, P+ E5 ]1 @& b$ |
);$ Y0 o/ k. Z5 _' }# @- ?
}
7 r% T2 U9 D) x; m 8 G. O; J" ~" r) S( o1 N+ m
foreach($debrisRessource as $elementID)% v) W# O4 }. `- O2 T* {1 W, a L
{
0 d9 {1 k* u5 s5 m( t& f c, Y $debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];. c$ c } B' H" K) w% Z
$planetDebris[$elementID] = $targetPlanet['der_'.$resource[$elementID]] + $debris[$elementID];
, R$ d6 @0 e, U4 W0 l. S$ J }+ J3 b: _% d4 X/ T& B5 h9 A
; @' j! O4 I8 G- ?( j$ G, w $debrisTotal = array_sum($debris);( V Y" J B8 B9 `* J3 V
3 [2 ^6 a. b; q4 p/ H {- l
$raportInfo = array(' n* S8 w& A* g, ?& C. T5 d/ g
'thisFleet' => $this->_fleet,$ ~2 u" z! o( G, `1 T3 ?( v) ]
'debris' => $debris,4 D, E7 A+ |8 _* ~- u, f0 s, }
'stealResource' => $stealResource,
' K8 u8 g/ h: j5 }* S- C# [3 Y 'moonChance' => null,& \1 l3 P2 g+ y# D' W
'moonDestroy' => true,( C Z; f `/ f0 Y8 g
'moonName' => null,8 y8 L5 C; Y& V' e7 W; q/ k5 e
'moonDestroyChance' => null,
9 L6 f4 g! B0 i 'moonDestroySuccess' => null,: z7 f/ H8 p8 {" J# p0 p* f# E' A. ~4 a
'fleetDestroyChance' => null,; b. L9 k7 s: G; n6 W5 H5 {( ~
'fleetDestroySuccess' => false,
" ~0 t# _* p& |2 L8 e: I% C; m );
3 d3 W6 n# j7 ^, P4 [4 ^5 J; h
0 Q9 k4 D. v1 a* ] $destext = "";/ I: o2 ?5 K% |2 k! w# e1 Y- T
0 k. v& L2 M! _! U5 V
switch($combatResult['won'])* S5 w' P# f4 T2 K7 Q( S$ o1 o
{' Y/ V+ C1 `* o" U+ u
case "a"://勝利
! X( @ y. k4 C $moonDestroyChance = round((100 - sqrt($targetPlanet['diameter'])) * sqrt($fleetAttack[$this->_fleet['fleet_id']]['unit'][214]), 1);6 J8 U! G$ p' [0 A _6 s
5 u+ c. I u( {0 ?
// Max 100% | Min 0%" a4 M3 z) o. e9 {
$moonDestroyChance = min($moonDestroyChance, 100);
* y8 Q1 }% {: V& [7 d' L' T$ i $moonDestroyChance = max($moonDestroyChance, 0);2 V1 i" B& K: n8 {
! O" r( E8 u. Q& N: c $randChance = mt_rand(1, 100);; _3 j m Y% r& I8 A& ?
if ($randChance <= $moonDestroyChance)
8 r2 c( ~% J6 Q7 Q* ^* C2 h//毀月成功 |
|