等級:25 - 爐火純青 經驗值:0 / 245 魔法值:13562 / 13562 生命值:5%
升級
100%
TA的每日心情 | 無聊 22 小時前 |
---|
簽到天數: 5488 天 [LV.Master]伴壇終老
|
發表於 2016-8-5 17:17:14
|
顯示全部樓層
f% p! |/ `3 R; }1 u先進行普通戰鬥+ O7 h. f0 ~( Y \$ L0 W1 e/ |
還有剩餘艦隊與死星5 O8 B8 G1 \ \/ f. y3 w- {! s
便會進行毀月
" L) X N8 n* W) Hforeach ($fleetAttack as $fleetID => $fleetDetail)
: m/ \; J: `( a1 l7 d6 K {
/ b; w8 W: P$ o $fleetArray = '';+ P7 H9 Y& Z6 s/ s' p" D" w
$totalCount = 0;
, r- j+ v$ z: f6 m1 c! g ) l* @7 Y% M. v3 d6 G% x+ `) o
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
8 K: p2 g: _& x) Z+ I/ r- P2 | foreach ($fleetDetail['unit'] as $elementID => $amount)+ f# u: S9 U+ n- e3 I, @
{
: m0 e7 }* `) J- b; s4 _6 B2 @5 o, G $fleetArray .= $elementID.','.floattostring($amount).';';( T. A: X) Y) S, s" a+ Y w
$totalCount += $amount;
" \+ W z4 H' ^8 Z9 D9 d3 ~ \ }
( C/ b1 O1 L6 O4 {$ u
/ Q, |& D6 i1 o: J if($totalCount == 0)0 s6 @6 k0 n! _/ |8 P0 [1 y; c1 }
{+ `' I- \; P( y7 ?3 S7 v. G7 c
if($this->_fleet['fleet_id'] == $fleetID)
3 n6 \- A- S4 Z0 ~6 m$ t {( m$ C9 ^6 O! l2 V @6 v4 O
$this->KillFleet();
5 C2 r/ Q+ R5 F; Y0 Q }. W& j4 A3 c4 @ Q' T4 p# T% ?1 J
else. T2 h) B+ d! {- t* e! @5 x/ u
{; [& d( |- m' ?4 [0 u8 I4 H
$sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";
* B3 {' r- E/ C- Z" H9 F+ p. e $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";; Z7 l. v4 c2 ^% R( K: O
}
+ Q) W8 b5 W8 d7 P S
7 }! l( T/ Y: \* ]6 Y $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";( z6 T6 H5 N; x
}3 W& x" i7 O+ c4 _
elseif($totalCount > 0)4 C+ D; u8 t1 U8 y
{
2 e& b$ Y$ C( `6 D9 e $sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";, O$ R( K! }7 l+ u0 t
$sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";2 M" f- w6 M" O1 Y
}
$ X2 W5 T3 y2 y) S D else6 r. i1 k' ^3 P' w2 p2 Y
{
% _3 \; W: \* O) n; m7 u# c throw new Exception("Negative Fleet amount ....");/ U3 I# l& }' F H; A
}
1 ?4 K3 B5 d: G9 g0 w) B! A# p }5 B2 }9 _* Y/ u; G$ ~( _" _
! z2 W4 y& _2 i% q( ^
foreach ($fleetDefend as $fleetID => $fleetDetail)
$ S5 F2 H! k' ?8 L" x) G9 d) C2 E4 u5 L {
2 ? ]! W! y' U, ?9 w' V/ {: I if($fleetID != 0)
- z0 k; T1 e$ R {9 f' V/ O) b3 }1 @. H
$fleetArray = '';
4 n7 u' R) p# T; B0 {8 G $totalCount = 0;) ?& ~" }% K% C5 x7 `: e! e
' I% p+ {8 t9 M5 r+ e5 v+ j* z- A
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);1 o. n3 L/ P8 H4 j, K9 z+ O
foreach ($fleetDetail['unit'] as $elementID => $amount)
: A R" d6 P7 G2 X. b { . d8 a2 g6 B8 `& i" E) \
$fleetArray .= $elementID.','.floattostring($amount).';';8 `7 Q E( f. a! e$ _7 I
$totalCount += $amount;0 X% Z4 |+ m5 `, d
}
+ j1 a* n8 @: `- }2 K$ ~6 H 9 i: ^. }- N- i% \2 V1 x1 J6 w$ d
if($totalCount == 0)$ X( j+ D# I5 X' s W- `
{3 j/ ^, S+ r o; P! f/ Q
$sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";
; |( w4 c' H( X& v& g $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";& Y" j( j& h6 {/ w7 s! {- W
$sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";
: @9 C6 B3 @0 |7 Z( d0 O+ O& Z5 }# }$ o }; J% e- g) ]+ c
elseif($totalCount > 0)
6 s; \$ @( a, [$ ?4 b! R {* B! ~8 k2 a, z. E) \
$sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";
, A( k" k N) N" i3 O! u $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";& n9 h; E* O8 V: O
}3 r& X! _( S! c, Z6 {2 `7 l8 {5 N3 s# _
else0 j. _2 t, H3 m' X' e
{
0 @4 J1 y% J! X! B throw new Exception("Negative Fleet amount ....");& b# k9 b o; ?! m; t+ d
}; `2 b9 O! p" e% B; }9 v: P
}0 `& J6 ]; p( p) H) V9 n
else
7 n9 I/ Z V# v4 ]6 ^: i {" e6 A9 F) ?1 b7 r
$fleetArray = array();
( f% K: m$ t7 I$ O: [. x; n foreach ($fleetDetail['unit'] as $elementID => $amount)& ]2 n N2 ^: @& ~+ T9 V8 C/ D7 H# P
{
5 }5 I3 x" k2 t; i $fleetArray[] = $resource[$elementID]." = ".$amount;: B5 H5 R. u( N% k' Z
}3 A1 @+ w3 h$ X9 L0 p% Y' @
1 r6 a8 p$ g2 a9 r
if(!empty($fleetArray))5 ], j4 \+ ?3 k* D
{; \0 T. j5 G5 p9 [* _
$sqlQuery .= "UPDATE ".PLANETS." SET ".implode(', ', $fleetArray)." WHERE id = '".$this->_fleet['fleet_end_id']."';";' \# A. J) w3 v: B
}8 ]7 O( e7 z/ z( k6 i, r9 J
}
! n5 x3 ^; y) j) G0 d }
) C! A6 v% r% L% D 8 o% E5 ^7 V9 c/ O
$GLOBALS['DATABASE']->multi_query($sqlQuery);
% x, I# y- U9 ~' Y" V2 E
4 J0 G' `0 e! j' q6 L0 {( | if ($combatResult['won'] == "a")% i8 r: Y2 D+ \
{/ ~6 K) s* P0 z. Y' n
require_once('calculateSteal.php');4 S T5 q" L: |0 [1 @
$stealResource = calculateSteal($fleetAttack, $targetPlanet);
( R* y% B1 S# B6 n$ B0 V }; G/ K* k, a4 h. k4 L% b9 ^- F
1 _1 k3 V W H: i' c3 p if($this->_fleet['fleet_end_type'] == 3)/ r" t/ f) ?- o w- j2 w& ~9 `
{: _' o; N7 A" k+ v* n
// Use planet debris, if attack on moons
# m! v0 e+ Z, E/ ~7 f $targetPlanet = array_merge(
* @1 ^* H. Z# e* y7 p $targetPlanet,
$ f% u1 F% u+ Y8 N+ U8 T0 E) R$ Z $GLOBALS['DATABASE']->getFirstRow("SELECT der_metal, der_crystal FROM ".PLANETS." WHERE id_luna = ".$this->_fleet['fleet_end_id'].";")
/ j D3 B: ~5 g2 f! H );
8 Q9 c+ p3 _" ^$ i4 ]3 N& V }
* K- k H ^- @4 w7 G & f" g4 w+ R' k3 T0 B8 n
foreach($debrisRessource as $elementID)) V: e1 m8 p, o
{1 |0 T/ l3 C$ x* U1 i4 N
$debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];
+ _. w0 b& v _7 ?: Y( g2 T! H0 B $planetDebris[$elementID] = $targetPlanet['der_'.$resource[$elementID]] + $debris[$elementID];# g) c6 Y# Q& P6 M
}
! M+ g! O6 }2 L* ~, \. f, s& ~ , Q* N( d' M7 k ^& h6 z: v4 I. p
$debrisTotal = array_sum($debris);
! @) O/ G) O2 _/ L( @( d8 l$ q
0 j) X& B5 M( H $raportInfo = array(
2 e6 r1 I: m. E5 _+ o# j 'thisFleet' => $this->_fleet,
5 F V: T" w3 l7 ^/ |0 Z 'debris' => $debris,3 C [/ ]# \7 n. i) n- @
'stealResource' => $stealResource,6 I/ B7 f; K* F9 d- I
'moonChance' => null,) l5 t( b" a# z. x; U3 f; H
'moonDestroy' => true,
/ M5 d6 ]! ?) ~; }/ r; G9 @& Q s 'moonName' => null," ]: y4 c, t; b
'moonDestroyChance' => null,$ A0 O/ Z, W E* ^& Z! {4 L
'moonDestroySuccess' => null,
: [+ I) d6 w1 _9 D% {, x 'fleetDestroyChance' => null,9 o. \ H8 F: O7 E T
'fleetDestroySuccess' => false,% m' x% `! }4 v7 N$ i
);
9 Z1 Y4 `6 r- |. J/ j0 d) D
; o: s) T! ~: M. b $destext = ""; e$ [. B5 P4 ?, @
- `, [+ U! m/ c* B0 v4 r, o- s
switch($combatResult['won'])8 }8 F6 i5 Q- S1 H/ Q! z2 ]
{* z( o, v5 ?: E* `0 e8 O9 l
case "a"://勝利
4 s' H! o, k) y* M: H) r $moonDestroyChance = round((100 - sqrt($targetPlanet['diameter'])) * sqrt($fleetAttack[$this->_fleet['fleet_id']]['unit'][214]), 1);6 e; K H- @" q" J" x2 v5 ~
; ?6 k6 U3 M2 o0 ^ // Max 100% | Min 0%
: [5 ^2 p+ d a $moonDestroyChance = min($moonDestroyChance, 100);4 Y& t; r) \* U& V6 S. y
$moonDestroyChance = max($moonDestroyChance, 0); y- k0 }5 B6 {# E! k4 Y
4 S6 j7 E) E0 l$ e0 z. l
$randChance = mt_rand(1, 100);/ w' o% p: H- {4 i0 i# Y# Y
if ($randChance <= $moonDestroyChance)
2 j: q& x/ C! L6 w//毀月成功 |
|