Artifacts fixes part 4

Completely fixed the artifact of the fool and fixed all kind of
artifact:

+Deleted some useless .tpl files and merged into one (Stable)
+The artifact of the fool effect won't be displayed if not active
+Fixed a bug that permitted to have a great and a unique artefacts
active at the same moment
+Big reductions of code in a lot of files
+Created some new methods to support artifacts
+Fixed a bug that prevented the effect of the "Rivals confusion" to work
correctly
+Fixed a bug that prevented "The eagles eyes" artifact to work correctly
for the attacker
+Fixed the artifact of the fool of every kind, now it's calculated with
a new method
+Fixed the cranny capacity when a "Rivals confusion" artifact is active
+Some minor bug fixing , improovements and optimization
This commit is contained in:
iopietro
2018-04-26 20:37:47 +02:00
parent 42eda2f935
commit 56e280f436
32 changed files with 275 additions and 1194 deletions
+9 -49
View File
@@ -499,52 +499,12 @@ class Technology {
}
}
// $unit = "hero";
// global $$unit;
// $dataarray = $$unit;
if ( $prisoners == 0 ) {
if ( ! isset( $array['hero'] ) ) {
$array['hero'] = 0;
}
$upkeep += $array['hero'] * 6;
} else {
if ( ! isset( $array['t11'] ) ) {
$array['t11'] = 0;
}
$upkeep += $array['t11'] * 6;
}
$artefact = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 4, 3, 0 ) );
$artefact1 = count( $database->getOwnUniqueArtefactInfo2( $vid, 4, 1, 1 ) );
$artefact2 = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 4, 2, 0 ) );
if ( $artefact > 0 ) {
$upkeep /= 2;
$upkeep = round( $upkeep );
} else if ( $artefact1 > 0 ) {
$upkeep /= 2;
$upkeep = round( $upkeep );
} else if ( $artefact2 > 0 ) {
$upkeep /= 4;
$upkeep = round( $upkeep );
$upkeep *= 3;
}
$foolartefact = $database->getFoolArtefactInfo( 4, $vid, $session->uid );
if ( count( $foolartefact ) > 0 ) {
var_dump($foolartefact);
foreach ( $foolartefact as $arte ) {
if ( $arte['bad_effect'] == 1 ) {
$upkeep *= $arte['effect2'];
} else {
$upkeep /= $arte['effect2'];
$upkeep = round( $upkeep );
}
}
}
return $upkeep;
$unit = ($prisoners > 0) ? 't11' : 'hero';
if(!isset($array[$unit])) $array[$unit] = 0;
$upkeep += $array[$unit] * 6;
return $database->getArtifactsValueInfluence($session->uid, $vid, 4, $upkeep);
}
private function trainUnit($unit,$amt,$great=false) {
@@ -627,9 +587,9 @@ class Technology {
$clay = ${'u'.$unit}['clay'] * $amt * ($great?3:1);
$iron = ${'u'.$unit}['iron'] * $amt * ($great?3:1);
$crop = ${'u'.$unit}['crop'] * $amt * ($great?3:1);
$time = $each*$amt;
if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0) && $amt > 0) {
$database->trainUnit($village->wid,$unit+($great?60:0),$amt,${'u'.$unit}['pop'],$each,time()+$time,0);
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
}
}
}