Example #1
0
 private function attackGroupOfThieves(Player $player)
 {
     $damage = rand(50, 150);
     if ($victory = $player->harm($damage)) {
         // The den of thieves didn't accomplish their goal
         $gold = rand(100, 300);
         if ($damage > 120) {
             // Powerful attack gives an additional disadvantage
             $player->subtractKills(1);
         }
         $player->setGold($player->gold + $gold);
         $inventory = new Inventory($player);
         $inventory->add('phosphor', 1);
     } else {
         // If the den of theives killed the attacker.
         $gold = 0;
     }
     $player->save();
     return ['npc.thief-group.tpl', ['attack' => $damage, 'gold' => $gold, 'victory' => $victory]];
 }