コード例 #1
0
ファイル: GameState.cs プロジェクト: UncleGus/dracula
 private CombatRoundResult ResolveRoundOfCombat(List<Hunter> huntersFighting, List<ItemDetail> combatCards, List<ItemDetail> hunterBasicCards, CombatRoundResult result, bool hunterMoved, int enemyType, UserInterface ui)
 {
     string targetHunterName;
     string newEnemyCardUsed = Dracula.ChooseCombatCardAndTarget(huntersFighting, combatCards, result, NameOfHunterAlly(), out targetHunterName).Name;
     string newHunterCardUsed = "nothing";
     foreach (Hunter h in huntersFighting)
     {
         do
         {
             newHunterCardUsed = ui.GetCombatCardFromHunter(h.Name);
             if (GetItemByNameFromItemDeck(newHunterCardUsed).Name == "Unknown item")
             {
                 if (GetItemByNameFromList(newHunterCardUsed, hunterBasicCards).Name == "Unknown item")
                 {
                     ui.TellUser("I didn't recognise that item name");
                 }
             }
         } while (GetItemByNameFromItemDeck(newHunterCardUsed).Name == "Unknown item" && GetItemByNameFromList(newHunterCardUsed, hunterBasicCards).Name == "Unknown item");
         if (newHunterCardUsed != "Punch" && newHunterCardUsed != "Dodge" && newHunterCardUsed != "Escape")
         {
             if (h.ItemsKnownToDracula.FindIndex(it => it.Name == newHunterCardUsed) == -1)
             {
                 h.ItemsKnownToDracula.Add(GetItemByNameFromItemDeck(newHunterCardUsed));
             }
             else if (newHunterCardUsed == h.LastItemUsedInCombat)
             {
                 List<ItemDetail> copyOfHunterItemsKnown = new List<ItemDetail>();
                 copyOfHunterItemsKnown.AddRange(h.ItemsKnownToDracula);
                 copyOfHunterItemsKnown.Remove(copyOfHunterItemsKnown.Find(it => it.Name == newHunterCardUsed));
                 if (copyOfHunterItemsKnown.FindIndex(it => it.Name == newHunterCardUsed) == -1)
                 {
                     h.ItemsKnownToDracula.Add(GetItemByNameFromItemDeck(newHunterCardUsed));
                 }
             }
             h.LastItemUsedInCombat = newHunterCardUsed;
         }
     }
     ui.TellUser("Enemy chose " + newEnemyCardUsed + " against " + targetHunterName);
     if (NameOfHunterAlly() == "Sister Agatha" && enemyType == 6)
     {
         if (newEnemyCardUsed == "Fangs" || newEnemyCardUsed == "Escape (Man)" || newEnemyCardUsed == "Escape (Bat)" || newEnemyCardUsed == "Escape (Mist)")
         {
             ui.TellUser("Dracula spent two blood to play his card");
             Dracula.Blood -= 2;
         }
     }
     string newOutcome = ui.GetCombatRoundOutcome();
     CombatRoundResult newResult = new CombatRoundResult();
     newResult.enemyCardUsed = newEnemyCardUsed;
     newResult.outcome = newOutcome;
     newResult.hunterTargeted = targetHunterName;
     return newResult;
 }