some movement fixes

This commit is contained in:
unknown
2012-06-22 04:15:28 +03:00
parent 11034d3331
commit 9c9ee7ebe7
5 changed files with 51 additions and 92 deletions
File diff suppressed because one or more lines are too long
+3 -13
View File
@@ -2016,19 +2016,6 @@ class MYSQL_DB {
return $row[0] + $row2[0] + $row3[0];
}
/***************************
Function to retrieve movement of village
Type 0: Send Resource
Type 1: Send Merchant
Type 2: Return Resource
Type 3: Attack
Type 4: Return
Type 5: Settler
Type 6: Bounty Type 7: Reinf.
Mode 0: Send/Out
Mode 1: Recieve/In
References: Type, Village, Mode
***************************/
function getMovement($type, $village, $mode) {
$time = time();
if(!$mode) {
@@ -2061,6 +2048,9 @@ class MYSQL_DB {
case 7:
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
break;
case 8:
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC";
break;
case 34:
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
break;
+1 -1
View File
@@ -358,7 +358,7 @@ class Message {
$welcomemsg = preg_replace("'%USER%'", $username, $welcomemsg);
$welcomemsg = preg_replace("'%START%'", date("y.m.d", COMMENCE), $welcomemsg);
$welcomemsg = preg_replace("'%TIME%'", date("H:i", COMMENCE), $welcomemsg);
$welcomemsg = preg_replace("'%PLAYERS%'", $database->countUser()-4, $welcomemsg);
$welcomemsg = preg_replace("'%PLAYERS%'", $database->countUser(), $welcomemsg);
$welcomemsg = preg_replace("'%ALLI%'", $database->countAlli(), $welcomemsg);
$welcomemsg = preg_replace("'%SERVER_NAME%'", SERVER_NAME, $welcomemsg);
$welcomemsg = "[message]".$welcomemsg."[/message]";
+8 -8
View File
@@ -55,16 +55,16 @@ function showCheckList() {
newTD1.className = 'ally';
newTD2.className = 'tag';
newTD3.className = 'ad';
newTD1.innerHTML = html_input_1 + 'id="allys_by_id_'+num_fields+'" class="text" maxlength="8" name="allys_by_id['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'allys\')">';
newTD2.innerHTML = html_input_1 + 'id="allys_by_name_'+num_fields+'" class="text" maxlength="8" name="allys_by_name['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'allys\')">';
newTD1.innerHTML = html_input_1 + 'id="allys_by_id_'+num_fields+'" class="text" maxlength="15" name="allys_by_id['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'allys\')">';
newTD2.innerHTML = html_input_1 + 'id="allys_by_name_'+num_fields+'" class="text" maxlength="15" name="allys_by_name['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'allys\')">';
}
if(element_id == 'user_list') {
newTD1.className = 'id';
newTD2.className = 'pla';
newTD3.className = 'ad';
newTD1.innerHTML = html_input_1 + 'id="users_by_id_'+num_fields+'" class="text" maxlength="8" name="users_by_id['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'users\')">';
newTD2.innerHTML = html_input_1 + 'id="users_by_name_'+num_fields+'" class="text" maxlength="15" name="users_by_name['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'users\')">';
newTD1.innerHTML = html_input_1 + 'id="users_by_id_'+num_fields+'" class="text" maxlength="15" name="users_by_id['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'users\')">';
newTD2.innerHTML = html_input_1 + 'id="users_by_name_'+num_fields+'" class="text" maxlength="50" name="users_by_name['+num_fields+']" onkeyup="checkInputs('+num_fields+',\'users\')">';
}
newTD3.innerHTML = '<img class="add" src="img/x.gif" title="add" alt="add" onclick="addRow(\''+element_id+'\')">';
@@ -139,10 +139,10 @@ function showCheckList() {
</thead><tbody>
<tr>
<td class="ally">
<input class="text" type="text" id="allys_by_id_0" maxlength="8" name="allys_by_id[0]" onkeyup="checkInputs(0,'allys');" />
<input class="text" type="text" id="allys_by_id_0" maxlength="15" name="allys_by_id[0]" onkeyup="checkInputs(0,'allys');" />
</td>
<td class="tag">
<input class="text" type="text" id="allys_by_name_0" maxlength="8" name="allys_by_name[0]" onkeyup="checkInputs(0,'allys');" />
<input class="text" type="text" id="allys_by_name_0" maxlength="15" name="allys_by_name[0]" onkeyup="checkInputs(0,'allys');" />
</td>
<td class="ad">
@@ -162,11 +162,11 @@ function showCheckList() {
</thead><tbody>
<tr>
<td class="id">
<input class="text" type="text" id="users_by_id_0" maxlength="8" name="users_by_id[0]" onkeyup="checkInputs(0,'users');" />
<input class="text" type="text" id="users_by_id_0" maxlength="15" name="users_by_id[0]" onkeyup="checkInputs(0,'users');" />
</td>
<td class="pla">
<input class="text" type="text" id="users_by_name_0" maxlength="15" name="users_by_name[0]" onkeyup="checkInputs(0,'users');" />
<input class="text" type="text" id="users_by_name_0" maxlength="50" name="users_by_name[0]" onkeyup="checkInputs(0,'users');" />
</td>
<td class="ad">
<img class="add" src="img/x.gif" title="add" alt="add" onclick="addRow('user_list')" />
+38 -69
View File
@@ -9,16 +9,28 @@
## ##
#################################################################################
$aantal=(count($database->getMovement(4,$village->wid,1))+count($database->getMovement(4,$village->wid,0))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1)));
$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(4,$village->wid,0))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))-count($database->getMovement(8,$village->wid,1)));
if($aantal > 0){
echo '<table id="movements" cellpadding="1" cellspacing="1"><thead><tr><th colspan="3">'.TROOP_MOVEMENTS.'</th></tr></thead><tbody>';
}
$NextArrival = array();
$NextArrival1 = array();
$NextArrival2 = array();
$NextArrival3 = array();
/* Units coming back from Reinf,attack,raid */
$aantal = count($database->getMovement(4,$village->wid,1));
/* Units coming back from Reinf,attack,raid,evasion or reinf to my town */
$aantal = count($database->getMovement(4,$village->wid,1))+count($database->getMovement(7,$village->wid,1));
$aantal2 = $database->getMovement(4,$village->wid,1);
$aantal3 = $database->getMovement(7,$village->wid,1);
$aantal4 = count($database->getMovement(3,$village->wid,1));
$lala = $aantal4;
$aantal5 = $database->getMovement(3,$village->wid,1);
for($i=0;$i<$aantal4;$i++){
if(($aantal5[$i]['attack_type']==1) or ($aantal5[$i]['attack_type']==3) or ($aantal5[$i]['attack_type']==4)) { $lala -= 1; }
}
$aantal = $aantal+$lala;
if($aantal > 0){
foreach($aantal2 as $receive) {
$action = 'def1';
@@ -27,22 +39,22 @@ if($aantal > 0){
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
}
/* Units coming back from evasion */
$aantal = count($database->getMovement(7,$village->wid,1));
$aantal2 = $database->getMovement(7,$village->wid,1);
if($aantal > 0){
foreach($aantal2 as $receive) {
foreach($aantal3 as $receive) {
$action = 'def1';
$aclass = 'd1';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
foreach($aantal5 as $receive) {
if ($receive['attack_type'] == 2) {
$action = 'def1';
$aclass = 'd1';
$title = ''.OWN_REINFORCING_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
@@ -50,20 +62,22 @@ if($aantal > 0){
/* attack/raid on you! */
$aantal = count($database->getMovement(3,$village->wid,1));
$aantal1 = count($database->getMovement(3,$village->wid,1));
$aantal2 = $database->getMovement(3,$village->wid,1);
for($i=0;$i<$aantal;$i++){
for($i=0;$i<$aantal1;$i++){
if($aantal2[$i]['attack_type'] == 2) { $aantal -= 1; }
if($aantal2[$i]['attack_type'] == 1) { $aantal -= 1; }
}
if($aantal > 0){
if(!empty($NextArrival)) { reset($NextArrival); }
if(!empty($NextArrival1)) { reset($NextArrival1); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] != 2) {
if ($receive['attack_type'] != 2 && $receive['attack_type'] != 1) {
$action = 'att1';
$aclass = 'a1';
$title = ''.OWN_ATTACKING_TROOPS.'';
$short = ''.ATTACK.'';
$NextArrival[] = $receive['endtime'];
$NextArrival1[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
@@ -73,19 +87,20 @@ if($aantal > 0){
/* on attack, raid */
$aantal = count($database->getMovement(3,$village->wid,0));
$aantal1 = count($database->getMovement(3,$village->wid,0));
$aantal2 = $database->getMovement(3,$village->wid,0);
for($i=0;$i<$aantal;$i++){
for($i=0;$i<$aantal1;$i++){
if($aantal2[$i]['attack_type'] == 2) { $aantal -= 1; }
}
if($aantal > 0){
if(!empty($NextArrival)) { reset($NextArrival); }
if(!empty($NextArrival2)) { reset($NextArrival2); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] != 2) {
$action = 'att2';
$aclass = 'a2';
$title = ''.OWN_ATTACKING_TROOPS.'';
$short = ''.ATTACK.'';
$NextArrival[] = $receive['endtime'];
$NextArrival2[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
@@ -101,63 +116,17 @@ for($i=0;$i<$aantal;$i++){
if(($aantal2[$i]['attack_type']==1) or ($aantal2[$i]['attack_type']==3) or ($aantal2[$i]['attack_type']==4)) { $lala -= 1; }
}
if($lala > 0){
if(!empty($NextArrival)) { reset($NextArrival); }
if(!empty($NextArrival3)) { reset($NextArrival3); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] == 2) {
$action = 'def2';
$aclass = 'd2';
$title = ''.OWN_REINFORCING_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
$NextArrival3[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$lala.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
}
/* Units send to reinf. (to my town) */
$aantal = count($database->getMovement(3,$village->wid,1)); $lala=$aantal;
$aantal2 = $database->getMovement(3,$village->wid,1);
for($i=0;$i<$aantal;$i++){
if(($aantal2[$i]['attack_type']==1) or ($aantal2[$i]['attack_type']==3) or ($aantal2[$i]['attack_type']==4)) { $lala -= 1; }
}
if($lala > 0){
if(!empty($NextArrival)) { reset($NextArrival); }
foreach($aantal2 as $receive) {
if ($receive['attack_type'] == 2) {
$action = 'def1';
$aclass = 'd1';
$title = ''.OWN_REINFORCING_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&raquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$lala.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
}
/* Units coming back from ATTACK
$gettroops = $database->getMovement(3,$village->wid,1);
for($i=0;$i<count($gettroops);$i++){
if($gettroops[$i]['attack_type'] == 1) { unset($gettroops[$i]); }
}
$aantal2 = array_values($gettroops);
$aantal = count($aantal2);
if($aantal > 0){
if(!empty($NextArrival)) { reset($NextArrival); }
foreach($aantal2 as $receive) {
$action = 'att1';
$aclass = 'a1';
$title = 'Incoming troops';
$short = 'Attack';
$NextArrival[] = $receive['endtime'];
}
echo '<tr><td class="typ"><a href="build.php?id=39"><img src="img/x.gif" class="'.$action.'" alt="'.$title.'" title="'.$title.'" /></a><span class="'.$aclass.'">&laquo;</span></td>
<td><div class="mov"><span class="'.$aclass.'">'.$aantal.'&nbsp;'.$short.'</span></div><div class="dur_r">in&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat(min($NextArrival)-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
}
?>
</tbody></table>
*/
}