コード例 #1
0
ファイル: DecisionMaker.cs プロジェクト: UncleGus/dracula
 // done
 internal string DecideHunterToAttack(List<Hunter> huntersFighting, List<ItemDetail> combatCards, CombatRoundResult result)
 {
     Logger.WriteToDebugLog("Deciding which hunter to attack");
     string nameOfHunterToAttack = huntersFighting[new Random().Next(0, huntersFighting.Count())].Name;
     Logger.WriteToDebugLog("Returning " + nameOfHunterToAttack);
     return nameOfHunterToAttack;
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: GameState.cs プロジェクト: UncleGus/dracula
        internal string ResolveCombat(Hunter hunter, int enemyInCombat, bool hunterMoved, UserInterface ui)
        {
            List<ItemDetail> enemyCombatCards = new List<ItemDetail>();
            List<ItemDetail> hunterBasicCards = new List<ItemDetail>();
            List<Hunter> huntersInCombat = new List<Hunter>();
            if (hunterMoved)
            {
                foreach (HunterName h in hunter.HuntersInGroup)
                {
                    huntersInCombat.Add(Hunters[(int)h]);
                }
            }
            else
            {
                foreach (Hunter h in Hunters)
                {
                    if (h.CurrentLocation == Hunters[hunterIndex].CurrentLocation)
                    {
                        huntersInCombat.Add(h);
                    }
                }
            }
            hunterBasicCards.Add(new ItemDetail("Punch"));
            hunterBasicCards.Add(new ItemDetail("Escape"));
            bool trapPlayed = false;
            int rageRounds = 0;
            string enemyName = "nobody";
            switch (enemyInCombat)
            {
                case 1:
                    {
                        enemyName = "Dracula";
                        enemyCombatCards.Add(new ItemDetail("Claws"));
                        enemyCombatCards.Add(new ItemDetail("Escape (Man)"));
                        if (TimeIndex > 2)
                        {
                            enemyCombatCards.Add(new ItemDetail("Strength"));
                            enemyCombatCards.Add(new ItemDetail("Escape (Bat)"));
                            enemyCombatCards.Add(new ItemDetail("Escape (Mist)"));
                            enemyCombatCards.Add(new ItemDetail("Fangs"));
                            enemyCombatCards.Add(new ItemDetail("Mesmerize"));
                        }
                        break;
                    }
                case 2:
                    {
                        enemyName = "Minion with Knife";
                        enemyCombatCards.Add(new ItemDetail("Punch"));
                        enemyCombatCards.Add(new ItemDetail("Knife"));
                        break;
                    }
                case 3:
                    {
                        enemyName = "Minion with Knife and Pistol";
                        enemyCombatCards.Add(new ItemDetail("Punch"));
                        enemyCombatCards.Add(new ItemDetail("Knife"));
                        enemyCombatCards.Add(new ItemDetail("Pistol"));
                        break;
                    }
                case 4:
                    {
                        enemyName = "Minion with Knife and Rifle";
                        enemyCombatCards.Add(new ItemDetail("Punch"));
                        enemyCombatCards.Add(new ItemDetail("Knife"));
                        enemyCombatCards.Add(new ItemDetail("Rifle"));
                        break;
                    }
                case 5:
                    {
                        enemyName = "Assassin";
                        enemyCombatCards.Add(new ItemDetail("Punch"));
                        enemyCombatCards.Add(new ItemDetail("Knife"));
                        enemyCombatCards.Add(new ItemDetail("Pistol"));
                        enemyCombatCards.Add(new ItemDetail("Rifle"));
                        break;
                    }
                case 6:
                    {
                        enemyName = "New Vampire";
                        enemyCombatCards.Add(new ItemDetail("Claws"));
                        enemyCombatCards.Add(new ItemDetail("Escape (Man)"));
                        if (TimeIndex > 2)
                        {
                            enemyCombatCards.Add(new ItemDetail("Strength"));
                            enemyCombatCards.Add(new ItemDetail("Escape (Bat)"));
                            enemyCombatCards.Add(new ItemDetail("Escape (Mist)"));
                            enemyCombatCards.Add(new ItemDetail("Fangs"));
                            enemyCombatCards.Add(new ItemDetail("Mesmerize"));
                        }
                        break;
                    }

            }
            ui.TellUser(Hunters[hunterIndex].Name + " is entering combat against " + enemyName + (huntersInCombat.Count() > 1 ? " with " + huntersInCombat[1].Name : "") + (huntersInCombat.Count() > 2 ? " and " + huntersInCombat[2].Name : "") + (huntersInCombat.Count() > 3 ? " and " + huntersInCombat[3].Name : ""));
            EventDetail draculaEventCard = null;
            do
            {
                draculaEventCard = Dracula.PlayEventCardAtStartOfCombat(this, trapPlayed, hunterMoved, enemyInCombat);
                if (draculaEventCard != null)
                {
                    DiscardEventFromDracula(draculaEventCard.name);
                    switch (draculaEventCard.name)
                    {
                        case "Trap":
                            PlayTrap(ui);
                            int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                            if (hunterPlayingGoodluck > -1)
                            {
                                DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                            }
                            else
                            {
                                trapPlayed = true;
                                break;
                            }
                            break;
                        case "Rage":
                            PlayRage(huntersInCombat, ui);
                            int hunterPlayingGoodluckB = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                            if (hunterPlayingGoodluckB > -1)
                            {
                                DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluckB, ui);
                            }
                            else
                            {
                                rageRounds = 3;
                                try
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Man)"));
                                }
                                catch (Exception e) { }
                                try
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Bat)"));
                                }
                                catch (Exception e) { }
                                try
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Mist)"));
                                }
                                catch (Exception e) { }
                            }
                            break;

                        case "Wild Horses": PlayWildHorses(huntersInCombat, ui); return "Wild Horses";
                    }
                }
            } while (draculaEventCard != null);
            bool[] hunterPlayedCard = new bool[4] { true, true, true, true };
            int hunterPlayingCard = 0;
            while (hunterPlayedCard[0] || hunterPlayedCard[1] || hunterPlayedCard[2] || hunterPlayedCard[3])
            {
                if (ui.GetHunterPlayingCard(Hunters[hunterPlayingCard].Name))
                {
                    string cardName = "";
                    do
                    {
                        cardName = ui.GetNameOfHunterCardPlayedAtStartOfCombat(Hunters[hunterPlayingCard].Name);
                    } while (GetEventByNameFromEventDeck(cardName).name == "Unknown event" && GetItemByNameFromItemDeck(cardName).Name == "Unknown item" && cardName.ToLower() != "cancel");
                    if (cardName != "cancel")
                    {
                        hunterPlayedCard[hunterPlayingCard] = true;
                        switch (cardName)
                        {
                            case "Advance Planning":
                                DiscardEventFromHunterAtIndex(cardName, hunterPlayingCard, ui);
                                draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                                bool eventIsCancelled = false;
                                if (draculaEventCard != null)
                                {
                                    switch (draculaEventCard.name)
                                    {
                                        case "DevilishPower":
                                            ui.TellUser("Dracula played Devilish power to cancel this event");
                                            DiscardEventFromDracula("Devilish Power");
                                            int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                            if (hunterPlayingGoodluck > -1)
                                            {
                                                DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                            }
                                            else
                                            {
                                                eventIsCancelled = true;
                                            }

                                            break;
                                    }
                                }
                                if (!eventIsCancelled)
                                {
                                    PlayAdvancePlanningInCombat(ui);
                                }
                                break;
                            case "Escape Route":
                                DiscardEventFromHunterAtIndex(cardName, hunterPlayingCard, ui);
                                draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                                bool eventIsCancelledB = false;
                                if (draculaEventCard != null)
                                {
                                    switch (draculaEventCard.name)
                                    {
                                        case "DevilishPower":
                                            ui.TellUser("Dracula played Devilish power to cancel this event");
                                            DiscardEventFromDracula("Devilish Power");
                                            int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                            if (hunterPlayingGoodluck > -1)
                                            {
                                                DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                            }
                                            else
                                            {
                                                eventIsCancelledB = true;
                                            }

                                            break;
                                    }
                                }
                                if (!eventIsCancelledB)
                                {
                                    PlayEscapeRouteInCombat(hunterPlayingCard, ui);
                                    return "Escape Route";
                                }
                                break;
                            case "Heroic Leap":
                                DiscardEventFromHunterAtIndex(cardName, hunterPlayingCard, ui);
                                draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                                bool eventIsCancelledC = false;
                                if (draculaEventCard != null)
                                {
                                    switch (draculaEventCard.name)
                                    {
                                        case "DevilishPower":
                                            ui.TellUser("Dracula played Devilish power to cancel this event");
                                            DiscardEventFromDracula("Devilish Power");
                                            int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                            if (hunterPlayingGoodluck > -1)
                                            {
                                                DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                            }
                                            else
                                            {
                                                eventIsCancelledC = true;
                                            }

                                            break;
                                    }
                                }
                                if (!eventIsCancelledC)
                                {
                                    PlayHeroicLeapInCombat(hunterPlayingCard, ui);
                                }
                                break;
                            case "Garlic":
                                rageRounds = 3;
                                if (enemyCombatCards.FindIndex(card => card.Name == "Escape (Man)") > -1)
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Man)"));
                                }
                                if (enemyCombatCards.FindIndex(card => card.Name == "Escape (Bat)") > -1)
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Bat)"));
                                }
                                if (enemyCombatCards.FindIndex(card => card.Name == "Escape (Mist)") > -1)
                                {
                                    enemyCombatCards.Remove(enemyCombatCards.Find(card => card.Name == "Escape (Mist)"));
                                }
                                DiscardItemFromHunterAtIndex(cardName, hunterPlayingCard, ui);
                                break;
                        }

                    }
                }
                else
                {
                    hunterPlayedCard[hunterPlayingCard] = false;
                }
                hunterPlayingCard = (hunterPlayingCard + 1) % 4;
            }
            CombatRoundResult roundResult = new CombatRoundResult();
            roundResult = ResolveRoundOfCombat(huntersInCombat, enemyCombatCards, hunterBasicCards, roundResult, hunterMoved, enemyInCombat, ui);
            rageRounds--;
            if (rageRounds == 0)
            {
                enemyCombatCards.Add(new ItemDetail("Escape (Man)"));
                if (TimeIndex > 2)
                {
                    enemyCombatCards.Add(new ItemDetail("Escape (Bat)"));
                    enemyCombatCards.Add(new ItemDetail("Escape (Mist)"));
                }
            }
            enemyCombatCards.Add(new ItemDetail("Dodge"));
            hunterBasicCards.Add(new ItemDetail("Dodge"));

            while (roundResult.outcome != "Bite" && roundResult.outcome != "Enemy killed" && roundResult.outcome != "Hunter killed" && roundResult.outcome != "End")
            {
                if (roundResult.outcome == "Hunter wounded")
                {
                    if (ui.AskIfHunterIsUsingGreatStrengthToCancelDamage(roundResult.hunterTargeted))
                    {
                        DiscardEventFromHunterAtIndex("Great Strength", Array.FindIndex(Hunters, h => h.Name == roundResult.hunterTargeted), ui);
                        draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                        if (draculaEventCard != null)
                        {
                            switch (draculaEventCard.name)
                            {
                                case "DevilishPower":
                                    ui.TellUser("Dracula played Devilish power to cancel this event");
                                    DiscardEventFromDracula("Devilish Power");
                                    int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                    if (hunterPlayingGoodluck > -1)
                                    {
                                        DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                    }
                                    break;
                            }
                        }
                    }
                }
                roundResult = ResolveRoundOfCombat(huntersInCombat, enemyCombatCards, hunterBasicCards, roundResult, hunterMoved, enemyInCombat, ui);
            }
            foreach (Hunter h in huntersInCombat)
            {
                h.Health -= ui.GetHunterHealthLost(h.Name);
            }
            if (enemyInCombat == 1)
            {
                Dracula.Blood -= ui.GetDraculaBloodLost();
            }
            ui.TellUser("Be sure to discard any items that were destroyed/consumed in this combat");
            if (roundResult.outcome == "Bite" || roundResult.outcome == "Enemy killed" || roundResult.outcome == "Hunter killed" || roundResult.outcome == "End")
            {
                switch (roundResult.outcome)
                {
                    case "Bite":
                        ApplyBiteToHunter(Array.FindIndex(Hunters, hunt => hunt.Name == roundResult.hunterTargeted), ui);
                        HandleDraculaEscape(ui);
                        break;
                    case "End":
                        if (TimeIndex > 2)
                        {
                            HandleDraculaEscape(ui);
                        }
                        break;
                }
                return roundResult.outcome;
            }
            return ui.GetCombatRoundOutcome();
        }
