$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(); ?>
$defenseWeaponsRatio = Weapon::getStrengthRatio($target->id, false); debug("defenseRatio: $defenseWeaponsRatio->ratio"); $attacklog->attackerRA = $user->RA * rand($attackLowPer, 100) * 0.01; $attacklog->targetRA = $target->RA * rand($defenseLowPer, 100) * 0.01; debug("attacker RA: $attacklog->attackerRA, <Br>targetRA: $attacklog->targetRA"); $raWeapons = array(); $raWeaponsRatio = 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"); }