等級:25 - 爐火純青 經驗值:0 / 244 魔法值:13405 / 13405 生命值:4%
升級
100%
TA的每日心情 | 衰 11 小時前 |
---|
簽到天數: 5429 天 [LV.Master]伴壇終老
|
發表於 2015-9-16 20:17:13
|
顯示全部樓層
- class MissionCaseDestruction extends MissionFunctions
0 E$ K. O6 Y- f! ^, t - {
0 K; B2 F7 P6 G& @ - function __construct($Fleet)$ c h, O! n5 \" u8 v3 b
- {4 E2 M- J: G6 y' a* Z( n
- $this->_fleet = $Fleet;6 z% F, o: L# E( B% [
- }! }* M/ F! t% T. H) Z+ _; M" }+ \
- 4 V6 r% E0 E' Y% a' M" p$ ]
- function TargetEvent()
& a7 O) T( i5 V& e - {
* H3 p( _0 n" x3 h1 l8 g - global $resource, $reslist;
$ Q8 o) N3 a$ H& o' W* m( _) j6 r. y -
, H4 T6 G: Q9 M - $fleetAttack = array();
Z m/ I1 R- s7 F; o+ h4 l% c - $fleetDefend = array();
. D7 b- M( Z, J, @, A0 H -
! E6 w o) c) m: j - $userAttack = array();
- ~5 x5 m8 ?6 g - $userDefend = array();
4 H: v$ i0 i: _6 w! l$ A - 8 p4 ?$ Q/ u: R" C' T" P, [
- $stealResource = array() [2 n/ \7 q, J; r/ r- ?/ ~
- 901 => 0,+ H& a$ i; C4 d# ~: b6 Y- c
- 902 => 0,
2 B# a4 S7 f! @7 q: Z% H - 903 => 0,3 S( q& W5 B: I0 U
- );4 {! ~2 A+ g' e D
-
) V F+ A) M: j* c# b) I/ o - $debris = array();
1 M+ B) ]" s' j1 f) J( d9 e - $planetDebris = array();& I# R* k% z( X
-
2 [' o8 ?1 I4 v2 _ - $raportInfo = array();
7 M2 Y* t/ \/ R* [: Y- a -
4 o9 V1 o% w n5 L3 k. U0 C - $debrisRessource = array(901, 902);; v9 S3 c* J. S0 g* K9 M* r9 h
- & M1 H* ?% ^4 E! u9 L
- $messageHTML = <<<HTML
! E8 h b Y2 _$ j - <div class="raportMessage">3 H" t) O5 g/ ]* ~; T
- <table># h3 D: t3 A# i0 f) _
- <tr>
2 E |4 f' }2 e: d - <td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
+ B# ^9 @ x) s2 M, {' a - </tr>
( h2 `5 m$ F$ U( V% F - <tr>
! O- u, t7 J+ x - <td>%s</td><td><span class="%s">%s: %s</span> <span class="%s">%s: %s</span></td>8 e" X) z- o; d. ^: A$ I- B: N
- </tr>4 n- M& s% H# ^4 ?* O2 s
- <tr>3 c! {, @& b1 B
- <td>%s</td><td><span>%s: <span class="raportSteal element901">%s</span> </span><span>%s: <span class="raportSteal element902">%s</span> </span><span>%s: <span class="raportSteal element903">%s</span></span></td>
E% K4 S* L3 M3 r4 d! N7 N" a& p - </tr>- a4 k/ Q0 S3 j/ M; P6 ?
- <tr>7 Q( w; B3 V }; m$ ?" O# j& p
- <td>%s</td><td><span>%s: <span class="raportDebris element901">%s</span> </span><span>%s: <span class="raportDebris element902">%s</span></span></td>
; c6 Z7 x, m+ f% q. T - </tr>
: e/ ^" U# t8 r7 G$ D& Q+ x - </table>
( q) s* G3 a( w+ b1 ` - </div>
1 ~4 p# n" g1 ]4 W- y - HTML;
( q, I! b7 w7 A( A: q% w: p" G - //Minize HTML
8 G" _/ F6 Z$ p1 @5 s3 [ - $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
- } |! m3 C6 O) p/ E4 I -
: K1 X% k3 [1 T - $targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM ".PLANETS." WHERE id = '".$this->_fleet['fleet_end_id']."';");% N' l- x5 F- M" j$ \- H0 n u
- $targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM ".USERS." WHERE id = '".$targetPlanet['id_owner']."';");
, z+ a, `% @5 }( i m9 ? - + B g* c; _0 j& b# o. a
- $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);* i( f* }# s5 k
- $planetUpdater = new ResourceUpdate();* M3 L2 d& I* F( `* M( r
-
h4 r/ c' V! ]: I3 s9 d) m: t - list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);1 o. K( O4 C) n1 d' D' C
-
$ S& h& Y5 P8 ~+ O - if($this->_fleet['fleet_group'] != 0)% o2 Y8 G" r, t5 u
- {6 }% o7 D# R% ~
- $GLOBALS['DATABASE']->query("DELETE FROM ".AKS." WHERE id = '".$this->_fleet['fleet_group']."';");
( e6 `% m4 h( b# A$ Q5 F, c - $incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM ".FLEETS." WHERE fleet_group = '".$this->_fleet['fleet_group']."';");
7 _1 K+ c9 R* a8 ?# @ -
, M! R" |3 @% n% V - while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult))
7 J9 f! }( |. _) F0 W - {
4 z. ]: n. x: C+ ~ - $incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;" ?9 e$ @8 c" n% r! i2 d
- }
/ b. ~, D: Y; l! L -
; G* z( I/ }' f; Z2 a2 r - $GLOBALS['DATABASE']->free_result($incomingFleetsResult);! @, a( V3 R: [6 Z6 K
- }
0 a: b3 {. ~8 G* e - else2 `! x1 ]4 T1 I1 X% U9 ]# i
- {! ^1 u3 F0 c- v+ I
- $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
# {0 _/ m6 _- g0 h7 \ - }
/ s3 b+ |: b, F. F( X - ?: P0 F; w5 s' Z
- foreach($incomingFleets as $fleetID => $fleetDetail)
}% k) p, a# n- J3 e - {1 V8 M6 j" S ~6 j
- $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;* ]' b5 a+ r: q5 l/ [. V4 W* q# H
- $fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM ".USERS." WHERE id = '".$fleetDetail['fleet_owner']."';");. e3 l; Y% Z- T y0 \
- $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
# C9 Q: [/ \" c. y; z+ f - $fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
, V( M" W! R# L$ ]+ U1 V4 V% ` - 1 t3 q# b0 @& Z4 S: R7 p p
- $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];5 n3 W9 r# Q' b$ u* Z1 ]6 m7 E0 O
- }$ G" p5 i( `7 o8 x
- # c3 ^- G8 m, v. j
- $targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM ".FLEETS." WHERE fleet_mission = '5' AND fleet_end_id = '".$this->_fleet['fleet_end_id']."' AND fleet_start_time <= '".TIMESTAMP."' AND fleet_end_stay >= '".TIMESTAMP."';");+ f8 c O+ G; p8 c) u
- while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult))
; `( L: x4 U B8 \ - {
! s/ I! Z$ A0 d- ~( v& E7 ?: F - $fleetID = $fleetDetail['fleet_id'];1 V1 |: L, \ W* ~
-
7 z8 k9 T3 ?8 y- c- n1 L- Z1 s) u - $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
/ _, } K0 m2 f; h4 N# t - $fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM ".USERS." WHERE id = '".$fleetDetail['fleet_owner']."';");% Q: |* X# m) S- o) N
- $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);9 Z" \( j: T) s5 t' Y4 @5 @6 @
- $fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
}& x2 a& z* ]7 _1 | - 3 @5 K6 ?" {! Y) r
- $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];8 U, B, q& c7 D
- }
* E! [$ `3 u- o4 c& U" T -
" g" R$ l2 F4 F5 H% G - $GLOBALS['DATABASE']->free_result($targetFleetsResult);
! C' R& |% g6 h: m; y. s; v( M -
! p7 m, N: Y4 \3 b& ?3 b - $fleetDefend[0]['player'] = $targetUser;3 e5 M1 l/ J5 L' {( R! {
- $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);% T$ C3 ~6 d& e. W; l1 }5 z; V
- $fleetDefend[0]['fleetDetail'] = array(8 A6 @/ H' ^, Z5 S, {3 }
- 'fleet_start_galaxy' => $targetPlanet['galaxy'],
2 o4 [" _& y: H' N3 u4 H: ]: ? - 'fleet_start_system' => $targetPlanet['system'],
+ A% g0 \; O- D9 g - 'fleet_start_planet' => $targetPlanet['planet'],
5 i8 n1 K& @1 |4 _" e* R4 `! T - 'fleet_start_type' => $targetPlanet['planet_type'], 0 u1 R5 ]8 q& ~. m' B9 ?
- );$ P3 @9 V3 N o5 P! f: g( U' F
-
4 S/ X! |* D% w' t3 K4 T - $fleetDefend[0]['unit'] = array();
8 X1 p8 t |/ G -
# j1 a- n8 Y7 i! R3 { - foreach(array_merge($reslist['fleet'], $reslist['defense']) as $elementID). @" d% F7 \1 Y1 d
- {
' C& J, |9 n. b - if (empty($targetPlanet[$resource[$elementID]])) continue;. o8 a I" [+ @/ ?8 s
- 4 s8 X2 j( ]" n+ J4 X) S
- $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];8 f# C9 G+ d J i- q; L
- }- `4 N; N" a7 b* A& e
- ) x) \$ ]* _9 W! w3 X( m! L2 M( s
- $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
# }/ _) m+ L, p: z8 p' Z - - u$ L( p$ k; L" j# s+ o" t9 @& E- ^
- require_once('calculateAttack.php');
5 v( u6 m6 [" m z7 c( w -
v" U) e7 q! x! F. i - $fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];$ U) r8 m5 n. ]4 j6 I, I
- $defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];6 o; @$ ^, S/ D1 n; V% |
- 4 V9 {4 C0 F% c1 b" Q4 v
- $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
) z* n N; c4 ?$ Z% ^, r, @ -
& T0 v5 Q! T$ b6 X' ` - $sqlQuery = "";
% N8 C9 ?$ x5 O6 ? -
) \: ?/ @, s) u9 C. I: | - foreach ($fleetAttack as $fleetID => $fleetDetail); r0 n# b2 L* B; {" @' v# [4 o
- {7 r; [: J) q) e, z
- $fleetArray = '';* Z1 A1 x) h8 i D& ^% L- H
- $totalCount = 0;
% X, Z. g6 k5 t, J -
. e# v; g* T8 x* c7 [ - $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
8 A; u0 b6 B% P9 q$ d - foreach ($fleetDetail['unit'] as $elementID => $amount)
7 A- o) U Z! s3 ~7 h - {
( A" |; `8 W, U6 N! ]" F - $fleetArray .= $elementID.','.floattostring($amount).';';
4 r: }3 p/ `! R9 |4 v - $totalCount += $amount;
: f$ k4 z5 J# g( ?, M - }- w/ J: _% i$ R S& N
- 6 k2 s2 ]3 p3 N" z a
- if($totalCount == 0)
9 X3 u& ?8 @1 S8 k - {8 ^! ^# A0 B# y; b
- if($this->_fleet['fleet_id'] == $fleetID)( N9 z0 E+ E0 P# [ |' c
- {$ _5 t* y9 H% u6 [& @" k
- $this->KillFleet();
( r( V0 W/ H% b1 X! P4 N! K - }0 V% G: Z0 g7 B( ?# s) }$ ?
- else2 u- Q1 s/ K- K) l
- {3 |4 d3 A0 K, U' E i, K
- $sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";
' G5 Q7 b. I, n/ e - $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";3 F' ?7 c7 S6 {: Q$ h# C
- }
+ W' K; f. ~. P0 r) b: d$ P& L3 @5 V - 4 [* `! H) C; j" ]
- $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";
% S0 q+ x/ ]1 |& R8 f: _1 r+ V - }+ U7 Q% V" Z' W
- elseif($totalCount > 0)0 U# L/ @. x' p* D& ^3 K$ v
- {1 s0 f; w( g4 w' W8 e+ C% B) h4 B
- $sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";
N. c" X8 ~7 h |+ T1 E - $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";
/ X+ k0 _- ^( q - }5 S) F2 u6 `0 N, V. N
- else
, [' I9 o7 ?# ~" n4 W f$ v9 n - {- I9 f4 o4 w8 d/ f2 z; W9 J
- throw new Exception("Negative Fleet amount ....");9 e* B/ ]( ~- K* x( |$ ?4 x, [0 H9 z6 @
- }
5 {* x* q. ^6 B, s( }: d$ X - }( q# _/ ~5 }: T5 h# w
-
" Q9 H( t4 {- u: ?; m( t* L% d - foreach ($fleetDefend as $fleetID => $fleetDetail)$ i/ w- W5 [8 G) U4 R2 B7 e0 }
- {, W" h( {4 v% ^$ K, u' G- q
- if($fleetID != 0)
# j' [3 F( j% D1 ^ - {4 B! f" i6 L M; D0 {4 Y
- $fleetArray = '';* q2 K" ]6 a: t, N
- $totalCount = 0;! e% q4 \2 a8 K
- ' w) ~* _& Q$ P8 _* [5 C
- $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
& D! G4 P( u$ U# l" s - foreach ($fleetDetail['unit'] as $elementID => $amount)
* _9 `/ D8 |# \ - { - O0 u$ \, {, o6 T7 B2 t+ V. q
- $fleetArray .= $elementID.','.floattostring($amount).';';4 j7 U/ C3 V5 S0 O
- $totalCount += $amount;
5 B B T) H( }3 Z - }: g! N2 k6 E0 e7 c
-
g, R- Z. o& ]! B6 i - if($totalCount == 0)
5 k0 I) |0 F+ ~6 V - {
3 ~8 U! c S* j* H: |# L2 B - $sqlQuery .= "DELETE FROM ".FLEETS." WHERE fleet_id = ".$fleetID.";";3 m1 J- g0 r. ]; R" g$ m
- $sqlQuery .= "DELETE FROM ".FLEETS_EVENT." WHERE fleetID = ".$fleetID.";";3 w% n) E2 Y% S' T- |3 [
- $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_state = 2 WHERE fleet_id = '".$fleetID."';";" L+ d B9 i& ]! j/ U
- }4 p$ p0 s& k7 f1 \
- elseif($totalCount > 0)( J- V' {' S# e- K3 w$ `; o* @. A
- {
/ U9 b$ I6 Z9 j% h/ y7 N - $sqlQuery .= "UPDATE ".FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."' WHERE fleet_id = '".$fleetID."';";
5 d( H3 B1 t* }! v7 y$ |2 s - $sqlQuery .= "UPDATE ".LOG_FLEETS." SET fleet_array = '".substr($fleetArray, 0, -1)."', fleet_amount = '".$totalCount."', fleet_state = 1 WHERE fleet_id = '".$fleetID."';";
4 k* p* o* ]! f. {# E3 s S4 { - }0 Z2 @6 Y. @$ h" ]
- else
6 m5 V$ s- @- t2 W - {
1 g% \9 F5 W/ x$ t3 K7 Z6 e - throw new Exception("Negative Fleet amount ....");
% ]. c8 B: f v! M% N - }
; i; @- O# @1 Z) ~1 Y - }! Q% j: n/ c$ b) a% n( A! Q
- else
& o2 B7 j) i. p( p, V - {& w& q) C: V# S( N" {
- $fleetArray = array();
1 e( O- z4 Y: D6 L - foreach ($fleetDetail['unit'] as $elementID => $amount)9 b3 e+ l# d+ D0 ^1 m' @
- { . Z( }6 V9 D4 q6 d
- $fleetArray[] = $resource[$elementID]." = ".$amount;
# g6 e Y7 Z4 R" d: P - }
8 A' F+ C* |9 I: z% f0 _) h; A3 Y -
' b3 w" F- v/ q' m+ h6 V - if(!empty($fleetArray))6 y! P) o w; i
- {( Y" W2 v2 G: Z
- $sqlQuery .= "UPDATE ".PLANETS." SET ".implode(', ', $fleetArray)." WHERE id = '".$this->_fleet['fleet_end_id']."';";6 K, `; e P7 s1 \* X1 R% j
- }) R% Q6 s- N( |. ?9 s6 A
- }
9 e* x. \* J) I - }
/ f; ~- v! P" b7 C9 Y4 T( T! L -
( |8 Q& z6 n; K/ H: [0 C3 F - $GLOBALS['DATABASE']->multi_query($sqlQuery);
9 u+ i$ P1 X# P -
' Z8 y# A- C t - if ($combatResult['won'] == "a")
% U) O. Z" [ V) q2 [* T, _ - {
Q* b4 ?) Z( U4 M7 o, C) I - require_once('calculateSteal.php');" N9 v( W# X8 R& Y ^
- $stealResource = calculateSteal($fleetAttack, $targetPlanet);
( H9 L& P9 A9 s2 O% ~' ?0 t - }, r9 W! S% \$ T% j, j2 R3 j
-
# X; D5 {) E* `$ G0 } - if($this->_fleet['fleet_end_type'] == 3)
5 D) a3 B8 c7 B$ \$ T& m - {
( x$ t7 l: h# O6 A - // Use planet debris, if attack on moons
& j) a0 J# b: V - $targetPlanet = array_merge(& i0 T4 I/ k# K! y& K
- $targetPlanet,
: a: [7 F" @8 S4 N - $GLOBALS['DATABASE']->getFirstRow("SELECT der_metal, der_crystal FROM ".PLANETS." WHERE id_luna = ".$this->_fleet['fleet_end_id'].";"); @4 J( Z4 x4 c1 C
- );
) `2 y: }, F( f8 Z - }
) N6 N o( x0 P( ]+ a$ _# {' i - $ V6 D @, K# o2 h3 x: V
- foreach($debrisRessource as $elementID), `5 U. U' V r+ n) T
- {
: F9 f8 x Y+ k - $debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];4 H. W6 J& ~7 h& j0 ^7 k$ C
- $planetDebris[$elementID] = $targetPlanet['der_'.$resource[$elementID]] + $debris[$elementID];9 Z4 b* a$ i/ D4 i* L4 N9 W) u7 k
- }
$ q- h: `3 K0 J; h ^ - 6 F4 _) p. S- _+ p2 K4 D
- $debrisTotal = array_sum($debris);
( X$ v7 l; V5 D - & w8 o3 }) o1 ^; |( Q( _! x
- $raportInfo = array(
7 y5 z, l! v$ @9 [4 C - 'thisFleet' => $this->_fleet,9 b+ ]: J. N* u% n/ k( C& B) U
- 'debris' => $debris,6 N$ t. k: _$ c S! o
- 'stealResource' => $stealResource,
9 |( Q# H" n& x9 N [# o - 'moonChance' => null,
( X, A$ Y0 J7 M5 v - 'moonDestroy' => true,' W& Z j; ~. E% l8 f3 |" t
- 'moonName' => null,
% X+ |( i" {) y0 W - 'moonDestroyChance' => null,. c- z4 x6 e: }, @( M
- 'moonDestroySuccess' => null,6 U5 f7 R9 Q- J( o+ z
- 'fleetDestroyChance' => null,1 o5 u% U9 _- H
- 'fleetDestroySuccess' => false," |( n# v# A- {5 D: f. G
- );$ G1 f3 F) t0 l/ U6 O
; N- @5 o$ _0 f2 E) J- $destext = "";8 Q% E& K+ q( F8 y) M, W/ d
-
6 s% @! R; W0 C - switch($combatResult['won'])
: g& n! l9 q7 H4 m+ ]* t% K - {8 k+ }' K5 u" R% M# f8 z" u
- case "a":
& }8 {: m* B; P: h# @) L( {2 X) { - $moonDestroyChance = round((100 - sqrt($targetPlanet['diameter'])) * sqrt($fleetAttack[$this->_fleet['fleet_id']]['unit'][214]), 1);5 {: C- {( e4 t) I6 N3 z) M( t
- ) r) N7 f% Y* I( h4 ]
- // Max 100% | Min 0%
- `8 P0 i( C( R - $moonDestroyChance = min($moonDestroyChance, 100);
8 {3 U" o+ l) V8 T - $moonDestroyChance = max($moonDestroyChance, 0);
: I) E# k4 O, [/ _, @* c9 E - 3 V( f: D! O" \7 V
- $randChance = mt_rand(1, 100);' b' u. H. c5 a$ Y. R% A N( Z
- if ($randChance <= $moonDestroyChance), ?6 F- o3 t! k) |4 g% n/ p% t
- {
$ k/ G4 H7 [# v3 Q5 Q - $planetID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM ".PLANETS." WHERE id_luna = ".$targetPlanet['id'].";");8 M, D* z) z2 H8 l
- $GLOBALS['DATABASE']->multi_query("1 Q6 G( L6 J1 i& @; `& \( x
- UPDATE ".FLEETS." SET
* h- m& F$ f7 K0 l$ Y6 a - fleet_start_type = 1, - W3 n* h& }1 U- R
- fleet_start_id = ".$planetID."
. A, H! @% o, t, q - WHERE fleet_start_id = ".$targetPlanet['id'].";
6 I4 k8 V% S# V z8 F- G - UPDATE ".FLEETS." SET
6 x0 d l& R1 _. Q) r# t- G, k7 |; i' r - fleet_end_type = 1, ( c3 f" z' f; B' U }, z
- fleet_end_id = ".$planetID.",# e! Y" ]6 A; s3 `
- fleet_mission = IF(fleet_mission = 9, 1, fleet_mission) / K3 N- O9 I& @* s7 L
- WHERE fleet_end_id = ".$this->_fleet['fleet_end_id']."
) Y0 T% [: Z) t9 d( } - AND fleet_id != ".$this->_fleet['fleet_id'].";6 _8 f: p3 A* y
- UPDATE ".PLANETS."
& U: D' l/ s, C7 Y - SET id_luna = 00 x& i8 k, ]$ E1 u( N( I
- WHERE id_luna = ".$targetPlanet['id'].";. v' s8 p, ]: P, M+ o: ~4 N) h. R
- DELETE FROM ".PLANETS." 5 K, i3 U" M/ V' T
- WHERE id = ".$targetPlanet['id'].";");3 b# T8 W2 j9 P
-
! N b7 G, s- x% q - $raportInfo['moonDestroySuccess'] = 1;
+ J7 L. ^+ f; H' a& I2 K% f' u - } else {
( Q" `9 s2 r2 K; h - $raportInfo['moonDestroySuccess'] = 0;, j- ]' c/ q$ a D/ n+ p% O1 g
- }
0 d/ s% p% j9 }! F& v - : p% J6 Y5 S5 g2 E4 \' A# \
- $fleetDestroyChance = round(sqrt($targetPlanet['diameter']) / 2);5 a7 E+ q! `; [, b) j
- % s. k3 i. _( M- W- r
- $randChance = mt_rand(1, 100);# r# S6 F. P* [1 R$ I7 ?6 }
- if ($randChance <= $fleetDestroyChance)3 N0 ~2 o$ J+ ^) m x3 H
- {- T6 R _/ f) x
- $this->KillFleet();
6 d# p4 @1 M6 Y( B9 R - $raportInfo['fleetDestroySuccess'] = true;
" I9 |% n+ S1 K! } ]" w" c - }) T) T: ]5 F6 Y5 r6 z
- else8 D/ F6 F" M0 i
- {
1 v) @* a- o2 k( y, d4 n - $raportInfo['fleetDestroySuccess'] = false;
+ N& y3 o, ~' x& e - }
$ O" t4 E1 x+ ]3 T' E/ ]' h - / F4 y- s+ R2 x X) @! H" e* G3 g
-
% P4 W) G) L' g) Q' A8 X+ c - $raportInfo['moonDestroyChance'] = $moonDestroyChance;
4 `7 E2 Q# y; `, ]8 x9 k8 | - $raportInfo['fleetDestroyChance'] = $fleetDestroyChance;
# f) \& b) h# U% W/ @7 N6 Y$ T+ g; U -
: w* u8 y/ m A - $attackStatus = 'wons';
4 m; x" \) O% t$ W$ Y6 p% N& \& c - $defendStatus = 'loos';. y: Q! P E8 S+ ]1 V! H0 h
- $attackClass = 'raportWin';
8 n. u# t0 W9 e6 ~: I9 D7 S0 S - $defendClass = 'raportLose';
5 L {6 b8 p5 U5 P - break; r) U, x* P8 ?: e( q5 m2 e9 @4 s; f
- case "w":) \5 C g5 K p, J3 _7 K7 N
- $attackStatus = 'draws';
7 ^4 r$ U( w/ B/ l6 i+ r - $defendStatus = 'draws';. J! r8 z/ n C5 c, |7 N3 i$ c$ m
- $attackClass = 'raportDraw';
' f4 h \$ O5 V& i9 [ - $defendClass = 'raportDraw';
2 N% n2 G$ m1 P, }. j- K, X - $raportInfo['moonDestroySuccess'] = -1;
; {1 X( R" ^ H - break;
+ u7 y- u& M" t. e! x - case "r":
& ^* b, ^ L* |8 c+ o - $attackStatus = 'loos';
- Z* Q! q' X2 @* L9 u2 L6 k, C - $defendStatus = 'wons';
2 O6 B$ M& ?, C9 J: _ - $attackClass = 'raportLose';& @- ?" W5 x8 }7 R; j' Q; `3 `* F0 B8 H6 H
- $defendClass = 'raportWin';
# I6 [2 i$ l+ O0 Y+ m - $raportInfo['moonDestroySuccess'] = -1;+ l7 g5 w- k: R7 `
- break;
g" R/ Q9 ?$ I) I - }
) x, h8 w3 B% Q0 } - 2 v" d! N* e- t# _& m# {
- require_once('GenerateReport.php');
/ L& A1 B# M0 Y+ H: g n/ i8 X - $raportData = GenerateReport($combatResult, $raportInfo);
' m+ {8 n% z' W" ^# l -
9 D! o* \& a/ r" @ - $raportID = md5(uniqid('', true).TIMESTAMP);+ U: _; J3 h# K/ L! k! W0 B
- $sqlQuery = "INSERT INTO ".RW." SET " T5 i* {' b9 ?9 I! E" d
- rid = '".$raportID."',
3 F8 N6 L# H+ r( e7 z& C3 v1 w - raport = '".serialize($raportData)."',7 W8 V1 C, F( N8 K
- time = '".$this->_fleet['fleet_start_time']."',; r( i4 n G0 {: N( C$ u4 @7 h; h
- attacker = '".implode(',', array_keys($userAttack))."',' f6 j& A) c0 y. U* H
- defender = '".implode(',', array_keys($userDefend))."';";
* r( o* g$ Y) ~+ C5 f( I) C6 U - $GLOBALS['DATABASE']->query($sqlQuery);
* b9 Y! [ u; I - 7 @2 X3 H! Y3 U7 A) j" _
- $sqlQuery = "";8 N$ v6 G2 W c1 K G& M
- foreach($userAttack as $userID => $userName)& h2 ^& k( Q! D; r
- {
+ i8 v; k4 i! e& N% u A; P$ ~ - $LNG = $this->getLanguage(NULL, $userID);" V; z5 J* M1 y4 M7 j
- 5 r2 C% n0 x( U3 X# l
- $message = sprintf($messageHTML,
+ `0 R" F, s* m O - $raportID,
2 K- F' H5 ?% E4 c2 U& B# r$ H - $attackClass,
6 Y/ l5 k' G+ M) J. V - $LNG['sys_mess_attack_report'],
' y7 W8 g2 e& {& f1 j u+ m6 l - sprintf(+ @8 ]4 J- S6 a% ~% _& d
- $LNG['sys_adress_planet'],
& l& i3 ~: ]0 R% b* k* X - $this->_fleet['fleet_end_galaxy'],- v( z8 d7 s* Z% D& \# o! I: C( S
- $this->_fleet['fleet_end_system'],
1 Y8 P1 Y% A( W" D - $this->_fleet['fleet_end_planet']8 _8 a( h* f+ [" b0 l( k: @9 n
- ),
1 ]8 {* V, |- ]7 K - $LNG['type_planet_short'][$this->_fleet['fleet_end_type']],
$ H8 n7 m. l3 m( q2 \ - $LNG['sys_lost'],
, Z$ y0 L6 J% v% O' p" X% p - $attackClass,
' y) Q% s4 W3 Y, J- n - $LNG['sys_attack_attacker_pos'],
4 L2 F3 R$ s) a$ P Y1 I5 B - pretty_number($combatResult['unitLost']['attacker']),
& H& J$ d5 Z5 h - $defendClass,
3 F! S) s0 j# T# U - $LNG['sys_attack_defender_pos'], r5 f- S0 F, R% y5 Y+ H' G$ e
- pretty_number($combatResult['unitLost']['defender']),: P3 Z/ l; e6 R5 N& s2 P
- $LNG['sys_gain'],* w* e, P7 }# [5 h4 k$ c: t" i
- $LNG['tech'][901],
, z6 B0 D) W& j# i$ s. g, S, L - pretty_number($stealResource[901]),
& ]/ o& f$ H( e* ^4 t - $LNG['tech'][902],
/ H' B* h, n+ O - pretty_number($stealResource[902]),
& {! w7 ]5 `0 |4 K, ]4 `: H - $LNG['tech'][903],
0 @, R2 r8 l* c0 E$ R) D/ O - pretty_number($stealResource[903]),
* h/ e/ i1 y/ @+ M - $LNG['sys_debris'],
7 Z4 `/ J8 u; o: i/ U - $LNG['tech'][901],5 n+ [1 y6 o6 w) j* {
- pretty_number($debris[901]), 9 i( S4 w" I: I( U: q
- $LNG['tech'][902],
' a: d q. f' P) | - pretty_number($debris[902])4 ^1 o0 ?/ H" R7 i! a0 h3 K" \
- );
* N1 L. j" _$ @4 U$ z -
3 ^6 j! ^/ Q5 F1 _- ^9 S - SendSimpleMessage($userID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $message);. d& c/ V V% W- w
-
5 Q& c+ T7 Q9 @2 A - $sqlQuery .= "INSERT INTO ".TOPKB_USERS." SET ";0 e. b# v, I% ^0 I
- $sqlQuery .= "rid = '".$raportID."', ";
1 {. |+ j/ v/ d& }+ X( E$ a - $sqlQuery .= "role = 1, ";
0 U5 f6 k3 ~/ I- J& E7 i" R! T1 ` - $sqlQuery .= "username = '".$GLOBALS['DATABASE']->escape($userName)."', ";
0 V; @7 B/ u- h - $sqlQuery .= "uid = ".$userID.";";" ~- P! D G9 Q# I8 o. ~; G) J- A
- }
R# w" X/ U5 _+ V- D: }+ F -
' U3 w# A$ t& C - ! J" |+ v6 W- O4 B
- foreach($userDefend as $userID => $userName)
' @- R* [* M/ @. `1 v, P2 [. r) n - {; z' Y" h( a5 X5 E/ P% }
- $LNG = $this->getLanguage(NULL, $userID);
3 m; l. | I3 M# w d4 p+ g -
2 ~% V2 V7 |$ f2 X' ]5 F - $message = sprintf($messageHTML,$ K# B9 ?; v6 u; n
- $raportID,. z* V, b1 Q- l5 [7 ], C
- $defendClass,7 d: Z# Y. Q6 I( M0 N0 B! \( T
- $LNG['sys_mess_attack_report'],) M. t. n; |% _( l( h y
- sprintf(
. a7 j& U9 v: W - $LNG['sys_adress_planet'],% s! i$ O7 M4 G: _6 H$ z
- $this->_fleet['fleet_end_galaxy'],& u' x3 q& i/ ~: P5 i0 C' T% e
- $this->_fleet['fleet_end_system'],& W" ~. o/ c# J1 }# K5 Y+ r& B$ E
- $this->_fleet['fleet_end_planet']8 M& a) t9 g8 h7 f* \
- ),
; u3 } f5 s* E" M8 Q ~ - $LNG['type_planet_short'][$this->_fleet['fleet_end_type']],& J2 p+ V9 b6 a+ A$ b1 M% v9 U- v0 D
- $LNG['sys_lost'],
/ l% I- s7 d& _6 A+ E - $defendClass,9 p1 ~: p; s. N( [( e/ p! P# { b
- $LNG['sys_attack_attacker_pos'],
3 h/ P2 y3 y" r4 j) l - pretty_number($combatResult['unitLost']['attacker']),, K% E) {% h3 R' a1 x* ?- I3 ?
- $attackClass,
* I& |" Y3 j9 R) v1 O( @0 } - $LNG['sys_attack_defender_pos'],; l/ Z& m6 b, _: m. X9 Y
- pretty_number($combatResult['unitLost']['defender']),
5 @5 z+ A8 `- } - $LNG['sys_gain'],
1 e2 D9 f$ Z6 b3 L* @ - $LNG['tech'][901],
. |+ q* M& r# U' p" Q# n$ ]6 T - pretty_number($stealResource[901]),4 k+ M4 {7 g3 r1 s. B
- $LNG['tech'][902],
. h3 x5 g. j% ~ - pretty_number($stealResource[902]),
* g+ f! Z! ]1 c - $LNG['tech'][903],* v5 T! `& j& {- ^: c
- pretty_number($stealResource[903]),
; o8 g1 J7 g3 l4 L- u, e* G - $LNG['sys_debris'],6 ?% N% \. K3 l) R
- $LNG['tech'][901],3 U& z+ n% X u/ e$ S* c
- pretty_number($debris[901]),
2 O1 d% R& @7 }+ c) x* u6 [ - $LNG['tech'][902],6 f) o/ I' ]9 D) T( l
- pretty_number($debris[902])
! }0 @) `) Y/ ~- e0 n; f* M) O N - );' k2 g. _3 z+ r0 t( L
-
; A5 G4 m+ ?: h - SendSimpleMessage($userID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $message);! i+ v- Q+ u7 j, S# q' ]
- 6 e+ | x; s3 e
- $sqlQuery .= "INSERT INTO ".TOPKB_USERS." SET ";9 b8 g' \7 w. \: ~- h$ j9 P
- $sqlQuery .= "rid = '".$raportID."', ";6 L$ }. [/ T7 f) L. F
- $sqlQuery .= "role = 2, ";4 X8 a! Y" r6 x( X: f2 n
- $sqlQuery .= "username = '".$GLOBALS['DATABASE']->escape($userName)."', ";& b, o4 _" Q* K
- $sqlQuery .= "uid = ".$userID.";";3 E. u. ]/ p0 l6 ~
- }6 N6 u; G( d! W# o) [, p0 u% j
-
! Z* ?! x& S3 S) R' i8 S - if($this->_fleet['fleet_end_type'] == 3)% N. G, p+ Z" J$ A$ T1 y
- {
, Y9 n! S5 r: |$ q9 c) t - $debrisType = 'id_luna';, ^4 _& t9 X+ N6 v
- }( w2 B! R( ~& R* \% _" t
- else
7 z' c, c% k% q9 N# B% x2 k2 z - {3 m! f6 p$ m V% M8 A# u
- $debrisType = 'id';
: U v( ?. j6 F$ x9 Z4 _ - }
) C I8 q; u0 \* w1 n - 6 s. j0 E$ Q, k, n1 h
- $sqlQuery .= "UPDATE ".PLANETS." SET
: O- @- X: g4 o- H - der_metal = ".$planetDebris[901].",, P; s" {* |! X( x0 \2 Q8 u
- der_crystal = ".$planetDebris[902]."" Q1 `3 B$ O- c( t3 L2 U/ R
- WHERE
" H w& ?- ?6 |" s# Z" { - ".$debrisType." = ".$this->_fleet['fleet_end_id'].";
) l1 s `( y. P6 ^; }* t* T* X - UPDATE ".PLANETS." SET
1 S) v/ s2 }6 v2 B" H9 p! j3 A - metal = metal - ".$stealResource[901].",, d4 r+ L- p7 y. t
- crystal = crystal - ".$stealResource[902].",& K, i% p: }% z0 ~: L; M# a
- deuterium = deuterium - ".$stealResource[903]."3 ?" N0 X$ m% H7 _, B
- WHERE
: f4 y4 t* o8 y+ l - id = ".$this->_fleet['fleet_end_id'].";
* V8 D$ Y! g z: h$ A - INSERT INTO ".TOPKB." SET6 l" {) f( @) Y9 U
- units = ".($combatResult['unitLost']['attacker'] + $combatResult['unitLost']['defender']).",
( O/ Y* R7 p" ~3 d Q. ] - rid = '".$raportID."',6 |. M/ L! a: F) G3 ^' o
- time = ".$this->_fleet['fleet_start_time'].",
+ y' l1 H' U; ~" F! D - universe = ".$this->_fleet['fleet_universe'].",
3 a6 \; j9 N( Y: P - result = '".$combatResult['won'] ."';
; H+ t/ j& Z0 U/ D# V5 @: ]9 e - UPDATE ".USERS." SET! L7 v& z) x5 v# N) J2 }; k, S- Y
- ".$attackStatus." = ".$attackStatus." + 1,* ^, `% P* K4 P6 ]6 J6 o8 t7 F$ `
- kbmetal = kbmetal + ".$debris[901].",
. p: A" n: P9 |: L6 K - kbcrystal = kbcrystal + ".$debris[902].",! ^5 a/ Y0 A7 a9 Q4 q
- lostunits = lostunits + ".$combatResult['unitLost']['attacker'].",$ E5 y$ a( A" ]1 B J0 H @
- desunits = desunits + ".$combatResult['unitLost']['defender']."8 f+ |* V: w9 y- p4 O
- WHERE3 i1 O* o( t5 Y$ r K2 N Z8 [7 Q
- id IN (".implode(',', array_keys($userAttack)).");
9 }6 `; |# y) e9 L3 g, }& y' g: M - UPDATE ".USERS." SET' d! @ f4 @4 [4 Z) c$ ^
- ".$defendStatus." = ".$defendStatus." + 1,
" _! T1 }- H' L - kbmetal = kbmetal + ".$debris[901].",
6 E: W; s& n! O9 N+ G5 I - kbcrystal = kbcrystal + ".$debris[902].",) @( J3 H7 n, T! T$ t: A- n5 Z
- lostunits = lostunits + ".$combatResult['unitLost']['defender'].",! H! ?: K( i0 n& T" @% y5 a/ s- I# [
- desunits = desunits + ".$combatResult['unitLost']['attacker']."/ c" k# u: R! g- q
- WHERE# s' N0 i) j, O& C! C
- id IN (".implode(',', array_keys($userDefend)).");";. _: ^: p4 G% O% ], E) X% z' ^
-
" q6 v9 r" j5 k& }# u Y - $GLOBALS['DATABASE']->multi_query($sqlQuery);! k' h P/ C4 o0 _! z2 \8 b& h
-
6 |5 X t( P6 c4 T - $this->setState(FLEET_RETURN);* m7 _) M% _& ^) Y1 z( f+ O
- $this->SaveFleet();
! L+ N7 H7 }2 [6 \ - }( c& K% }& O) M2 O
-
" _( L+ A) p q; p, p2 L, { - function EndStayEvent()) T$ z% E6 s( W5 K
- {! Z) e! B7 o, H' C0 h9 d
- return;. d: |; \) o2 A8 P3 n; f. l+ W1 U
- }
7 a& |+ O( }7 J. A6 V3 Q -
" |+ a W. @) o- ~, [; x - function ReturnEvent()
. W+ J/ j- k+ q9 V: s6 J. w' c9 O* Z - {" Q; b* x6 p8 \4 g* d
- $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
3 O2 S' V! j! _$ O M - $TargetName = $GLOBALS['DATABASE']->getFirstCell("SELECT name FROM ".PLANETS." WHERE id = ".$this->_fleet['fleet_start_id'].";");
! \% S) X$ p; ` - $Message = sprintf($LNG['sys_fleet_won'], $TargetName, GetTargetAdressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]);
% R: e" l: Q! @' e; W9 z
" r' [! W. f8 W- SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_fleetback'], $Message);
. }- W3 C" ~" m# P/ k0 Q - 6 L8 {- Z% l" k7 S/ B
- $this->RestoreFleet();0 r5 W! [' t6 m" w0 j
- } ~9 B- z4 Q- n: w
- }
複製程式碼 S+ A) b! f3 K8 o, f# Q
2 _! s. @% d5 z1 D, C3 s* @1 s |
|