Merge pull request #510 from iopietro/master

Added some things
This commit is contained in:
Vladyslav
2018-04-05 08:32:37 +03:00
committed by GitHub
21 changed files with 89 additions and 223 deletions
+15 -144
View File
@@ -1118,7 +1118,7 @@ class Automation {
if ($isSecondRow) {
if ($tbid > 0 || ($tbid == 0 && strpos($info_cat, 'The village has') === false)) {
$info_cat .= "<br><tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
<img class=\"unit u" . $catp_pic . "\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> " . $this->procResType( $tbgid, $can_destroy, $isoasis ) . " destroyed.";
<img class=\"unit u" . $catp_pic . "\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> " . $this->procResType( $tbgid, $can_destroy, $isoasis ) . " <b>destroyed</b>.";
}
// embassy level was changed
@@ -1128,7 +1128,7 @@ class Automation {
$info_cat .= "</td></tr></tbody>";
} else {
$info_cat = "" . $catp_pic . ", " . $this->procResType( $tbgid, $can_destroy, $isoasis ) . " destroyed.";
$info_cat = "" . $catp_pic . ", " . $this->procResType( $tbgid, $can_destroy, $isoasis ) . " <b>destroyed</b>.";
// embassy level was changed
if ($tbgid==18){
@@ -1175,7 +1175,7 @@ class Automation {
if ($tblevel == 1 && $totallvl == 0) {
// building was actually destroyed - recalculate population and remove village itself, if needed
$info_cata = " destroyed.";
$info_cata = " <b>destroyed</b>.";
} else {
// building was damaged to a lower level
$info_cata = " damaged from level <b>" . $tblevel . "</b> to level <b>" . $totallvl . "</b>.";
@@ -3335,140 +3335,6 @@ class Automation {
}
}
private function sendTroopsBack($post) {
global $form, $database, $village, $generator, $session, $technology;
$enforce=$database->getEnforceArray($post['ckey'],0);
$to = $database->getVillage($enforce['from']);
$Gtribe = "";
if ($database->getUserField($to['owner'],'tribe',0) == '2'){ $Gtribe = "1"; } else if ($database->getUserField($to['owner'],'tribe',0) == '3'){ $Gtribe = "2"; } else if ($database->getUserField($to['owner'],'tribe',0) == '4'){ $Gtribe = "3"; }else if ($database->getUserField($to['owner'],'tribe',0) == '5'){ $Gtribe = "4"; }
for($i=1; $i<10; $i++){
if(isset($post['t'.$i])){
if($i!=10){
if ($post['t'.$i] > $enforce['u'.$Gtribe.$i])
{
$form->addError("error","You can't send more units than you have");
break;
}
if($post['t'.$i]<0)
{
$form->addError("error","You can't send negative units.");
break;
}
}
} else {
$post['t'.$i.'']='0';
}
}
if(isset($post['t11'])){
if ($post['t11'] > $enforce['hero'])
{
$form->addError("error","You can't send more units than you have");
}
if($post['t11']<0)
{
$form->addError("error","You can't send negative units.");
}
} else {
$post['t11']='0';
}
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
exit;
} else {
//change units
$start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1;
$end = ($database->getUserField($to['owner'],'tribe',0)*10);
$j='1';
$units = [];
$amounts = [];
$modes = [];
for($i=$start;$i<=$end;$i++){
$units[] = $i;
$amounts[] = $post['t'.$j.''];
$modes[] = 0;
$j++;
}
$database->modifyEnforce($post['ckey'], $units, $amounts, $modes);
//get cord
$from = $database->getVillage($enforce['from']);
$fromcoor = $database->getCoor($enforce['from']);
$tocoor = $database->getCoor($enforce['vref']);
$fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']);
$toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']);
$speeds = array();
//find slowest unit.
for($i=1;$i<=10;$i++){
if (isset($post['t'.$i])){
if( $post['t'.$i] != '' && $post['t'.$i] > 0){
if($unitarray) { reset($unitarray); }
$unitarray = $GLOBALS["u".(($session->tribe-1)*10+$i)];
$speeds[] = $unitarray['speed'];
} else {
$post['t'.$i.'']='0';
}
} else {
$post['t'.$i.'']='0';
}
}
if (isset($post['t11'])){
if( $post['t11'] != '' && $post['t11'] > 0){
$hero_unit = getHeroField($from['owner'], 'unit');
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
} else {
$post['t11']='0';
}
} else {
$post['t11']='0';
}
$artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($from['vref'],2,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
if($artefact > 0){
$fastertroops = 3;
}else if($artefact1 > 0){
$fastertroops = 2;
}else if($artefact2 > 0){
$fastertroops = 1.5;
}else{
$fastertroops = 1;
}
$time = round($generator->procDistanceTime($fromCor,$toCor,min($speeds),1)/$fastertroops);
$foolartefact4 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']);
if(count($foolartefact4) > 0){
foreach($foolartefact4 as $arte){
if($arte['bad_effect'] == 1){
$time *= $arte['effect2'];
}else{
$time /= $arte['effect2'];
$time = round($endtime);
}
}
}
$reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
$database->addMovement(4,$village->wid,$enforce['from'],$reference,$AttackArrivalTime,($time+$AttackArrivalTime));
$technology->checkReinf($post['ckey']);
header("Location: build.php?id=39");
exit;
}
}
private function sendreinfunitsComplete() {
global $bid23,$database,$battle,$session,$autoprefix;
@@ -4441,15 +4307,20 @@ class Automation {
$valuesUpdated = false;
if($timepast <= 0 && $train['amt'] > 0) {
$valuesUpdated = true;
$timepast2 = $time - $train['timestamp2'];
$trained = 1;
while($timepast2 >= $train['eachtime']){
$timepast2 -= $train['eachtime'];
$trained += 1;
}
if($trained > $train['amt']){
if($train['eachtime'] > 0){
$timepast2 = $time - $train['timestamp2'];
$trained = 1;
while($timepast2 >= $train['eachtime']){
$timepast2 -= $train['eachtime'];
$trained += 1;
}
if($trained > $train['amt']){
$trained = $train['amt'];
}
}else{
$trained = $train['amt'];
}
if($train['unit']>60 && $train['unit']!=99){
$database->modifyUnit($train['vref'],array($train['unit']-60),array($trained),array(1));
}else{
+1 -55
View File
@@ -6113,9 +6113,7 @@ References: User ID/Message ID, Mode
}
}
}
if ( $each == 0 ) {
$each = 1;
}
$time2 = $now + $each;
if ( count( $queued ) > 0 ) {
$time += $queued[ count( $queued ) - 1 ]['timestamp'] - $now;
@@ -7882,58 +7880,6 @@ References:
return false;
}
/***************************
Function checkAttack
Made by: Shadow
***************************/
// no need to cache this method
function checkAttack($wref, $toWref) {
list($wref, $toWref) = $this->escape_input((int) $wref, (int) $toWref);
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref 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 = 3 or " . TB_PREFIX . "attacks.attack_type = 4) ORDER BY endtime ASC";
$result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
if ($result['Total']) {
return true;
} else {
return false;
}
}
/***************************
Function checkEnforce
Made by: Shadow
***************************/
// no need to cache this method
function checkEnforce($wref, $toWref) {
list($wref, $toWref) = $this->escape_input((int) $wref, (int) $toWref);
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref 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 = 2 ORDER BY endtime ASC";
$result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
if($result['Total']) {
return true;
}else{
return false;
}
}
/***************************
Function checkScout
Made by: yi12345
***************************/
// no need to cache this method
function checkScout($wref, $toWref) {
list($wref, $toWref) = $this->escape_input((int) $wref, (int) $toWref);
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.from = $wref and " . TB_PREFIX . "movement.to = $toWref 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";
$result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
if($result['Total']) {
return true;
}else{
return false;
}
}
};
// database is not needed if we're displaying static pages
+1
View File
@@ -628,6 +628,7 @@ define("TROOPS","Troops");
define("TROOPSFROM","Troops");
define("BOUNTY","Bounty");
define("ARRIVAL","Arrival");
define("CATAPULT_TARGET","Catapult target(s)");
define("INCOMING_TROOPS","Incoming Troops");
define("TROOPS_ON_THEIR_WAY","Troops on their way");
define("OWN_TROOPS","Own troops");
-1
View File
@@ -640,7 +640,6 @@ private function trainUnit($unit,$amt,$great=false) {
$clay = ${'u'.$unit}['clay'] * $amt * ($great?3:1);
$iron = ${'u'.$unit}['iron'] * $amt * ($great?3:1);
$crop = ${'u'.$unit}['crop'] * $amt * ($great?3:1);
$each = ($each == 0) ? 1 : $each;
$time = $each*$amt;
if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0) && $amt > 0) {
$database->trainUnit($village->wid,$unit+($great?60:0),$amt,${'u'.$unit}['pop'],$each,time()+$time,0);
+41 -9
View File
@@ -363,7 +363,7 @@ class Units {
if ( $data['u11'] < 0 ) {
$form->addError( "error", "You can't send negative units." );
}
if ( $form->returnErrors() > 0 ) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
@@ -503,8 +503,44 @@ class Units {
}
}
}
}
}
$rallyPointLevel = ($village->resarray)['f39'];
$invalidBuildings = [];
// fill the array with the invalid buildings
if($rallyPointLevel >= 3 && $rallyPointLevel < 5){
for($i = 1; $i <= 37; $i++){
if(!in_array($i, [10, 11])) $invalidBuildings[] = $i;
}
}
else if($rallyPointLevel >= 5 && $rallyPointLevel < 10){
for($i = 12; $i <= 37; $i++) $invalidBuildings[] = $i;
}
else if($rallyPointLevel >= 10){
$invalidBuildings = [23, 31, 32, 33, 34, 36];
}
if(isset($post['ctar1']) && $post['ctar1'] != 0){
// check if the player has selected a valid building
if($rallyPointLevel < 3 || $data['u8'] == 0 || in_array($post['ctar1'], $invalidBuildings) || $post['ctar1'] < 0 || $post['ctar1'] > 40){
$post['ctar1'] = 0;
}
}
if(isset($post['ctar2']) && $post['ctar2'] != 0){
// check if there are atleast 20 catapults
if($data['u8'] < 20 || $rallyPointLevel != 20){
$post['ctar2'] = 0;
}else{
// check if the player has selected a valid building
if(in_array($post['ctar2'], $invalidBuildings) || ($post['ctar2'] < 0 || $post['ctar2'] > 40 && $post['ctar2'] != 99)){
$post['ctar2'] = 99;
}
}
}
//TODO: check those instructions, i think that they're wrong
if ( isset( $post['ctar1'] ) ) {
if ( $artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1 ) {
if ( $post['ctar1'] != 40 or $post['ctar1'] != 27 and $iswwvilla == 1 ) {
@@ -512,12 +548,11 @@ class Units {
} else {
$post['ctar1'] = 99;
}
} else {
$post['ctar1'] = $post['ctar1'];
}
} else {
$post['ctar1'] = 0;
}
if ( isset( $post['ctar2'] ) ) {
if ( $artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1 ) {
if ( $post['ctar2'] != 40 or $post['ctar2'] != 27 and $iswwvilla == 1 ) {
@@ -525,15 +560,12 @@ class Units {
} else {
$post['ctar2'] = 99;
}
} else {
$post['ctar2'] = $post['ctar2'];
}
} else {
$post['ctar2'] = 0;
}
if ( isset( $post['spy'] ) ) {
$post['spy'] = $post['spy'];
} else {
if (!isset($post['spy'])) {
$post['spy'] = 0;
}
$abdata = $database->getABTech( $village->wid );
+13
View File
@@ -60,6 +60,19 @@ $to = $database->getOMInfo($units[$y]['to']);}
}
?>
</tr></tbody>
<?php if($units[$y]['t8'] > 0 && $units[$y]['attack_type'] == 3 && !$database->isVillageOases($units[$y]['to'])){ ?>
<tbody>
<tr>
<th><?php echo CATAPULT_TARGET;?></th>
<td style="text-align: center" colspan="5">
<?php echo $units[$y]['ctar1'] == 0 ? "Random" : $building->procResType($units[$y]['ctar1']); ?>
</td>
<td style="text-align: center" colspan="<?php if($units[$y]['t11'] == 0) {echo"5";}else{echo"6";}?>">
<?php echo $units[$y]['ctar2'] == 99 ? "Random" : ($units[$y]['ctar2'] == 0 ? "-" : $building->procResType($units[$y]['ctar2'])); ?>
</td>
</tr>
</tbody>
<?php } ?>
<tbody class="infos">
<tr>
<th><?php echo ARRIVAL;?></th>
+2 -2
View File
@@ -39,7 +39,7 @@ $dur=round(${'u'.$i}['time'] * ($bid19[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
@@ -75,7 +75,7 @@ $dur=round(${'u'.$i}['time'] * ($bid19[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) {
echo "|<a href=\"build.php?gid=17&t=3&r1=".((${'u'.$i}['wood'])*$technology->maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
}
+1 -1
View File
@@ -40,7 +40,7 @@ for($i=4;$i<=6;$i++) {
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) {
echo "|<a href=\"build.php?gid=17&t=3&r1=".((${'u'.$i}['wood'])*$technology->maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
}
+1 -1
View File
@@ -35,7 +35,7 @@ for($i=15;$i<=16;$i++) {
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -35,7 +35,7 @@ for($i=23;$i<=26;$i++) {
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -35,7 +35,7 @@ for($i=35;$i<=36;$i++) {
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -35,7 +35,7 @@ for($i=45;$i<=46;$i++) {
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
echo "</div></td>
<td class=\"val\">
<input type=\"text\" class=\"text\" name=\"t$i\" value=\"0\" maxlength=\"10\">
+1 -1
View File
@@ -65,7 +65,7 @@
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -65,7 +65,7 @@ $dur=round(${'u'.$i}['time'] * ($bid25[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -65,7 +65,7 @@ $dur=round(${'u'.$i}['time'] * ($bid26[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -38,7 +38,7 @@ $dur=round(${'u'.$i}['time'] * ($bid29[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -38,7 +38,7 @@ $dur=round(${'u'.$i}['time'] * ($bid30[$village->resarray['f'.$id]]['attri'] * (
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -37,7 +37,7 @@ $dur=round(${'u'.$i}['time'] * ($bid42[$village->resarray['f'.$id]]['attri'] / 1
}
}
$dur=$generator->getTimeFormat($dur);
echo ($dur=="0:00:00")? "0:00:01":$dur;
echo $dur;
//-- If available resources combined are not enough, remove NPC button
$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']);
+1 -1
View File
@@ -250,7 +250,7 @@ if($armoury == 0 && ($mainbuilding <= 2 || $academy == 0)) {
if($cropland <= 4) {
include("soon/grainmill.tpl");
}
if($marketplace == 0 && ($mainbuilding <= 2 || $granary <= 0 || $warehouse <= 0)) {
if($market == 0 && ($mainbuilding <= 2 || $granary <= 0 || $warehouse <= 0)) {
include("soon/marketplace.tpl");
}
if($residence == 0 && $mainbuilding <= 4) {
+2
View File
@@ -242,6 +242,7 @@ $end = ($tribe*10);
<option value="26">Palace</option>
<option value="27">Treasury</option>
<option value="28">Trade office</option>
<option value="35">Brewery</option>
<?php } ?>
<option value="38">Great warehouse</option>
<option value="39">Great granary</option>
@@ -298,6 +299,7 @@ $end = ($tribe*10);
<option value="27">Treasury</option>
<option value="28">Trade office</option>
<option value="35">Brewery</option>
<?php } ?>
<option value="38">Great warehouse</option>
<option value="39">Great granary</option>
+2
View File
@@ -228,6 +228,7 @@ $actionType = "Raid";
<option value="27">Treasury</option>
<option value="28">Trade office</option>
<option value="35">Brewery</option>
<?php } ?>
<option value="38">Great warehouse</option>
<option value="39">Great granary</option>
@@ -282,6 +283,7 @@ $actionType = "Raid";
<option value="27">Treasury</option>
<option value="28">Trade office</option>
<option value="35">Brewery</option>
<?php } ?>
<option value="38">Great warehouse</option>
<option value="39">Great granary</option>