コード例 #4
0
ファイル: DecisionMaker.cs プロジェクト: UncleGus/dracula
 // done
 internal ItemDetail DecideWhichCombatCardToPlay(List<Hunter> huntersFighting, Dracula dracula, List<ItemDetail> combatCards, string hunterAllyName, CombatRoundResult result)
 {
     Logger.WriteToDebugLog("Deciding which combat card to play");
     if (hunterAllyName == "Sister Agatha" && dracula.Blood < 3)
     {
         if (combatCards.FindIndex(card => card.Name == "Fangs") > -1)
         {
             combatCards.Remove(combatCards.Find(card => card.Name == "Fangs"));
         }
         if (combatCards.FindIndex(card => card.Name == "Escape (Man)") > -1)
         {
             combatCards.Remove(combatCards.Find(card => card.Name == "Fangs"));
         }
         if (combatCards.FindIndex(card => card.Name == "Escape (Bat)") > -1)
         {
             combatCards.Remove(combatCards.Find(card => card.Name == "Fangs"));
         }
         if (combatCards.FindIndex(card => card.Name == "Escape (Mist)") > -1)
         {
             combatCards.Remove(combatCards.Find(card => card.Name == "Fangs"));
         }
     }
     int chosenCardIndex;
     do
     {
         chosenCardIndex = new Random().Next(0, combatCards.Count());
     } while (combatCards[chosenCardIndex].Name == result.enemyCardUsed || (result.outcome == "Repel" && combatCards[chosenCardIndex].Name != "Dodge" && combatCards[chosenCardIndex].Name != "Escape (Man)" && combatCards[chosenCardIndex].Name != "Esacpe (Bat)" && combatCards[chosenCardIndex].Name != "Escape (Mist)"));
     Logger.WriteToDebugLog("Returning " + combatCards[chosenCardIndex].Name);
     return combatCards[chosenCardIndex];
 }
コード例 #5
0
ファイル: Dracula.cs プロジェクト: UncleGus/dracula
 internal ItemDetail ChooseCombatCardAndTarget(List<Hunter> huntersFigting, List<ItemDetail> combatCards, CombatRoundResult result, string hunterAllyName, out string name)
 {
     name = logic.DecideHunterToAttack(huntersFigting, combatCards, result);
     return logic.DecideWhichCombatCardToPlay(huntersFigting, this, combatCards, hunterAllyName, result);
 }