mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-17 23:57:18 +00:00
Generale fixes
+Fixed a bug that didn't return reinforcements in counquered oasis, if it was released by the owner, or from the admin panel +Changed the catapults and rams formulas (still not completed at 100%), thanks to Kirilloid! +Changed the Natars' capital default coordinates
This commit is contained in:
@@ -253,7 +253,7 @@ if(isset($id)){
|
|||||||
foreach($newResult as $row){
|
foreach($newResult as $row){
|
||||||
echo "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"?action=delOas&oid=".$row['wref']."\" onClick=\"return del('oas',".$row['wref'].")\"><img src=\"../img/admin/del.gif\"></a></td>
|
<td><a href=\"?action=delOas&oid=".$row['wref']."&did=".$_GET['did']."\" onClick=\"return del('oas',".$row['wref'].")\"><img src=\"../img/admin/del.gif\"></a></td>
|
||||||
<td class=\"hab\">".$row['name']."</td>
|
<td class=\"hab\">".$row['name']."</td>
|
||||||
<td class=\"hab\"><a href=\"../karte.php?d=".$row['wref']."&c=".$generator->getMapCheck($row['wref'])."\" target=\"blank\">(".$row['x']."|".$row['y'].")</a></td>
|
<td class=\"hab\"><a href=\"../karte.php?d=".$row['wref']."&c=".$generator->getMapCheck($row['wref'])."\" target=\"blank\">(".$row['x']."|".$row['y'].")</a></td>
|
||||||
<td class=\"hab\">".round($row['loyalty'])."%</td>
|
<td class=\"hab\">".round($row['loyalty'])."%</td>
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
// # ##
|
// # ##
|
||||||
// ################################################################################
|
// ################################################################################
|
||||||
include_once("../GameEngine/Artifacts.php");
|
include_once("../GameEngine/Artifacts.php");
|
||||||
|
include_once("../GameEngine/Units.php");
|
||||||
|
include_once("../GameEngine/Generator.php");
|
||||||
|
|
||||||
class funct
|
class funct
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ class funct
|
|||||||
|
|
||||||
function Act($get)
|
function Act($get)
|
||||||
{
|
{
|
||||||
global $admin, $database;
|
global $admin, $database, $units, $generator;
|
||||||
|
|
||||||
$artifact = new Artifacts();
|
$artifact = new Artifacts();
|
||||||
|
|
||||||
@@ -71,8 +74,8 @@ class funct
|
|||||||
// add ban
|
// add ban
|
||||||
break;
|
break;
|
||||||
case "delOas":
|
case "delOas":
|
||||||
$database->query('UPDATE ' . TB_PREFIX . 'odata SET conqured = 0, owner = 2, name = "Unoccupied Oasis" WHERE wref = ' . $get['oid']);
|
$units->returnTroops($get['did'], 1);
|
||||||
// oaza
|
$database->removeOases($get['oid']);
|
||||||
break;
|
break;
|
||||||
case "logout":
|
case "logout":
|
||||||
$this->LogOut();
|
$this->LogOut();
|
||||||
|
|||||||
+10
-15
@@ -35,23 +35,18 @@ class Artifacts
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
NATARS_CAPITAL_COORDINATES = [[WORLD_MAX, WORLD_MAX],
|
NATARS_CAPITAL_COORDINATES = [[WORLD_MAX, WORLD_MAX],
|
||||||
|
[WORLD_MAX, 0],
|
||||||
[WORLD_MAX, -WORLD_MAX],
|
[WORLD_MAX, -WORLD_MAX],
|
||||||
|
[0, -WORLD_MAX],
|
||||||
[-WORLD_MAX, -WORLD_MAX],
|
[-WORLD_MAX, -WORLD_MAX],
|
||||||
[WORLD_MAX - 1, WORLD_MAX],
|
[-WORLD_MAX, 0],
|
||||||
[WORLD_MAX, WORLD_MAX - 1],
|
[-WORLD_MAX, WORLD_MAX],
|
||||||
[-WORLD_MAX, WORLD_MAX - 1],
|
[0, WORLD_MAX],
|
||||||
[WORLD_MAX - 1, -WORLD_MAX],
|
[WORLD_MAX / 10, WORLD_MAX / 20],
|
||||||
[WORLD_MAX - 1, WORLD_MAX - 1],
|
[WORLD_MAX / 10, -WORLD_MAX / 10],
|
||||||
[WORLD_MAX, -WORLD_MAX + 1],
|
[-WORLD_MAX / 20, -WORLD_MAX / 10],
|
||||||
[WORLD_MAX - 1, -WORLD_MAX + 1],
|
[-WORLD_MAX / 10, 0],
|
||||||
[-WORLD_MAX + 1, -WORLD_MAX + 1],
|
[-WORLD_MAX / 20, WORLD_MAX / 10]],
|
||||||
[WORLD_MAX - 2, WORLD_MAX],
|
|
||||||
[WORLD_MAX - 2, -WORLD_MAX],
|
|
||||||
[WORLD_MAX - 2, WORLD_MAX - 1],
|
|
||||||
[WORLD_MAX - 1, WORLD_MAX - 2],
|
|
||||||
[-WORLD_MAX + 2, WORLD_MAX],
|
|
||||||
[-WORLD_MAX + 2, WORLD_MAX - 1],
|
|
||||||
[-WORLD_MAX + 2, -WORLD_MAX + 2]],
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Normal Natars' artifacts
|
* @var array Normal Natars' artifacts
|
||||||
|
|||||||
+27
-23
@@ -711,27 +711,33 @@ class Automation {
|
|||||||
|
|
||||||
if(isset($catapultTarget))
|
if(isset($catapultTarget))
|
||||||
{
|
{
|
||||||
// currently targeted building/field level
|
//Currently targeted building/field level
|
||||||
$tblevel = (int) $bdo['f'.$catapultTarget];
|
$tblevel = (int) $bdo['f'.$catapultTarget];
|
||||||
// currently targetet building/field GID (ID of the building/field type - woodcutter, cropland, embassy...)
|
//Currently targetet building/field GID (ID of the building/field type - woodcutter, cropland, embassy...)
|
||||||
$tbgid = (int) $bdo['f'.$catapultTarget.'t'];
|
$tbgid = (int) $bdo['f'.$catapultTarget.'t'];
|
||||||
// currently targeted building/field ID in the database (fdata, the fID field, e.g. f1, f2, f3...)
|
//Currently targeted building/field ID in the database (fdata, the fID field, e.g. f1, f2, f3...)
|
||||||
$tbid = (int) $catapultTarget;
|
$tbid = (int) $catapultTarget;
|
||||||
|
|
||||||
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['catapults']['moral'],
|
//If we're targeting the WW
|
||||||
$battlepart['catapults']['upgrades'],
|
if($catapultTarget == 40){
|
||||||
$battlepart['catapults']['downgrades'],
|
$battlepart['catapults']['strongerBuildings'] = 1;
|
||||||
$tblevel,
|
$battlepart['catapults']['moraleBonus'] = 1;
|
||||||
$battlepart['catapults']['realAttackers'] / ($twoRowsCatapultSetup ? 2 : 1),
|
}
|
||||||
$data['t8'] / ($twoRowsCatapultSetup ? 2 : 1),
|
|
||||||
($catapultTarget == 40 ? 1 : $battlepart['catapults']['strongerBuildings']));
|
$catapultsDamage = $battle->calculateCatapultsDamage($data['t8'],
|
||||||
|
$battlepart['catapults']['upgrades'],
|
||||||
|
$battlepart['catapults']['durability'],
|
||||||
|
$battlepart['catapults']['attackDefenseRatio'],
|
||||||
|
$battlepart['catapults']['strongerBuildings'],
|
||||||
|
$battlepart['catapults']['moraleBonus']);
|
||||||
|
|
||||||
|
$newLevel = $battle->calculateNewBuildingLevel($tblevel, $catapultsDamage / ($twoRowsCatapultSetup ? 2 : 1));
|
||||||
|
|
||||||
//If that building was present in the building queue, we have to modify his level or remove it
|
//If that building was present in the building queue, we have to modify his level or remove it
|
||||||
$database->modifyBData($data['to'], $tbid, [$newLevel, $tblevel], $tribe);
|
$database->modifyBData($data['to'], $tbid, [$newLevel, $tblevel], $tribe);
|
||||||
|
|
||||||
// building/field destroyed
|
// building/field destroyed
|
||||||
if ($newLevel == 0)
|
if ($newLevel == 0){
|
||||||
{
|
|
||||||
// prepare data to be updated
|
// prepare data to be updated
|
||||||
$fieldsToSet = ["f".$tbid];
|
$fieldsToSet = ["f".$tbid];
|
||||||
$fieldValuesToSet = [0];
|
$fieldValuesToSet = [0];
|
||||||
@@ -1266,11 +1272,8 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//to battle.php
|
|
||||||
//fix by ronix
|
//fix by ronix
|
||||||
//MUST TO BE FIX : You need to filter these values
|
|
||||||
//filter_input_array($battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$tblevel,$stonemason,$walllevel,0,0,0,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref,$conqureby));
|
|
||||||
if (!isset($walllevel)) $walllevel = 0;
|
if (!isset($walllevel)) $walllevel = 0;
|
||||||
|
|
||||||
$battlepart = $battle->calculateBattle($Attacker, $Defender, $def_wall, $att_tribe, $def_tribe, $residence, $attpop, $defpop, $type, $def_ab, $att_ab1, $att_ab2, $att_ab3, $att_ab4, $att_ab5, $att_ab6, $att_ab7, $att_ab8, $tblevel, $stonemason, $walllevel, 0, 0, 0, $AttackerID, $DefenderID, $AttackerWref, $DefenderWref, $conqureby, $enforcementarray);
|
$battlepart = $battle->calculateBattle($Attacker, $Defender, $def_wall, $att_tribe, $def_tribe, $residence, $attpop, $defpop, $type, $def_ab, $att_ab1, $att_ab2, $att_ab3, $att_ab4, $att_ab5, $att_ab6, $att_ab7, $att_ab8, $tblevel, $stonemason, $walllevel, 0, 0, 0, $AttackerID, $DefenderID, $AttackerWref, $DefenderWref, $conqureby, $enforcementarray);
|
||||||
@@ -1286,17 +1289,18 @@ class Automation {
|
|||||||
else $can_destroy = 0;
|
else $can_destroy = 0;
|
||||||
|
|
||||||
//Catapults and rams management
|
//Catapults and rams management
|
||||||
|
//TODO: Move this in Battle.php
|
||||||
if($isoasis == 0){
|
if($isoasis == 0){
|
||||||
if ($type == 3){
|
if ($type == 3){
|
||||||
if (($data['t7'] - $traped7) > 0){
|
if (($data['t7'] - $traped7) > 0){
|
||||||
if($walllevel > 0){
|
if($walllevel > 0){
|
||||||
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['rams']['moral'],
|
$ramsDamage = $battle->calculateCatapultsDamage($data['t7'],
|
||||||
$battlepart['rams']['upgrades'],
|
$battlepart['rams']['upgrades'],
|
||||||
$battlepart['rams']['downgrades'],
|
$battlepart['rams']['durability'],
|
||||||
$walllevel,
|
$battlepart['rams']['attackDefenseRatio'],
|
||||||
$battlepart['rams']['realAttackers'],
|
$battlepart['rams']['strongerBuildings'],
|
||||||
$data['t7'],
|
$battlepart['rams']['moraleBonus']);
|
||||||
$battlepart['rams']['strongerBuildings']);
|
$newLevel = $battle->calculateNewBuildingLevel($walllevel, $ramsDamage);
|
||||||
|
|
||||||
if ($newLevel == 0){
|
if ($newLevel == 0){
|
||||||
$info_ram = "".$ram_pic.",Wall <b>destroyed</b>.";
|
$info_ram = "".$ram_pic.",Wall <b>destroyed</b>.";
|
||||||
|
|||||||
+72
-65
@@ -8,7 +8,7 @@
|
|||||||
## Filename Battle.php ##
|
## Filename Battle.php ##
|
||||||
## Developed by: Dzoki & Dixie ##
|
## Developed by: Dzoki & Dixie ##
|
||||||
## Fixed by: Shadow ##
|
## Fixed by: Shadow ##
|
||||||
## Thanks to: Akakori & Elmar ##
|
## Thanks to: Akakori, Elmar & Kirilloid ##
|
||||||
## Reworked and Fix by: ronix ##
|
## Reworked and Fix by: ronix ##
|
||||||
## Fixed by: InCube - double troops ##
|
## Fixed by: InCube - double troops ##
|
||||||
## License: TravianZ Project ##
|
## License: TravianZ Project ##
|
||||||
@@ -21,6 +21,21 @@
|
|||||||
|
|
||||||
class Battle {
|
class Battle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
|
||||||
|
* @var double The number of attacking catapults: 1 = 100%, 0 = 0%
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
private $sigma;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
|
||||||
|
$this->sigma = function($x) { return ($x > 1 ? 2 - $x ** -1.5 : $x ** 1.5) / 2; };
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function procSim($post) {
|
public function procSim($post) {
|
||||||
global $form;
|
global $form;
|
||||||
|
|
||||||
@@ -374,10 +389,10 @@ class Battle {
|
|||||||
$abcount += 1;
|
$abcount += 1;
|
||||||
|
|
||||||
// Points catapult the attacker
|
// Points catapult the attacker
|
||||||
if(in_array($i,$catapult)) $catp += (int) $Attacker['u'.$i];
|
if(in_array($i, $catapult)) $catp += (int) $Attacker['u'.$i];
|
||||||
|
|
||||||
// Points of the Rams attacker
|
// Points of the Rams attacker
|
||||||
if(in_array($i,$rams)) $ram += (int) $Attacker['u'.$i];
|
if(in_array($i, $rams)) $ram += (int) $Attacker['u'.$i];
|
||||||
|
|
||||||
$involve += (int) $Attacker['u'.$i];
|
$involve += (int) $Attacker['u'.$i];
|
||||||
$units['Att_unit'][$i] = (int) $Attacker['u'.$i];
|
$units['Att_unit'][$i] = (int) $Attacker['u'.$i];
|
||||||
@@ -459,7 +474,7 @@ class Battle {
|
|||||||
$result['Defend_points'] = $rdp;
|
$result['Defend_points'] = $rdp;
|
||||||
$winner = ($rap > $rdp);
|
$winner = ($rap > $rdp);
|
||||||
|
|
||||||
// Formula for calculating the Moral
|
// Formula for calculating the Morale bonus
|
||||||
// WW villages aren't affected by this bonus
|
// WW villages aren't affected by this bonus
|
||||||
if($attpop > $defpop && !$isWWVillage) {
|
if($attpop > $defpop && !$isWWVillage) {
|
||||||
$moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / ($rdp > 0 ? $rdp : 1)))), 3);
|
$moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / ($rdp > 0 ? $rdp : 1)))), 3);
|
||||||
@@ -533,57 +548,54 @@ class Battle {
|
|||||||
}
|
}
|
||||||
$result['hero_fealthy'] = $fealthy;
|
$result['hero_fealthy'] = $fealthy;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ram -= ($winner) ? round($ram * $result[1] / 100) : round($ram * $result[2] / 100);
|
$ram -= ($winner) ? round($ram * $result[1] / 100) : round($ram * $result[2] / 100);
|
||||||
$catp -= ($winner) ? round($catp * $result[1] / 100) : round($catp * $result[2] / 100);
|
$catp -= ($winner) ? round($catp * $result[1] / 100) : round($catp * $result[2] / 100);
|
||||||
}
|
}
|
||||||
// Formula for the calculation of catapults needed
|
|
||||||
if($catp > 0 && $tblevel != 0) {
|
if($catp > 0 && $tblevel != 0) {
|
||||||
|
|
||||||
//catapults upgrades
|
//Catapults blacksmith upgrades
|
||||||
$upgrades = round(200 * pow(1.0205, $att_ab8) ) / 200;
|
$upgrades = round(200 * pow(1.0205, $att_ab8)) / 200;
|
||||||
|
|
||||||
$wctp = pow(($rap / $rdp), 1.5);
|
//Buildings durability
|
||||||
$wctp = ($wctp >= 1) ? 1 - 0.5 / $wctp : 0.5 * $wctp;
|
$durability = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
|
||||||
$wctp *= ($catp + $upgrades);
|
|
||||||
|
//Calculates the catapults morale bonus
|
||||||
//catapults downgrades
|
$catpMoraleBonus = min(max(($attpop / ($defpop > 0 ? $defpop : 1)) ** 0.3, 1), 3);
|
||||||
$downgrades = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
|
|
||||||
|
//New level of the building (only for warsim.php)
|
||||||
//catapults moral
|
$catapultsDamage = $this->calculateCatapultsDamage($catp, $upgrades, $durability, $rap / $rdp, $strongerbuildings, $catpMoraleBonus);
|
||||||
$catpMoral = pow($attpop / ($defpop > 0 ? $defpop : 1) , 0.3);
|
$result[3] = $this->calculateNewBuildingLevel($tblevel, $catapultsDamage);
|
||||||
|
|
||||||
// New level of the building (only for warsim.php)
|
|
||||||
$result[3] = $this->calculateNewBuildingLevel($catpMoral, $upgrades, $downgrades, $tblevel, $wctp, $catp, $strongerbuildings);
|
|
||||||
$result[4] = $tblevel;
|
$result[4] = $tblevel;
|
||||||
|
|
||||||
// Results for Automation.php
|
//Results for Automation.php
|
||||||
$result['catapults']['moral'] = $catpMoral;
|
|
||||||
$result['catapults']['upgrades'] = $upgrades;
|
$result['catapults']['upgrades'] = $upgrades;
|
||||||
$result['catapults']['downgrades'] = $downgrades;
|
$result['catapults']['durability'] = $durability;
|
||||||
$result['catapults']['realAttackers'] = $wctp;
|
$result['catapults']['attackDefenseRatio'] = $rap / $rdp;
|
||||||
$result['catapults']['strongerBuildings'] = $strongerbuildings;
|
$result['catapults']['strongerBuildings'] = $strongerbuildings;
|
||||||
|
$result['catapults']['moraleBonus'] = $catpMoraleBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ram > 0 && $walllevel != 0) {
|
if($ram > 0 && $walllevel != 0) {
|
||||||
|
|
||||||
|
//Rams blacksmith upgrades
|
||||||
$upgrades = round(200 * pow(1.0205, $att_ab7)) / 200;
|
$upgrades = round(200 * pow(1.0205, $att_ab7)) / 200;
|
||||||
|
|
||||||
$wctp = pow(($rap / $rdp), 1.5);
|
|
||||||
$wctp = ($wctp >= 1) ? 1 - 0.5 / $wctp : 0.5 * $wctp;
|
|
||||||
$wctp *= ($ram) + $upgrades;
|
|
||||||
|
|
||||||
$downgrades = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
|
//Building durability
|
||||||
|
$durability = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
|
||||||
|
|
||||||
// New level of the building (only for warsim.php)
|
// New level of the building (only for warsim.php)
|
||||||
$result[7] = $this->calculateNewBuildingLevel(1, $upgrades, $downgrades, $walllevel, $wctp, $ram, $strongerbuildings * 5);
|
$ramsDamage = $this->calculateCatapultsDamage($ram, $upgrades, $durability, $rap / $rdp, $strongerbuildings, 1);
|
||||||
|
$result[7] = $this->calculateNewBuildingLevel($walllevel, $ramsDamage);
|
||||||
$result[8] = $walllevel;
|
$result[8] = $walllevel;
|
||||||
|
|
||||||
// Results for Automation.php
|
// Results for Automation.php
|
||||||
$result['rams']['moral'] = 1;
|
|
||||||
$result['rams']['upgrades'] = $upgrades;
|
$result['rams']['upgrades'] = $upgrades;
|
||||||
$result['rams']['downgrades'] = $downgrades;
|
$result['rams']['durability'] = $durability;
|
||||||
$result['rams']['realAttackers'] = $wctp;
|
$result['rams']['attackDefenseRatio'] = $rap / $rdp;
|
||||||
$result['rams']['strongerBuildings'] = $strongerbuildings * 5;
|
$result['rams']['strongerBuildings'] = $strongerbuildings;
|
||||||
|
$result['rams']['moraleBonus'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[6] = pow($rap / ($rdp * $moralbonus > 0 ? $rdp * $moralbonus : 1), $Mfactor);
|
$result[6] = pow($rap / ($rdp * $moralbonus > 0 ? $rdp * $moralbonus : 1), $Mfactor);
|
||||||
@@ -608,7 +620,7 @@ class Battle {
|
|||||||
|
|
||||||
if ($hero_health <= $damage_health || $damage_health > 90){
|
if ($hero_health <= $damage_health || $damage_health > 90){
|
||||||
//hero die
|
//hero die
|
||||||
$result['casualties_attacker']['11'] = 1;
|
$result['casualties_attacker'][11] = 1;
|
||||||
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
|
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
|
||||||
}else{
|
}else{
|
||||||
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
|
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
|
||||||
@@ -735,46 +747,41 @@ class Battle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the new building level, after catapults/rams have damaged it
|
* @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
|
||||||
*
|
*
|
||||||
* @param float $moral The catapults/rams battle moral, 1 < moral < 3 => (Total attacker points / Total defender points)^3
|
* Calculates the new building level, after damaging it
|
||||||
* @param int $upgrades Upgrades of catapults/rams made in the blacksmith
|
*
|
||||||
* @param int $downgrades Defender bonuses, such as the stonemason's lodge
|
* @param int $oldLevel The old building level
|
||||||
* @param int $actualLevel The level of the building before the battle
|
* @param float $damage The damage done by catapults
|
||||||
* @param int $realAttackers Effective catapults/rams involved in the building damage
|
* @return int Returns the new building level
|
||||||
* @param int $totalAttackers Total catapults/rams sent in the attack
|
|
||||||
* @param int $strongerBuildings Indicates the defender artifacts bonus against catapults
|
|
||||||
* @return int Returns the new level of the damaged building
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function CalculateNewBuildingLevel($moral, $upgrades, $downgrades, $actualLevel, $realAttackers, $totalAttackers, $strongerBuildings)
|
public function calculateNewBuildingLevel($oldLevel, $damage){
|
||||||
{
|
$damage -= 0.5;
|
||||||
if($moral < 1) $moral = 1;
|
if ($damage < 0) return $oldLevel;
|
||||||
elseif($moral > 3) $moral = 3;
|
|
||||||
|
while ($damage >= $oldLevel && $oldLevel) $damage -= $oldLevel--;
|
||||||
$needMax = round($this->CalculateNeededCatapults($moral, $upgrades / ($downgrades * $strongerBuildings), $actualLevel));
|
|
||||||
if($needMax <= $realAttackers) return 0;
|
return $oldLevel;
|
||||||
for($i = $actualLevel - 1; $i >= 1; $i--)
|
|
||||||
{
|
|
||||||
$need = $this->CalculateNeededCatapults($moral, $upgrades / ($downgrades * $strongerBuildings), $i);
|
|
||||||
if(min($realAttackers, $totalAttackers) / ($needMax - $need) <= 1) return ++$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $actualLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the needed catapults/rams to completely destroy a building/wall
|
* @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
|
||||||
*
|
*
|
||||||
* @param float $moral The catapults/rams battle moral
|
* Calculates the damage done by catapults
|
||||||
* @param int $upDown (Upgrades / Downgrades / Stronger buildings) ratio of catapults/rams
|
*
|
||||||
* @param int $actualLevel The level of the building before the battle
|
* @param int $catapultsQuantity The quantity of catapults which take part in the attack
|
||||||
* @return float Returns the needed catapults/rams to destroy a building/wall
|
* @param double $catapultsUpgrade The catapults upgrade multiplier, affected by the cataputls level in the blacksmith
|
||||||
|
* @param double $durability The building durability, affected by the stonemason's lodge
|
||||||
|
* @param double $ADRatio The attack points / defensive points ratio
|
||||||
|
* @param double $strongerBuildings The artifacts multiplier, which strengthens the building, affected by durability artifacts
|
||||||
|
* @param double $moraleBonus The defender morale bonus
|
||||||
|
* @return double Returns the damage done by catapults
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function CalculateNeededCatapults($moral, $upDown, $actualLevel)
|
public function calculateCatapultsDamage($catapultsQuantity, $catapultsUpgrade, $durability, $ADRatio, $strongerBuildings, $moraleBonus){
|
||||||
{
|
$catapultsEfficiency = floor($catapultsQuantity / ($durability * $strongerBuildings));
|
||||||
return ($moral * (pow($actualLevel, 2) + $actualLevel + 1) / ($upDown == 0 ? 1 : 8 * $upDown)) + 0.5;
|
return 4 * ($this->sigma)($ADRatio) * $catapultsEfficiency * $catapultsUpgrade / $moraleBonus;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -855,7 +855,9 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
if(!is_array($coordinatesArray[0])) $coordinatesArray = [$coordinatesArray];
|
if(!is_array($coordinatesArray[0])) $coordinatesArray = [$coordinatesArray];
|
||||||
|
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
foreach($coordinatesArray as $coordinate) $conditions[] = "(x = ".$coordinate[0]." AND y = ".$coordinate[1].")";
|
foreach($coordinatesArray as $coordinate){
|
||||||
|
$conditions[] = "(x = ".round($coordinate[0])." AND y = ".round($coordinate[1]).")";
|
||||||
|
}
|
||||||
|
|
||||||
$q = "SELECT id FROM " . TB_PREFIX . "wdata WHERE ".implode(" OR ", $conditions);
|
$q = "SELECT id FROM " . TB_PREFIX . "wdata WHERE ".implode(" OR ", $conditions);
|
||||||
$result = mysqli_query($this->dblink, $q);
|
$result = mysqli_query($this->dblink, $q);
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ class Units {
|
|||||||
|
|
||||||
$to = $database->getVillage($enforce['from']);
|
$to = $database->getVillage($enforce['from']);
|
||||||
$tribe = $database->getUserField($to['owner'], 'tribe', 0);
|
$tribe = $database->getUserField($to['owner'], 'tribe', 0);
|
||||||
|
$start = ($tribe - 1) * 10 + 1;
|
||||||
|
|
||||||
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $enforce, 1);
|
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $enforce, 1);
|
||||||
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
|
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
$oasisarray = $database->getOasis($village->wid);
|
$oasisarray = $database->getOasis($village->wid);
|
||||||
if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid){
|
if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid){
|
||||||
$database->removeOases($_GET['del']);
|
$units->returnTroops($village->wid, 1);
|
||||||
|
$database->removeOases($_GET['del']);
|
||||||
header("Location: build.php?id=".$id."&land");
|
header("Location: build.php?id=".$id."&land");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@ if(isset($_POST['result'])) {
|
|||||||
include("Templates/Simulator/res_d".$tar.".tpl");
|
include("Templates/Simulator/res_d".$tar.".tpl");
|
||||||
}
|
}
|
||||||
echo "<p>Type of attack: <b>";
|
echo "<p>Type of attack: <b>";
|
||||||
echo $form->getValue('ktyp') == 0? "Normal" : "Raid";
|
echo $form->getValue('ktyp') == 0 ? "Normal" : "Raid";
|
||||||
echo "</b></p>";
|
echo "</b></p>";
|
||||||
echo "<p>";
|
echo "<p>";
|
||||||
if (isset($_POST['result'][7]) && isset($_POST['result'][8])){
|
if (isset($_POST['result'][7]) && isset($_POST['result'][8])){
|
||||||
|
|||||||
Reference in New Issue
Block a user