mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-08 21:56:09 +00:00
big update (fix sitters, peace system, fix some problems of hero...)
This commit is contained in:
@@ -109,7 +109,7 @@ class Account {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$uid = $database->register($_POST['name'],md5($_POST['pw']),$_POST['email'],$_POST['vid'],$_POST['kid'],$act);
|
||||
$uid = $database->register($_POST['name'],md5($_POST['pw']),$_POST['email'],$_POST['vid'],$act);
|
||||
if($uid) {
|
||||
setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH);
|
||||
setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH);
|
||||
@@ -131,7 +131,7 @@ class Account {
|
||||
$result = mysql_query($q, $database->connection);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
if($dbarray['act'] == $_POST['id']) {
|
||||
$uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],$dbarray['location'],"");
|
||||
$uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],"");
|
||||
if($uid) {
|
||||
$database->unreg($dbarray['username']);
|
||||
$this->generateBase($dbarray['kid'],$uid,$dbarray['username']);
|
||||
@@ -188,8 +188,13 @@ class Account {
|
||||
header("Location: login.php");
|
||||
}
|
||||
else {
|
||||
$userid = $database->getUserArray($_POST['user'], 0);
|
||||
if($database->login($_POST['user'],$_POST['pw'])){
|
||||
$database->UpdateOnline("login" ,$_POST['user'],time(),$userid['id']);
|
||||
}else if($database->sitterLogin($_POST['user'],$_POST['pw'])){
|
||||
$database->UpdateOnline("sitter" ,$_POST['user'],time(),$userid['id']);
|
||||
}
|
||||
setcookie("COOKUSR",$_POST['user'],time()+COOKIE_EXPIRE,COOKIE_PATH);
|
||||
$database->UpdateOnline("login" ,$_POST['user'],time());
|
||||
$session->login($_POST['user']);
|
||||
}
|
||||
}
|
||||
|
||||
+48
-10
@@ -548,6 +548,7 @@ class Automation {
|
||||
$isoasis = $database->isVillageOases($data['to']);
|
||||
$AttackArrivalTime = $data['endtime'];
|
||||
$AttackerWref = $data['from'];
|
||||
$DefenderWref = $data['to'];
|
||||
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);
|
||||
@@ -810,7 +811,7 @@ class Automation {
|
||||
if(!isset($Defender['hero'])){
|
||||
$Defender['hero'] = '0';
|
||||
} else {
|
||||
if($Defender['hero']=='' or $Defender['hero']<='0'){
|
||||
if($Defender['hero']=='' or $Defender['hero']<'0'){
|
||||
$Defender['hero'] = '0';
|
||||
}
|
||||
}
|
||||
@@ -896,7 +897,8 @@ class Automation {
|
||||
$stonemason = "1";
|
||||
|
||||
}
|
||||
$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);
|
||||
if(PEACE == False || $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
|
||||
$unitssend_att = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
|
||||
@@ -948,8 +950,8 @@ class Automation {
|
||||
}
|
||||
$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));
|
||||
$dead['hero']+=$battlepart['deadherodef'];
|
||||
$database->modifyUnit($data['to'],array("hero"),array($battlepart['deadherodef']),array(0));
|
||||
}
|
||||
//kill other defence in village
|
||||
if(count($database->getEnforceVillage($data['to'],0)) > 0) {
|
||||
@@ -971,8 +973,8 @@ class Automation {
|
||||
$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']);
|
||||
$database->modifyEnforce($enforce['id'],"hero",$battlepart['deadheroref'][$enforce['id']],0);
|
||||
$dead['hero']+=$battlepart['deadheroref'][$enforce['id']];
|
||||
if($dead['hero']!=$enforce['hero']){
|
||||
$wrong='1';
|
||||
}
|
||||
@@ -1089,13 +1091,13 @@ class Automation {
|
||||
$heroxp = $totaldead_def;
|
||||
$database->modifyHeroXp("experience",$heroxp,$from['owner']);
|
||||
}
|
||||
$Defender1 = $database->getUnit($data['to']);
|
||||
$Defender1 = $database->getUnit($to['wref']);
|
||||
if($Defender1['hero'] > 0){
|
||||
$defheroowner = $database->getVillageField($Defender1['vref'],"owner");
|
||||
$defheroowner = $database->getVillageField($to['wref'],"owner");
|
||||
$defheroxp = $totaldead_att;
|
||||
$database->modifyHeroXp("experience",$defheroxp,$defheroowner);
|
||||
}
|
||||
$enforcementarray1 = $database->getEnforceVillage($data['to'],0);
|
||||
$enforcementarray1 = $database->getEnforceVillage($to['wref'],0);
|
||||
if(count($enforcementarray1) > 0) {
|
||||
foreach($enforcementarray1 as $enforce1) {
|
||||
if($enforce1['hero'] > 0){
|
||||
@@ -2100,6 +2102,42 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
if($type == 3 or $type == 4){
|
||||
$database->addGeneralAttack($totalattackdead);
|
||||
}
|
||||
}else{
|
||||
//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'].'';
|
||||
$herosend_att = $data['t11'];
|
||||
if ($herosend_att>0){
|
||||
$unitssend_att_check=$unitssend_att.','.$data['t11'];
|
||||
}else{
|
||||
$unitssend_att_check=$unitssend_att;
|
||||
}
|
||||
|
||||
$speeds = array();
|
||||
|
||||
//find slowest unit.
|
||||
for($i=1;$i<=10;$i++)
|
||||
{
|
||||
if ($data['t'.$i] > 0) {
|
||||
if($unitarray) { reset($unitarray); }
|
||||
$unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}
|
||||
}
|
||||
if ($herosend_att>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'];
|
||||
}
|
||||
$endtime = $this->procDistanceTime($from,$to,min($speeds),1) + time();
|
||||
$database->setMovementProc($data['moveid']);
|
||||
$database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],time(),$endtime);
|
||||
|
||||
$data2 = ''.$from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att_check.'';
|
||||
$database->addNotice($from['owner'],$to['wref'],$ownally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
|
||||
$database->addNotice($to['owner'],$to['wref'],$targetally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
|
||||
}
|
||||
unset($Attacker);
|
||||
unset($Defender);
|
||||
unset($enforce);
|
||||
@@ -2119,7 +2157,6 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
unset($data_fail);
|
||||
unset($owntribe);
|
||||
unset($unitsdead_att);
|
||||
unset($dead11);
|
||||
unset($herosend_def);
|
||||
unset($deadhero);
|
||||
unset($heroxp);
|
||||
@@ -2137,6 +2174,7 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
unset($defheroxp);
|
||||
unset($reinfheroxp);
|
||||
unset($AttackerWref);
|
||||
unset($DefenderWref);
|
||||
unset($troopsdead1);
|
||||
unset($troopsdead2);
|
||||
unset($troopsdead3);
|
||||
|
||||
@@ -154,9 +154,9 @@ class Battle {
|
||||
}
|
||||
|
||||
if(!$scout)
|
||||
return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],$post['ktyp']+3,$def_ab,$att_ab,$post['kata'],1,0,0,0);
|
||||
return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],$post['ktyp']+3,$def_ab,$att_ab,$post['kata'],1,0,0,0,0);
|
||||
else
|
||||
return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],1,$def_ab,$att_ab,$post['kata'],1,0,0,0);
|
||||
return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],1,$def_ab,$att_ab,$post['kata'],1,0,0,0,0);
|
||||
}
|
||||
|
||||
public function getTypeLevel($tid,$vid) {
|
||||
@@ -207,7 +207,7 @@ 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,$AttackerID,$DefenderID,$AttackerWref) {
|
||||
function calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref) {
|
||||
global $database,$bid34,$bid35;
|
||||
// Definieer de array met de eenheden
|
||||
$calvary = array(4,5,6,15,16,23,24,25,26,35,36,45,46);
|
||||
@@ -592,12 +592,13 @@ class Battle {
|
||||
if ($hero_health<=$damage_health or $damage_health>90)
|
||||
{
|
||||
//hero die
|
||||
$result['casualties_defender']['11'] = 1;
|
||||
$result['deadherodef'] = 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
|
||||
{
|
||||
$result['deadherodef'] = 0;
|
||||
mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
|
||||
}
|
||||
unset($_result);
|
||||
@@ -605,8 +606,8 @@ class Battle {
|
||||
unset($hero_id);
|
||||
unset($hero_health);
|
||||
unset($damage_health);
|
||||
|
||||
$DefendersAll = $database->getEnforceVillage($data['to'],0);
|
||||
|
||||
$DefendersAll = $database->getEnforceVillage($DefenderWref,0);
|
||||
if(!empty($DefendersAll)){
|
||||
foreach($DefendersAll as $defenders) {
|
||||
if($defenders['hero'] == 1) {
|
||||
@@ -622,12 +623,13 @@ class Battle {
|
||||
if ($hero_health<=$damage_health or $damage_health>90)
|
||||
{
|
||||
//hero die
|
||||
$result['casualties_defender']['11'] = 1;
|
||||
$result['deadheroref'][$defenders['id']] = 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
|
||||
{
|
||||
$result['deadheroref'][$defenders['id']] = 0;
|
||||
mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class Building {
|
||||
$this->constructBuilding($get['id'],$get['a']);
|
||||
}
|
||||
if(isset($get['buildingFinish'])) {
|
||||
if($session->gold >= 2) {
|
||||
if($session->gold >= 2 && $session->sit == 0) {
|
||||
$this->finishAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
mysql_select_db(SQL_DB, $this->connection) or die(mysql_error());
|
||||
}
|
||||
|
||||
function register($username, $password, $email, $tribe, $locate, $act) {
|
||||
function register($username, $password, $email, $tribe, $act) {
|
||||
$time = time();
|
||||
$timep = (time() + PROTECTION);
|
||||
$q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,location,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, $locate, '$act', $timep, $time, $time)";
|
||||
$q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)";
|
||||
if(mysql_query($q, $this->connection)) {
|
||||
return mysql_insert_id($this->connection);
|
||||
} else {
|
||||
@@ -203,12 +203,12 @@
|
||||
$q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED;
|
||||
$result2 = mysql_query($q2, $this->connection);
|
||||
$dbarray2 = mysql_fetch_array($result2);
|
||||
} else
|
||||
if($dbarray['sit2'] != 0) {
|
||||
}
|
||||
if($dbarray['sit2'] != 0) {
|
||||
$q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED;
|
||||
$result3 = mysql_query($q3, $this->connection);
|
||||
$dbarray3 = mysql_fetch_array($result3);
|
||||
}
|
||||
}
|
||||
if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) {
|
||||
if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) {
|
||||
return true;
|
||||
@@ -314,10 +314,20 @@
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function UpdateOnline($mode, $name = "", $time = "") {
|
||||
function GetOnline($uid) {
|
||||
$q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
return $dbarray['sit'];
|
||||
}
|
||||
|
||||
function UpdateOnline($mode, $name = "", $time = "", $uid = 0) {
|
||||
global $session;
|
||||
if($mode == "login") {
|
||||
$q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, time) VALUES ('$name', " . time() . ")";
|
||||
$q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)";
|
||||
return mysql_query($q, $this->connection);
|
||||
} else if($mode == "sitter") {
|
||||
$q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)";
|
||||
return mysql_query($q, $this->connection);
|
||||
} else {
|
||||
$q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . $session->username . "'";
|
||||
@@ -1692,7 +1702,7 @@
|
||||
}
|
||||
}
|
||||
if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) {
|
||||
if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19)) {
|
||||
if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) {
|
||||
$uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']);
|
||||
$x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0";
|
||||
mysql_query($x, $this->connection) or die(mysql_error());
|
||||
@@ -1743,6 +1753,15 @@
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function FinishWoodcutter($wid) {
|
||||
$time = time()-1;
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by timestamp ASC";
|
||||
$result = mysql_query($q);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
$q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'";
|
||||
$this->query($q);
|
||||
}
|
||||
|
||||
function getMasterJobs($wid) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
|
||||
@@ -79,7 +79,7 @@ define("NEXT_PROD","Production at level ");
|
||||
|
||||
//BUILDINGS
|
||||
define("B1","Woodcutter");
|
||||
define("B1_DESC","The Woodcutter cuts down trees in order to produce lumber. The further you extend the bid1 the more lumber is produced by him.");
|
||||
define("B1_DESC","The Woodcutter cuts down trees in order to produce lumber. The further you extend the woodcutter the more lumber is produced by him.");
|
||||
define("B2","Clay Pit");
|
||||
define("B2_DESC","Clay is produced here. By increasing its level you increase its clay production.");
|
||||
define("B3","Iron Mine");
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
$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(), $welcomemsg);
|
||||
$welcomemsg = preg_replace("'%PLAYERS%'", $database->countUser()-4, $welcomemsg);
|
||||
$welcomemsg = preg_replace("'%ALLI%'", $database->countAlli(), $welcomemsg);
|
||||
return $database->sendMessage($uid, 5, WEL_TOPIC, $welcomemsg, 0);
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ class Session {
|
||||
$this->alliance = $_SESSION['alliance_user'] = $this->userarray['alliance'];
|
||||
$this->checker = $_SESSION['checker'];
|
||||
$this->mchecker = $_SESSION['mchecker'];
|
||||
$this->sit = $database->GetOnline($this->uid);
|
||||
$this->sit1 = $this->userarray['sit1'];
|
||||
$this->sit2 = $this->userarray['sit2'];
|
||||
$this->cp = floor($this->userarray['cp']);
|
||||
|
||||
@@ -26,7 +26,7 @@ class Units {
|
||||
break;
|
||||
|
||||
case "2":
|
||||
if (isset($post['a'])&& $post['a']==533374){
|
||||
if (isset($post['a'])&& $post['a']==533374 && $post['disabledr'] == ""){
|
||||
$this->sendTroops($post);
|
||||
}else{
|
||||
$post = $this->loadUnits($post);
|
||||
@@ -39,7 +39,7 @@ class Units {
|
||||
break;
|
||||
|
||||
case "3":
|
||||
if (isset($post['a'])&& $post['a']==533374){
|
||||
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
|
||||
$this->sendTroops($post);
|
||||
}else{
|
||||
$post = $this->loadUnits($post);
|
||||
@@ -70,6 +70,12 @@ class Units {
|
||||
global $database,$village,$session,$generator,$logging,$form;
|
||||
// Busqueda por nombre de pueblo
|
||||
// Confirmamos y buscamos las coordenadas por nombre de pueblo
|
||||
if($post['disabledr'] != ""){
|
||||
$form->addError("error","You can't reinforce this village/oasis");
|
||||
}
|
||||
if($post['disabled'] != ""){
|
||||
$form->addError("error","You can't attack this village/oasis with normal attack");
|
||||
}
|
||||
if( !$post['t1'] && !$post['t2'] && !$post['t3'] && !$post['t4'] && !$post['t5'] &&
|
||||
!$post['t6'] && !$post['t7'] && !$post['t8'] && !$post['t9'] && !$post['t10'] && !$post['t11']){
|
||||
$form->addError("error","You need to mark min. one troop");
|
||||
|
||||
Reference in New Issue
Block a user