public function __construct(\Weapon $weapon, \Armor $armor, array $rings = [], $hp = 100) { $this->hp = $hp; $this->damage = $weapon->getDamage(); $this->cost += $weapon->getCost(); $this->armor = $armor->getArmor(); $this->cost += $armor->getCost(); foreach ($rings as $ring) { $this->damage += $ring->getDamage(); $this->armor += $ring->getArmor(); $this->cost += $ring->getCost(); } }
$cost = $toRepair * $weapon->getRepairPerPoint(); if ($user->canBuy($cost)) { $user->buy($cost); $weapon->weaponStrength += $toRepair; $user->cacheStats(); $weapon->save(); } else { $t->err = 'Not enough gold'; } } } else if ($filtered['repair-defense-max'] and $filtered['wId']) { $weapon = new Weapon(); $weapon->get($filtered['wId']); if ($weapon->userId == $user->id and $weapon->getDamage() > 0) { $toRepair = floor($user->getPrimary() / $weapon->getRepairPerPoint()); if ($toRepair > $weapon->getDamage()) { $toRepair = $weapon->getDamage(); } // repairperpoint takes weapons count into account $cost = $toRepair * $weapon->getRepairPerPoint(); if ($user->canBuy($cost)) { $user->buy($cost); $weapon->weaponStrength += $toRepair; $user->cacheStats(); $weapon->save(); } else { $t->err = 'Not enough gold';