本文整理汇总了PHP中Weapon::getStrengthRatio方法的典型用法代码示例。如果您正苦于以下问题:PHP Weapon::getStrengthRatio方法的具体用法?PHP Weapon::getStrengthRatio怎么用?PHP Weapon::getStrengthRatio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::getStrengthRatio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pow
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);
}
示例2:
$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();
?>
示例3: floor
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'];