more big update (sorry about all of them, but i not remember exactly all fixes that i did)

This commit is contained in:
unknown
2012-05-19 12:29:56 +03:00
parent 0ef7620da6
commit 3bcc09d110
29 changed files with 1960 additions and 1221 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename gold_1.php ##
## Filename gold.php ##
## Developed by: aggenkeech ##
## License: TravianX Project ##
## Copyright: TravianX (c) 2010-2012. All rights reserved. ##
+5 -7
View File
@@ -9,6 +9,7 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
include_once("../../config.php");
include_once("../../Session.php");
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysql_select_db(SQL_DB);
@@ -24,9 +25,11 @@ for($i=1;$i<=$amt;$i++) {
$wid = $database->generateBase($kid);
$database->setFieldTaken($wid);
$time = time();
$q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','3','WW Buildingplan',0,233,232,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,1314968914)";
$pop = rand(50,233);
$cp = $pop-1;
$q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','3','WW Buildingplan',0,$pop,$cp,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,1314968914)";
mysql_query($q) or die(mysql_error());
$q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,0,0,20,10,10,22,10,25,0,0,20,15,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,0,'World Wonder')";
$q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,10,27,20,10,10,22,10,25,0,0,20,15,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,0,'World Wonder')";
mysql_query($q);
$database->addUnits($wid);
$database->addTech($wid);
@@ -34,11 +37,6 @@ for($i=1;$i<=$amt;$i++) {
$q = "UPDATE ".TB_PREFIX."units SET u41 = u41 + '150000', u42 = u42 + '150000', u43 = u43 + '150000', u44 = u44 + '150000', u45 = u45 + '150000', u46 = u46 + '150000', u47 = u47 + '150000', u48 = u48 + '150000' , u49 = u49 + '150000', u50 = u50 + '150000' WHERE vref = '".$wid."'";
mysql_query($q);
$desc = 'With this ancient construction plan you will able to build World Wonder to level 50. to build further, your alliance must hold at least two plans.';
unset($i);
unset($vname);
unset($effect);
$vname = 'Ancient Construction Plan';
$database->addArtefact($wid, 3, 11, 3, 'Ancient Construction Plan', $desc, 0, 'typeww.gif');
}
+4 -1
View File
@@ -9,6 +9,7 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
include_once("../../config.php");
include_once("../../Session.php");
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysql_select_db(SQL_DB);
@@ -24,7 +25,9 @@ for($i=1;$i<=$amt;$i++) {
$wid = $database->generateBase($kid);
$database->setFieldTaken($wid);
$time = time();
$q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`,`natar`) values ('$wid','3','WW village',0,233,232,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,$time,1)";
$pop = rand(50,233);
$cp = $pop-1;
$q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`,`natar`) values ('$wid','3','WW village',0,$pop,$cp,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,$time,1)";
mysql_query($q) or die(mysql_error());
$q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,0,'World Wonder')";
mysql_query($q);
+264 -130
View File
@@ -146,6 +146,9 @@ class Automation {
if(!file_exists("GameEngine/Prevention/training.txt") or time()-filemtime("GameEngine/Prevention/training.txt")>10) {
$this->trainingComplete();
}
if(!file_exists("GameEngine/Prevention/starvation.txt") or time()-filemtime("GameEngine/Prevention/starvation.txt")>10) {
$this->starvation();
}
if(!file_exists("GameEngine/Prevention/celebration.txt") or time()-filemtime("GameEngine/Prevention/celebration.txt")>10) {
$this->celebrationComplete();
}
@@ -167,117 +170,6 @@ class Automation {
$this->updateStore();
}
function activeCropDead(){
global $session,$village,$database,$_SESSION, $allcrop;
// var_dump($session);
// var_dump($village);
// echo"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";'
//echo $session->villages;
$this->updateRes($_SESSION['wid'],$session->uid);
$allcrop=$this->bountyproduction['crop'];
$allUnitInTown=$database->getUnit($_SESSION['wid']);
$allEnforceInTown=$database->getEnforceVillage($_SESSION['wid'],0);
$checkcrop=$database->getVillageField($_SESSION['wid'],'crop');
$cropProd=$this->bountyGetCropProd();
// $time = time();
// var_dump($session);
// echo $checkcrop;
// echo $allcrop;
if ($allcrop<0&&$checkcrop<0){
$loops=0;
while ($loops<1){
if ($checkcrop < 0){
// array_shift($allUnitInTown);
// rsort($allUnitInTown);
//rsort($allEnforceIntown);
// echo $numEnforce=count($allEnforceInTown);
if (!empty($allEnforceInTown)){
arsort($allEnforceInTown);
$unitarr=array();
foreach ($allEnforceInTown as $enforceInTown){
//var_dump($enforceInTown);
// array_shift($enforceInTown);array_pop($enforceInTown);array_pop($enforceInTown);
// array_splice($enforceInTown,count($enforceInTown)+1,2);
// $enforceInTown=rsort($enforceInTown);
for ($i=1;$i<51;$i++){
$unitarr['u'.$i]=$enforceInTown['u'.$i];
}
$unitarr['hero']=$enforceInTown['hero'];
//var_dump($enforceInTown);
if (array_sum($unitarr)>0){
arsort($unitarr);
$keydel=key($unitarr);
$keydel2=substr($keydel,1);
// echo $keydel."|||".$keydel2."|||";
global ${$keydel};
// echo ${$keydel}['crop'];
// $newtroop=$unitarr[$keydel]-1;
$database->modifyEnforce($enforceInTown['id'],$keydel2,1,0);
// $cropupdate=$checkcrop+${$keydel}['crop'];
$q = "UPDATE ".TB_PREFIX."vdata set `crop` = `crop` +".${$keydel}['crop']." WHERE wref =".$_SESSION['wid'];
$database->query($q);
// echo$q;
}else{
$database->deleteReinf($enforceInTown["id"]);
}
// var_dump($enforceInTown);
// var_dump($unitarr);
/* $allkey=array_keys($enforceInTown));
$checkar=array();
foreach ($allkey as $value){
if ($enforceInTown[$value]>0){
$checkar[]=$value;
}
}*/
}
}else{
$unitarr=array();
for ($i=1;$i<51;$i++){
$unitarr['u'.$i]=$allUnitInTown['u'.$i];
}
$unitarr['hero']=$allUnitInTown['hero'];
arsort($unitarr);
if (array_sum($unitarr)>0){
$keydel=key($unitarr);
$keydel2=substr($keydel,1);
global ${$keydel};
$database->modifyUnit($allUnitInTown['vref'],$keydel2,1,0);
$q = "UPDATE ".TB_PREFIX."vdata set `crop` = `crop`+".${$keydel}['crop']." WHERE wref =".$_SESSION['wid'];
$database->query($q);
// echo$q;
}
}
$this->updateRes($_SESSION['wid'],$session->uid);
$allcrop=$this->bountyproduction['crop'];
$allUnitInTown=$database->getUnit($_SESSION['wid']);
$allEnforceInTown=$database->getEnforceVillage($_SESSION['wid'],0);
$checkcrop=$database->getVillageField($_SESSION['wid'],'crop');
//echo $allcrop."|||".$checkcrop;
if ($allcrop>=0){
$q = "UPDATE ".TB_PREFIX."vdata set `crop` = 0 WHERE wref =".$_SESSION['wid'];
$database->query($q);
$loops++;
}elseif ($checkcrop>0){
$loops++;
}
}
}
// var_dump($allUnitInTown);
//var_dump($allEnforceIntown);
// echo $allcrop;
}
}
private function loyaltyRegeneration() {
global $database;
$array = array();
@@ -656,7 +548,8 @@ if (array_sum($unitarr)>0){
if ($isoasis == 0){
$Attacker['id'] = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
$Defender['id'] = $database->getUserField($database->getVillageField($data['to'],"owner"),"id",0);
$AttackerID = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
$DefenderID = $database->getUserField($database->getVillageField($data['to'],"owner"),"id",0);
$owntribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
$targettribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
$ownally = $database->getUserField($database->getVillageField($data['from'],"owner"),"alliance",0);
@@ -693,6 +586,7 @@ if (array_sum($unitarr)>0){
for($i=1;$i<=50;$i++) {
$Defender['u'.$i] += $enforce['u'.$i];
}
$Defender['hero'] += $enforce['hero'];
}
}
for($i=1;$i<=50;$i++){
@@ -710,6 +604,13 @@ if (array_sum($unitarr)>0){
}
}
}
if(!isset($Defender['hero'])){
$Defender['hero'] = '0';
} else {
if($Defender['hero']=='' or $Defender['hero']<='0'){
$Defender['hero'] = '0';
}
}
//get attack units
$Attacker = array();
$start = ($owntribe-1)*10+1;
@@ -864,9 +765,10 @@ if (array_sum($unitarr)>0){
}else{
$Attacker['id'] = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
$Defender['id'] = $database->getUserField($database->getOasisField($data['to'],"owner"),"id",0);
$AttackerID = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
$DefenderID = $database->getUserField($database->getOasisField($data['to'],"owner"),"id",0);
$owntribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
$targettribe = 4;
$targettribe = $database->getUserField($database->getOasisField($data['to'],"owner"),"tribe",0);;
$ownally = $database->getUserField($database->getVillageField($data['from'],"owner"),"alliance",0);
$targetally = $database->getUserField($database->getOasisField($data['to'],"owner"),"alliance",0);
$to = $database->getOMInfo($data['to']);
@@ -884,6 +786,7 @@ if (array_sum($unitarr)>0){
for($i=1;$i<=50;$i++) {
$Defender['u'.$i] += $enforce['u'.$i];
}
$Defender['hero'] += $enforce['hero'];
}
}
for($i=1;$i<=50;$i++){
@@ -901,6 +804,13 @@ if (array_sum($unitarr)>0){
}
}
}
if(!isset($Defender['hero'])){
$Defender['hero'] = '0';
} else {
if($Defender['hero']=='' or $Defender['hero']<='0'){
$Defender['hero'] = '0';
}
}
//get attack units
$Attacker = array();
$start = ($owntribe-1)*10+1;
@@ -983,7 +893,7 @@ if (array_sum($unitarr)>0){
$stonemason = "1";
}
$battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel);
$battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID);
//units attack string for battleraport
$unitssend_att = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
@@ -999,14 +909,14 @@ if (array_sum($unitarr)>0){
$unitssend_def[3] = ''.$Defender['u21'].','.$Defender['u22'].','.$Defender['u23'].','.$Defender['u24'].','.$Defender['u25'].','.$Defender['u26'].','.$Defender['u27'].','.$Defender['u28'].','.$Defender['u29'].','.$Defender['u30'].'';
$unitssend_def[4] = ''.$Defender['u31'].','.$Defender['u32'].','.$Defender['u33'].','.$Defender['u34'].','.$Defender['u35'].','.$Defender['u36'].','.$Defender['u37'].','.$Defender['u38'].','.$Defender['u39'].','.$Defender['u40'].'';
$unitssend_def[5] = ''.$Defender['u41'].','.$Defender['u42'].','.$Defender['u43'].','.$Defender['u44'].','.$Defender['u45'].','.$Defender['u46'].','.$Defender['u47'].','.$Defender['u48'].','.$Defender['u49'].','.$Defender['u50'].'';
$herosend_def = $Defender['hero'];
$totalsend_alldef[1] = $Defender['u1']+$Defender['u2']+$Defender['u3']+$Defender['u4']+$Defender['u5']+$Defender['u6']+$Defender['u7']+$Defender['u8']+$Defender['u9']+$Defender['u10'];
$totalsend_alldef[2] = $Defender['u11']+$Defender['u12']+$Defender['u13']+$Defender['u14']+$Defender['u15']+$Defender['u16']+$Defender['u17']+$Defender['u18']+$Defender['u19']+$Defender['u20'];
$totalsend_alldef[3] = $Defender['u21']+$Defender['u22']+$Defender['u23']+$Defender['u24']+$Defender['u25']+$Defender['u26']+$Defender['u27']+$Defender['u28']+$Defender['u29']+$Defender['u30'];
$totalsend_alldef[4] = $Defender['u31']+$Defender['u32']+$Defender['u33']+$Defender['u34']+$Defender['u35']+$Defender['u36']+$Defender['u37']+$Defender['u38']+$Defender['u39']+$Defender['u40'];
$totalsend_alldef[5] = $Defender['u41']+$Defender['u42']+$Defender['u43']+$Defender['u44']+$Defender['u45']+$Defender['u46']+$Defender['u47']+$Defender['u48']+$Defender['u49']+$Defender['u50'];
$totalsend_alldef = $totalsend_alldef[1]+$totalsend_alldef[2]+$totalsend_alldef[3]+$totalsend_alldef[4]+$totalsend_alldef[5];
$totalsend_alldef = $totalsend_alldef[1]+$totalsend_alldef[2]+$totalsend_alldef[3]+$totalsend_alldef[4]+$totalsend_alldef[5]+$herosend_def;
$unitssend_deff[1] = '?,?,?,?,?,?,?,?,?,?,';
$unitssend_deff[2] = '?,?,?,?,?,?,?,?,?,?,';
@@ -1014,12 +924,12 @@ if (array_sum($unitarr)>0){
$unitssend_deff[4] = '?,?,?,?,?,?,?,?,?,?,';
$unitssend_deff[5] = '?,?,?,?,?,?,?,?,?,?,';
//how many troops died? for battleraport
for($i=1;$i<=11;$i++){
if($battlepart['casualties_attacker'][$i] <= 0) { ${dead.$i} = 0; }elseif($battlepart['casualties_attacker'][$i] > $data['t'.$i]){
${dead.$i}=$data['t'.$i];
}else { ${dead.$i} = $battlepart['casualties_attacker'][$i]; }
}
$heroAttackDead=$dead11;
for($i=1;$i<=11;$i++){
if($battlepart['casualties_attacker'][$i] <= 0) { ${dead.$i} = 0; }elseif($battlepart['casualties_attacker'][$i] > $data['t'.$i]){
${dead.$i}=$data['t'.$i];
}else { ${dead.$i} = $battlepart['casualties_attacker'][$i]; }
}
$heroAttackDead=$dead11;
//kill own defence
$q = "SELECT * FROM ".TB_PREFIX."units WHERE vref='".$data['to']."'";
$unitlist = $database->query_return($q);
@@ -1033,6 +943,11 @@ ${dead.$i}=$data['t'.$i];
$database->modifyUnit($data['to'],array($i),array(round($battlepart[2]*$unitlist[0]['u'.$i])),array(0));
}
}
$dead['hero']='0';
if($unitlist){
$dead['hero']+=round($battlepart[2]*$unitlist[0]['hero']);
$database->modifyUnit($data['to'],array("hero"),array(round($battlepart[2]*$unitlist[0]['hero'])),array(0));
}
//kill other defence in village
if(count($database->getEnforceVillage($data['to'],0)) > 0) {
foreach($database->getEnforceVillage($data['to'],0) as $enforce) {
@@ -1051,6 +966,13 @@ ${dead.$i}=$data['t'.$i];
} else {
$dead[$i]='0';
}
if($enforce['hero']>'0'){
$database->modifyEnforce($enforce['id'],"hero",round($battlepart[2]*$enforce['hero']),0);
$dead['hero']+=round($battlepart[2]*$enforce['hero']);
if($dead['hero']!=$enforce['hero']){
$wrong='1';
}
}
}
$notlife= ''.$dead[$start].','.$dead[$start+1].','.$dead[$start+2].','.$dead[$start+3].','.$dead[$start+4].','.$dead[$start+5].','.$dead[$start+6].','.$dead[$start+7].','.$dead[$start+8].','.$dead[$start+9].'';
$notlife1 = $dead[$start]+$dead[$start+1]+$dead[$start+2]+$dead[$start+3]+$dead[$start+4]+$dead[$start+5]+$dead[$start+6]+$dead[$start+7]+$dead[$start+8]+$dead[$start+9];
@@ -1092,6 +1014,7 @@ ${dead.$i}=$data['t'.$i];
$unitsdead_deff[3] = '?,?,?,?,?,?,?,?,?,?,';
$unitsdead_deff[4] = '?,?,?,?,?,?,?,?,?,?,';
$unitsdead_deff[5] = '?,?,?,?,?,?,?,?,?,?,';
$deadhero = $dead['hero'];
$totaldead_alldef[1] = $dead['1']+$dead['2']+$dead['3']+$dead['4']+$dead['5']+$dead['6']+$dead['7']+$dead['8']+$dead['9']+$dead['10'];
$totaldead_alldef[2] = $dead['11']+$dead['12']+$dead['13']+$dead['14']+$dead['15']+$dead['16']+$dead['17']+$dead['18']+$dead['19']+$dead['20'];
@@ -1099,7 +1022,7 @@ ${dead.$i}=$data['t'.$i];
$totaldead_alldef[4] = $dead['31']+$dead['32']+$dead['33']+$dead['34']+$dead['35']+$dead['36']+$dead['37']+$dead['38']+$dead['39']+$dead['40'];
$totaldead_alldef[5] = $dead['41']+$dead['42']+$dead['43']+$dead['44']+$dead['45']+$dead['46']+$dead['47']+$dead['48']+$dead['49']+$dead['50'];
$totaldead_alldef = $totaldead_alldef[1]+$totaldead_alldef[2]+$totaldead_alldef[3]+$totaldead_alldef[4]+$totaldead_alldef[5];
$totaldead_alldef = $totaldead_alldef[1]+$totaldead_alldef[2]+$totaldead_alldef[3]+$totaldead_alldef[4]+$totaldead_alldef[5]+$deadhero;
/*
if($battlepart['casualties_defender'][1] == 0) { $dead11 = 0; } else { $dead11 = $battlepart['casualties_defender'][1]; }
if($battlepart['casualties_defender'][2] == 0) { $dead12 = 0; } else { $dead12 = $battlepart['casualties_defender'][2]; }
@@ -1982,10 +1905,10 @@ $crannyimg = "<img src=\"gpack/travian_default/img/g/g23.gif\" height=\"30\" wid
}
$data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.',,';
$data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.',,';
}
else{
$data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.',,';
$data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.',,';
}
@@ -2111,6 +2034,11 @@ $crannyimg = "<img src=\"gpack/travian_default/img/g/g23.gif\" height=\"30\" wid
unset($data_fail);
unset($owntribe);
unset($unitsdead_att);
unset($dead11);
unset($herosend_def);
unset($deadhero);
unset($AttackerID);
unset($DefenderID);
}
if(file_exists("GameEngine/Prevention/sendunits.txt")) {
@unlink("GameEngine/Prevention/sendunits.txt");
@@ -2834,10 +2762,6 @@ private function demolitionComplete() {
if ($hdata['experience'] > $hero_levels[$hdata['level']+1]) {
mysql_query("UPDATE " . TB_PREFIX ."hero SET level = level + 1 WHERE heroid = '".$hdata['heroid']."'");
mysql_query("UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'");
}
if($hdata['health']==0) {
mysql_query("UPDATE " . TB_PREFIX ."hero SET dead = '1' WHERE heroid = '".$hdata['heroid']."'");
mysql_query("UPDATE " . TB_PREFIX ."units SET hero = '0' WHERE vref = '".$hdata['wref']."'");
}
}
}
@@ -2965,6 +2889,216 @@ private function demolitionComplete() {
}
}
}
private function starvation() {
global $database;
$ourFileHandle = @fopen("GameEngine/Prevention/starvation.txt", 'w');
@fclose($ourFileHandle);
$starvcost = array(
'1'=>30,
'2'=>70,
'3'=>80,
'4'=>40,
'5'=>100,
'6'=>180,
'7'=>70,
'8'=>90,
'9'=>37500,
'10'=>5500,
'11'=>40,
'12'=>40,
'13'=>70,
'14'=>50,
'15'=>75,
'16'=>80,
'17'=>70,
'18'=>60,
'19'=>27200,
'20'=>6500,
'21'=>30,
'22'=>60,
'23'=>40,
'24'=>60,
'25'=>120,
'26'=>170,
'27'=>75,
'28'=>90,
'29'=>37500,
'30'=>4900,
'31'=>100,
'32'=>100,
'33'=>100,
'34'=>100,
'35'=>100,
'36'=>100,
'37'=>100,
'38'=>100,
'39'=>100,
'40'=>100,
'41'=>100,
'42'=>100,
'43'=>100,
'44'=>100,
'45'=>100,
'46'=>100,
'47'=>100,
'48'=>100,
'49'=>100,
'50'=>100
);
$starvupkeep = array(
'1'=>1,
'2'=>1,
'3'=>1,
'4'=>2,
'5'=>3,
'6'=>4,
'7'=>3,
'8'=>6,
'9'=>5,
'10'=>1,
'11'=>1,
'12'=>1,
'13'=>1,
'14'=>1,
'15'=>2,
'16'=>3,
'17'=>6,
'18'=>4,
'19'=>1,
'20'=>1,
'21'=>1,
'22'=>1,
'23'=>2,
'24'=>2,
'25'=>2,
'26'=>3,
'27'=>3,
'28'=>6,
'29'=>4,
'30'=>1,
'31'=>1,
'32'=>1,
'33'=>1,
'34'=>2,
'35'=>2,
'36'=>3,
'37'=>3,
'38'=>3,
'39'=>3,
'40'=>5,
'41'=>1,
'42'=>1,
'43'=>1,
'44'=>1,
'45'=>2,
'46'=>3,
'47'=>6,
'48'=>5,
'49'=>1,
'50'=>1
);
$time = time();
// load villages with minus prod
$starvarray = array();
$starvarray = $database->getStarvation();
foreach ($starvarray as $starv){
if (($starv['starvupdate']+60) < $time){
// get enforce
$enforcearray = $database->getEnforceVillage($starv['wref'],0);
$maxcount = 0;
if(count($enforcearray)==0){
// get units
$unitarray = $database->getUnit($starv['wref']);
for($i = 0 ; $i <= 50 ; $i++){
$units = $unitarray['u'.$i];
if($unitarray['u'.$i] > $maxcount){
$maxcount = $unitarray['u'.$i];
$maxtype = $i;
}
}
}else{
foreach ($enforcearray as $enforce){
for($i = 0 ; $i <= 50 ; $i++){
$units = $enforce['u'.$i];
if($enforce['u'.$i] > $maxcount){
$maxcount = $enforce['u'.$i];
$maxtype = $i;
$enf = $enforce['id'];
}
}
}
}
// counting
$timedif = $time-$starv['starvupdate'];
$starvsec = ($starv['starv']/3600);
$difcrop = ($timedif*$starvsec);
$newcrop = 0;
$oldcrop = $database->getVillageField($starv['wref'], 'crop');
if ($oldcrop > 100){
$difcrop = $difcrop-$oldcrop;
if($difcrop < 0){
$difcrop = 0;
$newcrop = $oldcrop-$difcrop;
}else{
$newcrop = $starvcost[$maxtype];
}
}
if($difcrop > 0){
$killunits = round(($difcrop/$starvcost[$maxtype]));
if (isset($enf)){
if($killunits < $maxcount){
$database->modifyEnforce($enf, $maxtype, $killunits, 0);
}else{
$database->deleteReinf($enf);
}
}else{
if($killunits < $maxcount){
$database->modifyUnit($starv['wref'], $maxtype, $killunits, 0);
}elseif($killunits > $maxcount){
$killunits = $maxcount;
$database->modifyUnit($starv['wref'], $maxtype, $killunits, 0);
}
}
}
$upkeep = $starv['starv']-($killunits*$starvupkeep[$maxtype]);
$time = time();
$crop = $database->getCropProdstarv($starv['wref']);
$unitarrays = $this->getAllUnits($starv['wref']);
$upkeep = $this->getUpkeep($unitarrays, 0) ;
if ($crop < $upkeep){
// add starv data
$database->setVillageField($starv['wref'], 'starv', $upkeep);
$database->setVillageField($starv['wref'], 'starvupdate', $time);
$database->setVillageField($starv['wref'], 'crop', $newcrop);
}else{
$database->setVillageField($starv['wref'], 'starv', 0);
$database->setVillageField($starv['wref'], 'starvupdate', 0);
$database->setVillageField($starv['wref'], 'crop', $newcrop);
}
}
unset ($starv);
unset ($unitarray);
unset ($enforcearray);
unset ($enforce);
unset ($starvarray);
}
if(file_exists("GameEngine/Prevention/starvation.txt")) {
@unlink("GameEngine/Prevention/starvation.txt");
}
}
}
$automation = new Automation;
+84 -23
View File
@@ -76,7 +76,8 @@ class Battle {
$h_db = 1 + 0.002 * $heroarray[0]['defencebonus'];
return array('heroid'=>$heroarray[0]['heroid'],'unit'=>$heroarray[0]['unit'],'atk'=>$h_atk,'di'=>$h_di,'dc'=>$h_dc,'ob'=>$h_ob,'db'=>$h_db,'health'=>$heroarray['health']);
}
}
private function simulate($post) {
// Establecemos los arrays con las unidades del atacante y defensor
$attacker = array('u1'=>0,'u2'=>0,'u3'=>0,'u4'=>0,'u5'=>0,'u6'=>0,'u7'=>0,'u8'=>0,'u9'=>0,'u10'=>0,'u11'=>0,'u12'=>0,'u13'=>0,'u14'=>0,'u15'=>0,'u16'=>0,'u17'=>0,'u18'=>0,'u19'=>0,'u20'=>0,'u21'=>0,'u22'=>0,'u23'=>0,'u24'=>0,'u25'=>0,'u26'=>0,'u27'=>0,'u28'=>0,'u29'=>0,'u30'=>0,'u31'=>0,'u32'=>0,'u33'=>0,'u34'=>0,'u35'=>0,'u36'=>0,'u37'=>0,'u38'=>0,'u39'=>0,'u40'=>0,'u41'=>0,'u42'=>0,'u43'=>0,'u44'=>0,'u45'=>0,'u46'=>0,'u47'=>0,'u48'=>0,'u49'=>0,'u50'=>0);
@@ -160,8 +161,8 @@ class Battle {
//1 raid 0 normal
function calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel) {
global $bid34;
function calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID) {
global $database,$bid34;
// Definieer de array met de eenheden
$calvary = array(4,5,6,15,16,23,24,25,26,35,36,45,46);
$catapult = array(8,18,28,38,48);
@@ -178,14 +179,14 @@ class Battle {
if ($Attacker['uhero'] != 0)
{
//exit($Attacker['id']);
$atkhero= $this->getBattleHero($Attacker['id']);
//exit($AttackerID);
$atkhero= $this->getBattleHero($AttackerID);
}
if ($Defender['uhero'] != 0)
if ($Defender['hero'] != 0)
{
//exit($Defender['id']);
$defhero= $this->getBattleHero($Defender['id']);
//exit($DefenderID);
$defhero= $this->getBattleHero($DefenderID);
}
// Berekenen het totaal aantal punten van Aanvaller
$start = ($att_tribe-1)*10+1;
@@ -287,7 +288,7 @@ class Battle {
}
$units['Def_unit'][$y] = $Defender['u'.$y];
}
if ($Defender['uhero'] != 0){
if ($Defender['hero'] != 0){
$dp += $defhero['di'] * 35;
$dp = $dp * $defhero['db'];
}
@@ -310,11 +311,11 @@ class Battle {
$involve += $Defender['u'.$y];
$units['Def_unit'][$y] = $Defender['u'.$y];
}
if ($Defender['uhero'] != 0)
if ($Defender['hero'] != 0)
{
$units['Def_unit']['hero'] = $Defender['uhero'];
$cdp += $Defender['uhero']*$defhero['dc'];
$dp += $Defender['uhero']*$defhero['di'];
$units['Def_unit']['hero'] = $Defender['hero'];
$cdp += $Defender['hero']*$defhero['dc'];
$dp += $Defender['hero']*$defhero['di'];
$dp = $dp * $defhero['db'];
$cdp = $cdp * $defhero['db'];
}
@@ -513,12 +514,18 @@ class Battle {
//hero die
$result['casualties_attacker']['11'] = 1;
mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'");
mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'");
}
else
{
mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
}
}
unset($_result);
unset($fdb);
unset($hero_id);
unset($hero_health);
unset($damage_health);
//exit($result['casualties_attacker']['11']);
//$result['casualties_attacker'][11] = round($result[1]*$units['Att_unit']['hero']);
@@ -533,9 +540,9 @@ class Battle {
$fdb = mysql_fetch_array($_result);
$hero_id=$fdb['heroid'];
$hero_health=$fdb['health'];
$damage_health=round(100*$result[1]);
$damage_health=round(100*$result[2]);
//exit($damage_health."|".$hero_health."|".$defhero['heroid']);
if ($hero_health<=$damage_health)
if ($hero_health<=$damage_health or $damage_health>90)
{
//hero die
$result['casualties_defender']['11'] = 1;
@@ -546,7 +553,47 @@ class Battle {
{
mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
}
unset($_result);
unset($fdb);
unset($hero_id);
unset($hero_health);
unset($damage_health);
$DefendersAll = $database->getEnforceVillage($data['to'],0);
if(!empty($DefendersAll)){
foreach($DefendersAll as $defenders) {
if($defenders['hero'] == 1) {
if(!empty($heroarray)) { reset($heroarray); }
$ReinforcerData = $database->getVillageBattleData($defenders['from']);
$heroarraydefender = $this->getBattleHero($ReinforcerData['id']);
$_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$heroarraydefender['heroid']."'");
$fdb = mysql_fetch_array($_result);
$hero_id=$fdb['heroid'];
$hero_health=$fdb['health'];
$damage_health=round(100*$result[2]);
//exit($damage_health."|".$hero_health."|".$defhero['heroid']);
if ($hero_health<=$damage_health or $damage_health>90)
{
//hero die
$result['casualties_defender']['11'] = 1;
mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'");
mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'");
}
else
{
mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
}
}
}
}
}
unset($_result);
unset($fdb);
unset($hero_id);
unset($hero_health);
unset($damage_health);
//exit($result['casualties_defender']['11']);
//$result['casualties_defender'][11] = round($result[1]*$units['Def_unit']['hero']);
@@ -658,14 +705,14 @@ class Battle {
}
if($defenders['hero'] == 1 && $data['type'] != 1) {
if(!empty($heroarray)) { reset($heroarray); }
if($defender['vref'] == $data['to']) {
$heroarray = $this->getBattleHero($DefenderData['id']);
if($defenders['vref'] == $data['to']) {
$heroarraydefender = $this->getBattleHero($DefenderData['id']);
} else {
$ReinforcerData = $database->getVillageBattleData($defenders['from']);
$heroarray = $this->getBattleHero($ReinforcerData['id']);
$heroarraydefender = $this->getBattleHero($ReinforcerData['id']);
}
$definf = ($definf + $heroarray['di']) * $heroarray['db'];
$defcav = ($defcav + $heroarray['dc']) * $heroarray['db'];
$definf = ($definf + $heroarraydefender['di']) * $heroarraydefender['db'];
$defcav = ($defcav + $heroarraydefender['dc']) * $heroarraydefender['db'];
$defense_heros++;
}
$defense_infantry += $definf;
@@ -816,9 +863,22 @@ class Battle {
$database->modifyHero('dead',1,$heroarrayAttacker['heroid'],0);
$database->modifyHero('lastupdate',time(),$heroarrayAttacker['heroid'],0);
}
if($defence_casualties < 0.9) {
if($heroarrayDefender['health']-100*$defence_casualties > 0) {
$database->modifyHero('health',(100*$defence_casualties),$heroarrayDefender['heroid'],2);
}
$DefenderUnits = $database->getUnit($data['to']);
$DefendersAll = $database->getEnforceVillage($data['to'],0);
array_unshift($DefendersAll,$DefenderUnits);
foreach($DefendersAll as $defenders) {
if($defenders['hero'] == 1 && $data['type'] != 1) {
if(!empty($heroarray)) { reset($heroarray); }
if($defenders['vref'] == $data['to']) {
$heroarraydefender = $this->getBattleHero($DefenderData['id']);
} else {
$ReinforcerData = $database->getVillageBattleData($defenders['from']);
$heroarraydefender = $this->getBattleHero($ReinforcerData['id']);
}
if($defense_casualties < 0.9) {
if($heroarrayDefender['health']-100*$defense_casualties > 0) {
$database->modifyHero('health',(100*$defense_casualties),$heroarrayDefender['heroid'],2);
$database->modifyHero('lastupdate',time(),$heroarrayDefender['heroid'],0);
} else {
$database->modifyHero('health',0,$heroarrayDefender['heroid'],0);
@@ -831,6 +891,7 @@ class Battle {
$database->modifyHero('lastupdate',time(),$heroarrayDefender['heroid'],0);
}
}
}
// send surviving attackers and hero home, report.
// calculate defensive casualties, hero damage and experience (all heroes), modify units and reinforcements, report.
// damage buildings report
+2 -10
View File
@@ -628,9 +628,7 @@ class Building {
private function finishAll() {
global $database,$session,$logging,$village,$bid18,$bid10,$bid11,$technology,$_SESSION;
if($session->access!=BANNED){
if($session->gold >= 2){
if($session->access!=BANNED){
foreach($this->buildArray as $jobs) {
if($jobs['wid']==$village->wid){
$wwvillage = $database->getResourceLevel($jobs['wid']);
@@ -639,7 +637,6 @@ class Building {
$level = ($level == -1) ? 0 : $level;
if($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
$finish = 1;
$database->updateUserField($_SESSION['username'],'gold',$gold,0);
$resource = $this->resourceRequired($jobs['field'],$jobs['type']);
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = f".$jobs['field']." + 1, f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
if($database->query($q)) {
@@ -685,16 +682,12 @@ class Building {
}
if(($jobs['field'] >= 19 && ($session->tribe == 1 || ALLOW_ALL_TRIBE)) || (!ALLOW_ALL_TRIBE && $session->tribe != 1)) { $innertimestamp = $jobs['timestamp']; }
}
if($finish == 1){
$gold=$database->getUserField($_SESSION['username'],'gold','username');
$gold-=2;
}
}
}
}
$technology->finishTech();
$logging->goldFinLog($village->wid);
$database->modifyGold($session->uid,0,0);
$database->modifyGold($session->uid,2,0);
$stillbuildingarray = $database->getJobs($village->wid);
if(count($stillbuildingarray) == 1) {
if($stillbuildingarray[0]['loopcon'] == 1) {
@@ -703,7 +696,6 @@ class Building {
}
}
header("Location: ".$session->referrer);
}
}else{
header("Location: banned.php");
}
+125 -17
View File
@@ -139,6 +139,26 @@
return $dbarray[$field];
}
function getVrefField($ref, $field){
$q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'";
$result = mysql_query($q, $this->connection) or die(mysql_error());
$dbarray = mysql_fetch_array($result);
return $dbarray[$field];
}
function getVrefCapital($ref){
$q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1";
$result = mysql_query($q, $this->connection) or die(mysql_error());
$dbarray = mysql_fetch_array($result);
return $dbarray;
}
function getStarvation(){
$q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0";
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
function getActivateField($ref, $field, $mode) {
if(!$mode) {
$q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'";
@@ -1475,8 +1495,17 @@
case 8:
$q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id";
break;
case 9:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC";
break;
case 10:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC";
break;
case 11:
$q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0";
break;
}
if($mode <= 3 || $mode == 6) {
if($mode <= 3 || $mode == 6 || $mode > 8) {
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
} else {
@@ -1531,13 +1560,7 @@
}
function getNotice($uid) {
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC";
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
function getDelNotice($uid) {
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 1 ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC";
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
@@ -1548,6 +1571,12 @@
$dbarray = mysql_fetch_array($result);
return $dbarray[$field];
}
function getNotice3($uid) {
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC";
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
function addBuilding($wid, $field, $type, $loop, $time, $master, $level) {
$x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid;
@@ -2065,6 +2094,17 @@
}
return mysql_query($q, $this->connection);
}
function modifyHeroByOwner($column,$value,$uid,$mode=0) {
if(!$mode) {
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE uid = $uid";
} elseif($mode=1) {
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE uid = $uid";
} else {
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid";
}
return mysql_query($q, $this->connection);
}
function modifyHeroXp($column,$value,$heroid) {
$q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid";
@@ -2768,19 +2808,16 @@
}
function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
$q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid";
return mysql_query($q, $this->connection);
}
function getArrayMemberVillage($uid){
$q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC';
$result = mysql_query($q, $this->connection);
$array = $this->mysql_fetch_all($result);
return $array;
}
function getArrayMemberVillage($uid){
$q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC';
$result = mysql_query($q, $this->connection);
$array = $this->mysql_fetch_all($result);
return $array;
}
function addPassword($uid, $npw, $cpw){
$q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')";
@@ -2801,6 +2838,77 @@
return false;
}
function getCropProdstarv($wref) {
global $bid4,$bid8,$bid9,$sesion,$technology;
$basecrop = $grainmill = $bakery = 0;
$owner = $this->getVrefField($wref, 'owner');
$bonus = $this->getUserField($owner, b4, 0);
$buildarray = $this->getResourceLevel($wref);
$cropholder = array();
for($i=1;$i<=38;$i++) {
if($buildarray['f'.$i.'t'] == 4) {
array_push($cropholder,'f'.$i);
}
if($buildarray['f'.$i.'t'] == 8) {
$grainmill = $buildarray['f'.$i];
}
if($buildarray['f'.$i.'t'] == 9) {
$bakery = $buildarray['f'.$i];
}
}
$q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref";
$result = mysql_query($q, $this->connection) or die(mysql_error());
$oasis = mysql_fetch_array($result);
foreach($oasis as $oa){
switch($oa['type']) {
case 1:
case 2:
$wood += 1;
break;
case 3:
$wood += 1;
$cropo += 1;
break;
case 4:
case 5:
$clay += 1;
break;
case 6:
$clay += 1;
$cropo += 1;
break;
case 7:
case 8:
$iron += 1;
break;
case 9:
$iron += 1;
$cropo += 1;
break;
case 10:
case 11:
$cropo += 1;
break;
case 12:
$cropo += 2;
break;
}
}
for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; }
$crop = $basecrop + $basecrop * 0.25 * $cropo;
if($grainmill >= 1 || $bakery >= 1) {
$crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']);
}
if($bonus > time()) {
$crop *= 1.25;
}
$crop *= SPEED;
return $crop;
}
}
;
+8 -5
View File
@@ -13,7 +13,7 @@
public $unread, $nunread = false;
public $note;
public $inbox, $sent, $reading, $reply, $archived, $noticearray, $delnoticearray, $readingNotice = array();
public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $notice, $readingNotice = array();
private $totalMessage, $totalNotice;
private $allNotice = array();
@@ -91,7 +91,7 @@
}
if (!is_array($type)) { $type = array($type); }
$this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type);
$this->delnoticearray = $this->filter_by_value($database->getDelNotice($session->uid), "ntype", $type);
$this->notice = $this->filter_by_value($database->getNotice3($session->uid), "ntype", $type);
}
if(isset($get['id'])) {
$this->readingNotice = $this->getReadNotice($get['id']);
@@ -179,9 +179,9 @@
private function getNotice() {
global $database, $session;
$this->allNotice = $database->getNotice($session->uid);
$this->noticearray = $this->filter_by_value_except($this->allNotice, "ntype", 9);
$this->delnoticearray = $this->filter_by_value_except($database->getDelNotice($session->uid), "ntype", 9);
$this->allNotice = $database->getNotice3($session->uid);
$this->noticearray = $this->filter_by_value_except($database->getNotice($session->uid), "ntype", 9);
$this->notice = $this->filter_by_value_except($this->allNotice, "ntype", 9);
$this->totalNotice = count($this->allNotice);
}
@@ -285,8 +285,11 @@
global $database, $session;
$this->inbox = $database->getMessage($session->uid, 1);
$this->sent = $database->getMessage($session->uid, 2);
$this->inbox1 = $database->getMessage($session->uid, 9);
$this->sent1 = $database->getMessage($session->uid, 10);
if($session->plus) {
$this->archived = $database->getMessage($session->uid, 6);
$this->archived1 = $database->getMessage($session->uid, 11);
}
$this->totalMessage = count($this->inbox) + count($this->sent);
}
+1 -1
View File
@@ -8,7 +8,7 @@ ob_start();
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ##
#################################################################################
if(!file_exists('GameEngine/config.php')) {header("Location: install/");}
if(!file_exists('GameEngine/config.php') && !file_exists('../../GameEngine/config.php')) {header("Location: install/");}
$script_name = ($_SERVER['REQUEST_URI'] == 'karte.php') ? 'karte' : $_SERVER['REQUEST_URI'];
include ("Battle.php");