fixed bugs of NarcisRO and more

This commit is contained in:
unknown
2012-06-05 16:07:57 +03:00
parent 08c11858a2
commit b8d1267a4a
8 changed files with 180 additions and 16 deletions
+120 -6
View File
@@ -939,7 +939,7 @@ class Automation {
$stonemason = "1";
}
if(PEACE == False || $targettribe == 4 || $targettribe == 5){
if(PEACE == 0 || $targettribe == 4 || $targettribe == 5){
$battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref);
//units attack string for battleraport
@@ -1122,7 +1122,7 @@ class Automation {
$troopsdead6 = $dead6;
$troopsdead7 = $dead7;
$troopsdead8 = $dead8;
$troopsdead9 = $dead9;
$troopsdead9 = $dead9-1;
$troopsdead10 = $dead10;
$troopsdead11 = $dead11;
for($i=1;$i<=50;$i++) {
@@ -1814,29 +1814,39 @@ class Automation {
$database->setVillageField($data['to'],loyalty,($toF['loyalty']-$rand));
} else {
//you took over the village
$villname = $database->getVillageField($data['to'],"name");
$artifact = $database->getOwnArtefactInfo($data['to']);
$info_chief = "".$chief_pic.",Inhabitants decided to join your empire.";
$info_chief = "".$chief_pic.",Inhabitants of ".$villname." village decided to join your empire.";
if ($artifact['vref'] == $data['to']){
$database->claimArtefact($data['to'],$data['to'],$database->getVillageField($data['from'],"owner"));
}
$database->setVillageField($data['to'],loyalty,100);
$database->setVillageField($data['to'],loyalty,0);
$database->setVillageField($data['to'],owner,$database->getVillageField($data['from'],"owner"));
//delete upgrades in armory and blacksmith
$q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref=".$data['to'];
$q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref = ".$data['to']."";
$database->query($q);
$database->addABTech($data['to']);
//delete researches in academy
$q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref=".$data['to'];
$q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref = ".$data['to']."";
$database->query($q);
$database->addTech($data['to']);
//delete reinforcement
$q = "DELETE FROM ".TB_PREFIX."enforcement WHERE from = ".$data['to'],"";
$database->query($q);
// check buildings
$pop1 = $database->getVillageField($data['from'],"pop");
$pop2 = $database->getVillageField($data['to'],"pop");
if($pop1 > $pop2){
$buildlevel = $database->getResourceLevel($data['to']);
for ($i=1; $i<=39; $i++){
if($buildlevel['f'.$i]!=0){
if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){
$leveldown = $buildlevel['f'.$i]-1;
$database->setVillageLevel($data['to'],"f".$i,$leveldown);
}else{
$database->setVillageLevel($data['to'],"f".$i,0);
$database->setVillageLevel($data['to'],"f".$i."t",0);
}
}
}
if($buildlevel['f99']!=0){
@@ -2188,6 +2198,110 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
@unlink("GameEngine/Prevention/sendunits.txt");
}
}
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");
break;
}
if($post['t11']<0)
{
$form->addError("error","You can't send negative units.");
break;
}
} else {
$post['t11']='0';
}
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
} else {
//change units
$start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1;
$end = ($database->getUserField($to['owner'],'tribe',0)*10);
$j='1';
for($i=$start;$i<=$end;$i++){
$database->modifyEnforce($post['ckey'],$i,$post['t'.$j.''],0); $j++;
}
//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){
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
$resulth = mysql_query($qh);
$hero_f=mysql_fetch_array($resulth);
$hero_unit=$hero_f['unit'];
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
} else {
$post['t11']='0';
}
} else {
$post['t11']='0';
}
$time = $generator->procDistanceTime($fromCor,$toCor,min($speeds),1);
$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,time(),($time+time()));
$technology->checkReinf($post['ckey']);
header("Location: build.php?id=39");
}
}
private function sendreinfunitsComplete() {
global $bid23,$database,$battle;
+18 -3
View File
@@ -645,13 +645,28 @@ class Building {
if($jobs['wid']==$village->wid){
$wwvillage = $database->getResourceLevel($jobs['wid']);
if($wwvillage['f99t']!=40){
$level = $database->getFieldLevel($jobs['wid'],$jobs['field']);
$level = ($level == -1) ? 0 : $level;
$level = $jobs['level'];
if($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
$finish = 1;
$resource = $this->resourceRequired($jobs['field'],$jobs['type']);
if($jobs['master'] == 0){
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
if($database->query($q)) {
}else{
$villwood = $database->getVillageField($jobs['wid'],'wood');
$villclay = $database->getVillageField($jobs['wid'],'clay');
$villiron = $database->getVillageField($jobs['wid'],'iron');
$villcrop = $database->getVillageField($jobs['wid'],'crop');
$type = $jobs['type'];
$buildarray = $GLOBALS["bid".$type];
$buildwood = $buildarray[$level]['wood'];
$buildclay = $buildarray[$level]['clay'];
$buildiron = $buildarray[$level]['iron'];
$buildcrop = $buildarray[$level]['crop'];
if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop){
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
}
}
if($database->query($q)) {
$database->modifyPop($jobs['wid'],$resource['pop'],0);
$database->addCP($jobs['wid'],$resource['cp']);
$q = "DELETE FROM ".TB_PREFIX."bdata where id = ".$jobs['id'];
+5 -1
View File
@@ -448,7 +448,8 @@ class Units {
$total = count($database->getProfileVillages($session->uid));
$need_cps = ${'cp'.$mode}[$total];
$cps = $session->cp;
$rallypoint = $database->getResourceLevel($village->wid);
if($rallypoint['f39'] > 0){
if($cps >= $need_cps) {
$unit = ($session->tribe*10);
@@ -465,6 +466,9 @@ class Units {
} else {
header("Location: build.php?id=39");
}
}else{
header("Location: dorf1.php");
}
}else{
header("Location: banned.php");
}
+7 -1
View File
@@ -195,7 +195,13 @@ $coor['y'] = "";
<div class="clear"></div>
<?php if($session->goldclub == 1){?>
<p><select name="send3"><option value="1" selected="selected">1x</option><option value="2">2x</option><option value="3">3x</option></select>go</p>
<?php } ?>
<?php
}else{
?>
<input type="hidden" name="send3" value="1">
<?php
}
?>
<p><input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" tabindex="8" alt="OK" <?php if(!$market->merchantAvail()) { echo "DISABLED"; }?>/></p></form>
<?php
$error = '';
+20 -3
View File
@@ -1,7 +1,24 @@
<?php
//reinforcement is underattack
$dataarray = explode(",",$message->readingNotice['data']);
if(isset($dataarray[14]) and $dataarray[14]!=0){$colspan="11";}else{$colspan="10";}
if(PEACE == 1){
$image = "peace";
}else if(PEACE == 2){
$image = "xmas";
}else if(PEACE == 3){
$image = "newy";
}else{
$image = "easter";
}
if(PEACE == 1){
$message1 = "".$database->getUserField($dataarray[0],"username",0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops";
}else if(PEACE == 2){
$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Merry Christmas";
}else if(PEACE == 3){
$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy New Year";
}else{
$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy Easter";
}
?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
@@ -53,8 +70,8 @@ if(isset($dataarray[14]) and $dataarray[14]!=0){
?>
</tbody>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img src="<?php echo GP_LOCATE; ?>img/r/xmas.gif" alt="Peace" title="Peace" />
<?php echo "".$database->getUserField($dataarray[0],"username",0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops" ?>
<img src="<?php echo GP_LOCATE; ?>img/r/<?php echo $image; ?>.gif" alt="Peace" title="Peace" />
<?php echo $message1; ?>
</td></tr></tbody>
</table>
</td></tr></tbody></table>
Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

+5
View File
@@ -115,6 +115,11 @@ define("TS_THRESHOLD",%TS_THRESHOLD%);
define("REG_OPEN",%REG_OPEN%);
// ***** Peace system
// 0 = None
// 1 = Normal
// 2 = Christmas
// 3 = New Year
// 4 = Easter
define("PEACE",%PEACE%);
//////////////////////////////////
+5 -2
View File
@@ -92,8 +92,11 @@ echo "<div class=\"headline\"><span class=\"f10 c5\">Error creating constant.php
</td></tr><tr></tr>
<td><span class="f9 c6">Peace system:</span></td><td>
<select name="peace">
<option value="True">True</option>
<option value="False" selected="selected">False</option>
<option value="0" selected="selected">None</option>
<option value="1">Normal</option>
<option value="2">Christmas</option>
<option value="3">New Year</option>
<option value="4">Easter</option>
</select>
</td></tr><tr></tr>
</table>