Example #1
0
	public function
	getDA() {
		global $conf;
		
		$ret = 0;

		/// TODO: add alliance stuff

		// get some stuff
		$ratio = Weapon::getStrengthRatio($this->id, 0);
		$alloc = $this->getWeaponAlloacation(false, $ratio->total);

		// apply the weapon ratios to the units with weapons
		$alloc['mercs'    ]['weapons']   *= 50 * $ratio->ratio;
		$alloc['trained'  ]['weapons']   *= 20 * $ratio->ratio;
		$alloc['untrained']['weapons']   *= 3  * $ratio->ratio;

		// apply hand-to-hand to the units without weapons
		$alloc['mercs'    ]['noweapons'] *= $this->hhlevel * 10;
		$alloc['trained'  ]['noweapons'] *= $this->hhlevel * 25;
		$alloc['untrained']['noweapons'] *= $this->hhlevel * 15;

		// and sum them.
		$sum =
			$alloc['mercs'    ]['weapons'  ] +
			$alloc['trained'  ]['weapons'  ] +
			$alloc['untrained']['weapons'  ] +
			$alloc['mercs'    ]['noweapons'] +
			$alloc['trained'  ]['noweapons'] +
			$alloc['untrained']['noweapons'];

		// apply the da level
		$ret = $sum * pow(1.25, $this->dalevel + 1);
		// apply nation bonus
		$ret *= (1 + $conf["dabonus{$this->nation}"]);

		// finally add the units
		$ret += $this->dasoldiers + $this->damercs + $this->uu;
	
		return round($ret);
	}
Example #2
0
			$weapon->weaponId = $wId;
			$weapon->isAttack = 0;
			$weapon->weaponCount = $amount;
			$weapon->weaponStrength = $conf['weapon' . $wId . 'strength'];
			if ($amount and $weapon->create()) {
				$t->daWeapons[] = $weapon;
			}
		}
		$user->cacheStats();
	}
	else {
		$t->err = 'Not enough Gold';
	}
	
	
}

$t->user = $user;

if (!$t->saWeapons and !$t->daWeapons) {
	$t->saWeapons = Weapon::getUserAttackWeapons($user->id);
	$t->daWeapons = Weapon::getUserDefenseWeapons($user->id);
}

$t->saRatio = Weapon::getStrengthRatio($user->id, 1);
$t->daRatio = Weapon::getStrengthRatio($user->id, 0);

$t->pageTitle = 'Armoury';
$t->display();
?>
Example #3
0
if ($attacklog->attackerRA > $attacklog->targetRA) {
	// Attacker has more RA, so he can damage the target's attack weapons
	$attackWeaponsRatio->ratio  *= 1.03;
	$raWeapons                   = Weapon::getUserAttackWeapons($target->id);
	$raWeaponsRatio              = Weapon::getStrengthRatio($target->id, true);
	$raDmg                       = floor($raWeaponsRatio->ratio * 0.002 * $attackTurns);
	debug("Attacker won in RA, ratio: $raWeaponsRatio->ratio");
	debug("raDmg: floor($raWeaponsRatio->ratio * 0.002 * $attackTurns) = $raDmg");
	
}
else {
	// Target has more RA, so he can damage the attacker's defense weapons
	$defenseWeaponsRatio->ratio *= 1.03;
	$raWeapons                   = Weapon::getUserDefenseWeapons($user->id);
	$raWeaponsRatio              = Weapon::getStrengthRatio($user->id, false);
	$raDmg                       = floor($raWeaponsRatio->ratio * 0.002 * $attackTurns);
	debug("Target won in RA, ratio: $raWeaponsRatio->ratio");
	debug("raDmg: floor($raWeaponsRatio->ratio * 0.002 * $attackTurns) = $raDmg");
}

debug("raweapons: " . print_r($raWeapons, true));


$attackerAlloc = $user->getWeaponAlloacation(true, $attackWeaponsRatio->total    );
$targetAlloc   = $target->getWeaponAlloacation(false, $defenseWeaponsRatio->total);

debug("alloc1: " . print_r($attackerAlloc,true));
debug("alloc2: " . print_r($targetAlloc,true));

$attacklog->satrained   = $attackerAlloc['trained'  ]['weapons'];