fix showing attack on your oasis

This commit is contained in:
yi12345
2013-09-21 21:12:22 +03:00
parent a50b05c475
commit 5aca587f14
6 changed files with 137 additions and 43 deletions
+18 -6
View File
@@ -697,7 +697,7 @@ class Automation {
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
$starv = $database->getVillageField($indi['wid'],"starv");
if ($crop < $upkeep && $starv == 0){
// add starv data
// add starv data
$database->setVillageField($indi['wid'], 'starv', $upkeep);
$database->setVillageField($indi['wid'], 'starvupdate', $time);
}
@@ -2269,7 +2269,7 @@ class Automation {
if(!isset($nochiefing)){
//$info_chief = "".$chief_pic.",You don't have enought CP to chief a village.";
if($this->getTypeLevel(35,$data['from']) == 0){
for ($i=0; $i<($data['t9']-$dead9-$traped9); $i++){
for ($i=0; $i<($data['t9']-$dead9); $i++){
if($owntribe == 1){
$rand+=rand(20,30);
}else{
@@ -2277,7 +2277,7 @@ class Automation {
}
}
}else{
for ($i=0; $i<($data['t9']-$dead9-$traped9); $i++){
for ($i=0; $i<($data['t9']-$dead9); $i++){
$rand+=rand(5,15);
}
}
@@ -3009,7 +3009,12 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g33Icon.gif\" height=\"20\" width=\"15
$dataarray = $database->query_return($q);
foreach($dataarray as $data) {
if($data['from']==0){
$isoasis = $database->isVillageOases($data['to']);
if($isoasis == 0){
$to = $database->getMInfo($data['to']);
}else{
$to = $database->getOMInfo($data['to']);
}
$database->addEnforce($data);
$reinf = $database->getEnforce($data['to'],$data['from']);
$database->modifyEnforce($reinf['id'],31,1,1);
@@ -3815,7 +3820,14 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g33Icon.gif\" height=\"20\" width=\"15
foreach($harray as $hdata){
if((time()-$hdata['lastupdate'])>=1){
if($hdata['health']<100 and $hdata['health']>0){
$reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']);
if(SPEED <= 10){
$speed = SPEED;
}else if(SPEED <= 100){
$speed = ceil(SPEED/10);
}else{
$speed = ceil(SPEED/100);
}
$reg = $hdata['health']+$hdata['regeneration']*5*$speed/86400*(time()-$hdata['lastupdate']);
if($reg <= 100){
$database->modifyHero("health",$reg,$hdata['heroid']);
}else{
@@ -4418,8 +4430,8 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g33Icon.gif\" height=\"20\" width=\"15
$database->query($q);
}
}
function medals(){
function medals(){
global $ranking,$database;
//we mogen de lintjes weggeven
+1 -1
View File
@@ -2221,7 +2221,7 @@ class MYSQL_DB {
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC";
break;
case 6:
$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
break;
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";
+7 -2
View File
@@ -14,15 +14,20 @@
<?php
$units_type = $database->getMovement("34",$village->wid,1);
$settlers = $database->getMovement("7",$village->wid,1);
$oasis_incoming = 0;
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$oasis_incoming += count($database->getMovement(6,$conqured['wref'],0));
}
$units_incoming = count($units_type);
$settlers_incoming = count($settlers);
for($i=0;$i<$units_incoming;$i++){
if($units_type[$i]['attack_type'] == 1 && $units_type[$i]['sort_type'] == 3)
$units_incoming -= 1;
}
if($units_incoming > 0 or $settlers_incoming > 0){
if($units_incoming > 0 or $settlers_incoming > 0 or $oasis_incoming > 0){
?>
<h4>Incoming troops (<?php echo $units_incoming; ?>)</h4>
<h4>Incoming troops (<?php echo $units_incoming+$settlers_incoming+$oasis_incoming; ?>)</h4>
<?php include("16_incomming.tpl");
}
?>
+87 -1
View File
@@ -133,7 +133,7 @@ if ($units[$y]['sort_type']==3){
if ($units[$y]['attack_type']==1){
$actionType = "Return from ";
} else if ($units[$y]['attack_type']==2){
$actionType = "Reinforment for ";
$actionType = "Reinforcement for ";
} else if ($units[$y]['attack_type']==3){
$actionType = "Return from ";
} else if ($units[$y]['attack_type']==4){
@@ -212,6 +212,92 @@ $to = $database->getMInfo($units[$y]['vref']);
<?php
}
}
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$oasis = $database->getMovement("6",$conqured['wref'],0);
$total_for = count($oasis);
for($y=0;$y < $total_for;$y++){
$timer = $y+1;
if ($oasis[$y]['attack_type']==2){
$actionType = "Reinforcement for ";
} else if ($oasis[$y]['attack_type']==3){
$actionType = "Attack on ";
} else if ($oasis[$y]['attack_type']==4){
$actionType = "Raid on ";
}
$reinfowner = $database->getVillageField($oasis[$y]['from'],"owner");
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) {
$colspan = 11;
}else{
$colspan = 10;
}
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
<a href=\"karte.php?d=".$oasis[$y]['from']."&c=".$generator->getMapCheck($oasis[$y]['from'])."\">".$database->getVillageField($oasis[$y]['from'],"name")."</a></td>
<td colspan=\"$colspan\">";
echo "<a href=\"spieler.php?uid=".$database->getVillageField($oasis[$y]['from'],"owner")."\">".$database->getUserField($database->getVillageField($oasis[$y]['from'],"owner"),"username",0)."'s troops</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $database->getUserField($database->getVillageField($oasis[$y]['from'],"owner"),"tribe",0);
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>Troops</th>";
for($i=1;$i<=$colspan;$i++) {
$totalunits = $oasis[$y]['t1']+$oasis[$y]['t2']+$oasis[$y]['t3']+$oasis[$y]['t4']+$oasis[$y]['t5']+$oasis[$y]['t6']+$oasis[$y]['t7']+$oasis[$y]['t8']+$oasis[$y]['t9']+$oasis[$y]['t10']+$oasis[$y]['t11'];
if($oasis[$y]['attack_type'] == 2){
if($reinfowner != $session->uid){
echo "<td class=\"none\">?</td>";
}else{
if($oasis[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}
else {
echo "<td>";
echo $oasis[$y]['t'.$i]."</td>";
}
}}else{
$artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,3,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,3,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,3,2,0));
$total_artefact = $artefact + $artefact1 + $artefact2;
if($totalunits > $building->getTypeLevel(16) && $total_artefact == 0){
echo "<td class=\"none\">?</td>";
}else{
if($oasis[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}else{
echo "<td>?</td>";
}
}
}
}
echo "</tr></tbody>";
echo '
<tbody class="infos">
<tr>
<th>Arrival</th>
<td colspan="10">
<div class="in small"><span id=timer'.$timer.'>'.$generator->getTimeFormat($oasis[$y]['endtime']-time()).'</span> h</div>';
$datetime = $generator->procMtime($oasis[$y]['endtime']);
echo "<div class=\"at small\">";
if($datetime[0] != "today") {
echo "on ".$datetime[0]." ";
}
echo "at ".$datetime[1]." hours</div>
</div>
</td>
</tr>
</tbody>";
echo "</table>";
}
}
$settlers = $database->getMovement("7",$village->wid,1);
$total_for3 = count($settlers);
+2 -2
View File
@@ -140,9 +140,9 @@ $timer += 1;
echo "on ".$datetime[0]." ";
}
echo "at ".$datetime[1]."</div>";
if (($units[$y]['starttime']+90)>time()){
if (($settlers[$y]['starttime']+90)>time()){
?>
<div class="abort"><a href="build.php?id=<?php echo $_GET['id']."&mode=troops&cancel=1&moveid=".$units[$y]['moveid']; ?>"><img src="img/x.gif" class="del" /></a></div>
<div class="abort"><a href="build.php?id=<?php echo $_GET['id']."&mode=troops&cancel=1&moveid=".$settlers[$y]['moveid']; ?>"><img src="img/x.gif" class="del" /></a></div>
<?php } ?>
</div>
</td>
+22 -31
View File
@@ -9,8 +9,12 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(34,$village->wid,1))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))+count($database->getMovement(5,$village->wid,0))+count($database->getMovement(6,$village->wid,0))-count($database->getMovement(8,$village->wid,1))-count($database->getMovement(9,$village->wid,0)));
$oases = 0;
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$oases += count($database->getMovement(6,$village->wid,0));
}
$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))+count($database->getMovement(5,$village->wid,0))+$oases-count($database->getMovement(8,$village->wid,1))-count($database->getMovement(9,$village->wid,0)));
if($aantal > 0){
echo '<table id="movements" cellpadding="1" cellspacing="1"><thead><tr><th colspan="3">'.TROOP_MOVEMENTS.'</th></tr></thead><tbody>';
@@ -51,7 +55,7 @@ if($aantal > 0){
if ($receive['attack_type'] == 2) {
$action = 'def1';
$aclass = 'd1';
$title = ''.OWN_REINFORCING_TROOPS.'';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival[] = $receive['endtime'];
}
@@ -132,31 +136,6 @@ if($lala > 0){
$timer += 1;
}
/* Units send to reinf. (to my town) */
$units_type = $database->getMovement("34",$village->wid,1);
$lala = count($units_type);
for($i=0;$i<$lala;$i++){
if(($units_type[$i]['attack_type']==1)){
$lala -= 1;
}
}
if($lala > 0){
if(!empty($NextArrival4)) { reset($NextArrival4); }
foreach($units_type as $receive) {
$action = 'def1';
$aclass = 'd1';
$title = ''.OWN_REINFORCING_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
$NextArrival4[] = $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">&nbsp;<span id="timer'.$timer.'">'.$generator->getTimeFormat($receive['endtime']-time()).'</span>&nbsp;'.HOURS.'</div></div></td></tr>';
$timer += 1;
}
/* Found NEW VILLAGE by Shadow */
$aantal = count($database->getMovement(5,$village->wid,0));
@@ -179,15 +158,27 @@ if($aantal > 0){
/* Attacks on Oasis (to my oasis) by Shadow */
$aantal = count($database->getMovement(6,$village->wid,0));
$aantal2 = $database->getMovement(6,$village->wid,0);
$aantal = 0;
$aantal2 = array();
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$aantal += count($database->getMovement(6,$conqured['wref'],0));
$aantal2 = array_merge($database->getMovement(6,$conqured['wref'],0), $aantal2);
}
if($aantal > 0){
if(!empty($NextArrival6)) { reset($NextArrival6); }
foreach($aantal2 as $receive) {
if($receive['attack_type'] == 2){
$action = 'def3';
$aclass = 'd3';
$title = ''.ARRIVING_REINF_TROOPS.'';
$short = ''.ARRIVING_REINF_TROOPS_SHORT.'';
}else{
$action = 'att3';
$aclass = 'a1';
$aclass = 'a3';
$title = ''.OASISATTACK.'';
$short = ''.OASISATTACKS.'';
}
$NextArrival6[] = $receive['endtime'];
}