コード例 #1
0
                 $player->increaseHitpoints(2);
                 $boss->decreaseHitpoints(2);
                 break;
             }
             unset($currentSelects[$spellIndex]);
         }
         if ($spell == '') {
             // player dies
             $player->setHitpoints(0);
             continue;
         }
         $usedSpells[] = $spell;
         $playersTurn = false;
     } else {
         if ($boss->isAlive()) {
             $boss->attack($player);
         }
         $playersTurn = true;
     }
     if (!$shield) {
         // reset armor after a depleted shield
         $player->setArmor(0);
     }
 }
 $combinations[implode(':', $usedSpells)] = true;
 if ($player->isAlive()) {
     if (!isset($leastSpent) || $spentMana < $leastSpent) {
         $leastSpent = $spentMana;
     }
     echo "Player Wins! Spent {$spentMana} mana (" . implode(', ', $usedSpells) . "), least spent so far: {$leastSpent}\n";
 }