Exemple #1
0
    public void DiscardCardAddition()
    {
        if (selectedCard != null)
        {
            //all ally cards activated are added to the board and active allies
            if (selectedCard.type == "Ally Card")
            {
                //ally cards always get added to active allies
                AllyCard ally = (AllyCard)selectedCard;
                players[currentPlayerIndex].activeAllies.Add(ally);
                players[currentPlayerIndex].hand.Remove(selectedCard);
                UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), playerAllyPanels[currentPlayerIndex]);
            }
            else
            {
                bool removed = userInput.CheckDiscardCard(selectedCard);
                if (removed)
                {
                    //add card back to player
                    players[currentPlayerIndex].hand.Add(selectedCard);
                    UIUtil.PopulatePlayerBoard(this);
                }
                else
                {
                    //add it into the panel
                    players[currentPlayerIndex].hand.Remove(selectedCard);

                    //Debug.Log(selectedCard.name);
                    userInput.AddToUIDiscardPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab));
                }
            }

            selectedCard = null;
        }
    }
Exemple #2
0
    // high stakes Tournament returns the strongest possible play the CPU can make
    public List <Card> highStakesTournament(List <Card> hand, List <Player> players)
    {
        strategyUtil strat       = new strategyUtil();
        List <Card>  cardsToPlay = new List <Card>();

        // loop through the hand
        for (int i = 0; i < hand.Count; i++)
        {
            // play the amour card if we haven't already
            if (hand[i].type == "Amour Card" && strat.checkDuplicate(hand[i], cardsToPlay, "Amour Card"))
            {
                cardsToPlay.Add(hand[i]);
                hand.Remove(hand[i]);
            }
            // play the weapon card if we haven't already played a weapon of that type
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], cardsToPlay, "Weapon Card"))
            {
                cardsToPlay.Add(hand[i]);
                hand.Remove(hand[i]);
            }
            // play any ally card with BP
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints("", players) > 0)
                {
                    cardsToPlay.Add(hand[i]);
                    hand.Remove(hand[i]);
                }
            }
        }
        // return all the eligible cards to play
        return(cardsToPlay);
    }
Exemple #3
0
    public List <Card> playFinalFoe(List <Card> hand, bool amour)
    {
        strategyUtil strat        = new strategyUtil();
        List <Card>  foeEncounter = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], foeEncounter, "Weapon Card"))
            {
                foeEncounter.Add(hand[i]);
            }
            if (hand[i].type == "Ally Card")
            { // && hand[i].battlePoints > 0){
                AllyCard ally = (AllyCard)hand[i];
                if (ally.battlePoints > 0)
                {
                    foeEncounter.Add(hand[i]);
                }
            }
            if (hand[i].type == "Amour Card" && (amour == false))
            {
                foeEncounter.Add(hand[i]);
                amour = true;
            }
        }
        return(foeEncounter);
    }
    // Get power from card.
    public int getPowerFromCard(Card c)
    {
        if (c.GetType() == typeof(WeaponCard))
        {
            WeaponCard currWeapon = (WeaponCard)c;
            return(currWeapon.power);
        }

        if (c.GetType() == typeof(AmourCard))
        {
            AmourCard currAmour = (AmourCard)c;
            return(currAmour.power);
        }

        if (c.GetType() == typeof(AllyCard))
        {
            AllyCard currAlly = (AllyCard)c;

            int currAllyPower = currAlly.power;

            //Quest Condition
            if (_storyCard.GetType() == typeof(QuestCard))
            {
                QuestCard currQuest = (QuestCard)_storyCard;
                //Same Quest
                if (currAlly.questCondition == currQuest.name)
                {
                    currAllyPower += currAlly.bonusPower;
                }
            }

            //Ally Condition
            if (currAlly.allyCondition != null)
            {
                //Go Through The Players
                for (int x = 0; x < _players.Count; x++)
                {
                    List <Card> currInPlay = _players[x].inPlay;
                    for (int i = 0; i < currInPlay.Count; i++)
                    {
                        //If ally card
                        if (currInPlay[i].GetType() == typeof(AllyCard))
                        {
                            AllyCard compareAlly = (AllyCard)currInPlay[i];
                            if (currAlly.allyCondition == compareAlly.name)
                            {
                                currAllyPower += currAlly.bonusPower;
                                return(currAllyPower);
                            }
                        }
                    }
                }
            }
            return(currAllyPower);
        }

        return(0);
    }
Exemple #5
0
    void Awake()
    {
        InstantiateCards();

        m_lita = Instantiate(m_lita.gameObject).GetComponent <AllyCard>();
        m_lita.m_isPlayerDeck = false;

        m_ghoulPriest = Instantiate(m_ghoulPriest.gameObject).GetComponent <EnemyCard>();

        GameLogic.Get().m_currentScenario = this;
    }
    public void getFreeBid_returnsBidPoints_Adds_allyEffectBuffOnCardInPlay()
    {
        List <Player> players = new List <Player>();
        var           ally1   = new AllyCard("Ally Card", "Ayrton", "", 5, 5, "Special", "", "ally", 1, 1, new BuffOnCardInPlayEffect());
        var           ally2   = new AllyCard("Ally Card", "ally", "", 0, 0, "Special", "quest", "ally", 0, 0, new NoBuff());
        Player        player1 = new Player("ahmed", new List <Card>(), new iStrategyPlayer());

        players.Add(player1);
        player1.activeAllies.Add(ally2);

        Assert.AreEqual(6, ally1.getFreeBid("other quest", players));
    }
    protected List <AllyCard> extractAllies(List <Card> hand)
    {
        List <AllyCard> allyCards = new List <AllyCard>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand [i] is AllyCard)
            {
                AllyCard currAlly = (AllyCard)hand [i];
                allyCards.Add(currAlly);
            }
        }
        return(allyCards);
    }
Exemple #8
0
    public void CardAdditionCheck()
    {
        if (selectedCard != null)
        {
            //all ally cards activated are added to the board and active allies
            if (selectedCard.type == "Ally Card")
            {
                //ally cards always get added to active allies
                AllyCard ally = (AllyCard)selectedCard;
                players[currentPlayerIndex].activeAllies.Add(ally);
                players[currentPlayerIndex].hand.Remove(selectedCard);
                UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), playerAllyPanels[currentPlayerIndex]);
            }
            else
            {
                //check cards for removal from card panel
                bool removedCard = userInput.CheckCard(selectedCard);

                if (removedCard)
                {
                    //removed card from panel So add it back to hand
                    players[currentPlayerIndex].hand.Add(selectedCard);
                    UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), handPanel);
                }
                else
                {
                    bool addToPanel = true;

                    //CLUSTERFUCK
                    addToPanel = EventCheck(QuestCheck(TournamentCheck()));

                    //result
                    if (addToPanel)
                    {
                        //add it into the panel
                        players[currentPlayerIndex].hand.Remove(selectedCard);
                        userInput.AddToUICardPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab));
                    }
                    else
                    {
                        //return it to hand since we didn't delete it from player we are fine
                        UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), handPanel);
                    }
                }
            }

            //maybe we can check for certain cards like mordred here with some state
            selectedCard = null;
        }
    }
Exemple #9
0
    public List <Card> courtCalled()
    {
        List <Card> allies = new List <Card>();

        for (var i = 0; i < activeAllies.Count; i++)
        {
            allies.Add(activeAllies[i]);
        }
        for (var i = 0; i < allies.Count; i++)
        {
            AllyCard ally = (AllyCard)allies[i];
            activeAllies.Remove(ally);
        }

        return(allies);
    }
Exemple #10
0
    public void AllyCard_CreatedWithGiven_WillHaveTheVariables()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", " ", 10, 2, "Special", "Quest", "Ally", 0, 0, new NoBuff());

        ally.display();
        Assert.AreEqual("Ally Card", ally.type);
        Assert.AreEqual("Ayrton", ally.name);
        Assert.AreEqual(" ", ally.texturePath);
        Assert.AreEqual(10, ally.battlePoints);
        Assert.AreEqual("Special", ally.special);
        Assert.AreEqual(2, ally.freeBid);
        Assert.AreEqual("Special", ally.special);
        Assert.AreEqual("Quest", ally.specialQuest);
        Assert.AreEqual("Ally", ally.specialAlly);
        Assert.AreEqual(0, ally.bidBuff);
        Assert.AreEqual(0, ally.bpBuff);
        // Use the Assert class to test conditions.
    }
Exemple #11
0
 // Sorts allies by ASCENDING order of BP
 public List <Card> sortAlliesByAscendingOrder(List <Card> allies, string questName, List <Player> players)
 {
     for (int x = 0; x < allies.Count; x++)
     {
         for (int i = 0; i < (allies.Count - 1); i++)
         {
             AllyCard ally1 = (AllyCard)allies[i];
             AllyCard ally2 = (AllyCard)allies[i + 1];
             if (ally1.getBattlePoints(questName, players) > ally2.getBattlePoints(questName, players))
             {
                 var temp = allies[i + 1];
                 allies[i + 1] = allies[i];
                 allies[i]     = temp;
             }
         }
     }
     return(allies);
 }
Exemple #12
0
 // gets the BP of a single 'valid' card
 public int getValidCardBP(Card card, List <Player> players, string questName)
 {
     if (card.type == "Ally Card")
     {
         AllyCard ally = (AllyCard)card;
         return(ally.getBattlePoints(questName, players));
     }
     if (card.type == "Weapon Card")
     {
         WeaponCard weapon = (WeaponCard)card;
         return(weapon.battlePoints);
     }
     else
     {
         // amour
         return(10);
     }
 }
    private IEnumerator _OnConfirmAssignDamageCoroutine(int index)
    {
        var ui = GameLogic.Get().m_mainGameUI;

        ui.m_targetDropdown.onValueChanged.RemoveListener(Player.Get().m_onAssignDamage);

        AllyCard ally = Player.Get().GetAssetCardInSlot(AssetSlot.Ally) as AllyCard;

        UnityEngine.Assertions.Assert.IsNotNull(ally, "Assert failed in Player.OnConfirmAssignDamage()!!!");

        int allyDamage         = index - 1;
        int investigatorDamage = Player.Get().m_assignDamage - allyDamage;

        if (Player.Get().GetCurrentAction() == PlayerAction.AssignDamage)
        {
            ally.m_health -= allyDamage;
            Player.Get().LoseHealth(investigatorDamage);

            if (Player.Get().m_attacker)
            {
                GameLogic.Get().m_afterAssignDamageEvent.Invoke(Player.Get().m_attacker, investigatorDamage, allyDamage);

                yield return(new WaitUntil(() => GameLogic.Get().m_currentTiming == EventTiming.None));
            }
        }
        else
        {
            ally.m_sanity -= allyDamage;
            Player.Get().LoseSanity(investigatorDamage);
        }

        if (ally.m_health <= 0 || ally.m_sanity <= 0)
        {
            ally.Discard();

            GameLogic.Get().OutputGameLog(string.Format("{0}的盟友<{1}>被打死了!\n", Player.Get().m_investigatorCard.m_cardName, ally.m_cardName));
        }

        ui.m_targetDropdown.gameObject.SetActive(false);
        ui.m_actionDropdown.gameObject.SetActive(GameLogic.Get().m_currentPhase == TurnPhase.InvestigationPhase);
        Player.Get().m_currentAction.Pop();
    }
Exemple #14
0
    public bool canIPlay(int stages, List <Card> hand)
    {
        int count = (2 * stages);

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card")
            {
                count -= 1;
            }
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.battlePoints > 0)
                {
                    count -= 1;
                }
            }
        }
        return(count <= 0);
    }
Exemple #15
0
    //NEEDS CHANGESSSSSSSSSSSS!!!!!!!!!!!!!!
    public void CalculateTotalBP()
    {
        int total = 0;

        strategyUtil util = new strategyUtil();

        for (int i = 0; i < selectedCards.Count; i++)
        {
            if (selectedCards[i].type == "Foe Card")
            {
                FoeCard foe = (FoeCard)selectedCards[i];

                if (QuestState.currentQuest != null)
                {
                    total += util.getContextBP(foe, QuestState.currentQuest.foe);
                }
                else
                {
                    total += foe.minBP;
                }
            }
            else if (selectedCards[i].type == "Weapon Card")
            {
                WeaponCard weapon = (WeaponCard)selectedCards[i];
                total += weapon.battlePoints;
            }
            else if (selectedCards[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)selectedCards[i];
                total += ally.battlePoints;
            }
            else if (selectedCards[i].type == "Amour Card")
            {
                AmourCard amour = (AmourCard)selectedCards[i];
                total += amour.battlePoints;
            }
        }

        totalBP.text = "BP: " + total.ToString();
    }
Exemple #16
0
    public void getBattlePoints_returnsBattlePointsif_bpBuffisZero()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", "", 5, 5, "Special", "quest", "ally", 0, 0, new NoBuff());

        Assert.AreEqual(ally.battlePoints, ally.getBattlePoints("quest", new List <Player>()));
    }
Exemple #17
0
    public void AllyCard_CreatedWithoutSpecial_ReturnsFalse()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", " ", 10, 0, "", "Quest", "Ally", 0, 0, new NoBuff());

        Assert.IsFalse(ally.hasSpecial());
    }
Exemple #18
0
    public void AllyCard_CreatedWithAllyEffect_ReturnsTrue()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", " ", 10, 0, "Special", "Quest", "Ally", 0, 0, new NoBuff());

        Assert.IsNotNull(ally.allyEffect);
    }
Exemple #19
0
    public bool canIIncrement(int stages, List <Card> hand, List <Player> players, QuestCard card)
    {
        strategyUtil strat            = new strategyUtil();
        int          firstStageToFill = 1;
        bool         hasAmour         = false;
        int          prev             = 0;

        List <Card> allies  = new List <Card>();
        List <Card> weapons = new List <Card>();

        // Seperately fill lists with our weapons and allies
        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card")
            {
                weapons.Add(hand[i]);
            }
            // If we have an Amour Card, it will immediately be played meaning we start filling stages from round 2 (bc round 1 will be 10BP)
            if (hand[i].type == "Amour Card" && (hasAmour == false))
            {
                hasAmour         = true;
                firstStageToFill = 2;
                prev             = 10;
            }
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints(card.name, players) > 0)
                {
                    allies.Add(hand[i]);
                }
            }
        }
        // sort them by ascending order
        allies  = strat.sortAlliesByAscendingOrder(allies, card.name, players);
        weapons = strat.sortWeaponsByAscendingOrder(weapons);

        // Now we walk through each stage of the quest
        for (int i = firstStageToFill; i <= stages; i++)
        {
            // instantiate a list of unique weapon to ensure each stage doesn't have duplicate weapons
            List <Card> uniqueWeapons = new List <Card>();
            // set our threshold for how many BP this stage needs (incremented by 10)
            int pointThreshold = (10 + prev);
            // our current points for this stage
            int points = 0;
            // while we still have allies to play and we have yet to hit our point threshold
            while (allies.Count > 0 && (points < pointThreshold))
            {
                // play our allies and increment points to include their battlePoints
                AllyCard ally = (AllyCard)allies[0];
                points += ally.getBattlePoints(card.name, players);
                allies.Remove(allies[0]);
            }
            // if we run out of allies, we can loop through weapons and make sure that were not gonna play a duplicate weapon
            while (weapons.Count > 0 && (points < pointThreshold) && strat.checkDuplicate(weapons[0], uniqueWeapons, "Weapon Card"))
            {
                WeaponCard weapon = (WeaponCard)weapons[0];
                points += weapon.battlePoints;
                weapons.Remove(weapons[0]);
            }
            // if we've run out of allies AND weapons but haven't filled in this current stage yet then return false
            if (points < pointThreshold)
            {
                return(false);
            }
            // set prev to whatever our points ended up as
            prev = points;
        }
        // return true if weve made it through all stages
        return(true);
    }
Exemple #20
0
        // assuming battleCards is sorted, starting from weakest
        private List <BattleCard>[] bestCardsToPlayInQuest(QuestCard questCard, Hand hand)
        {
            List <BattleCard>[] stages = new List <BattleCard> [questCard.StageCount];

            List <Amour>      amours  = new List <Amour>(hand.GetDistinctCards <Amour>());
            List <AllyCard>   allies  = new List <AllyCard>(hand.GetCards <AllyCard>());
            List <WeaponCard> weapons = new List <WeaponCard>(hand.GetCards <WeaponCard>());

            allies.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints));
            weapons.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints));

            for (int i = 0; i < questCard.StageCount; i++)
            {
                stages[i] = new List <BattleCard>();
            }

            BattleArea lastCards = new BattleArea();
            BattleArea currCards;

            for (int i = 0; i < questCard.StageCount; i++)
            {
                currCards = new BattleArea();

                BattleArea weaponArea = new BattleArea();
                weapons.ForEach(x => weaponArea.Add(x));
                List <WeaponCard> playableWeapons = weaponArea.GetDistinctCards <WeaponCard>();

                while (currCards.BattlePoints() < lastCards.BattlePoints() + 10 && amours.Count + allies.Count + playableWeapons.Count > 0)
                {
                    if (i == 0 && amours.Count > 0)
                    {
                        Amour nextAmour = amours[0];
                        stages[i].Add(nextAmour);
                        currCards.Add(nextAmour);
                        amours.Remove(nextAmour);
                        continue;
                    }

                    // Add ally.
                    else if (allies.Count > 0)
                    {
                        AllyCard nextAlly = allies[0];
                        stages[i].Add(nextAlly);
                        currCards.Add(nextAlly);
                        allies.Remove(nextAlly);
                        continue;
                    }

                    // Add wepon
                    else if (playableWeapons.Count > 0)
                    {
                        WeaponCard nextWeapon = playableWeapons[0];
                        stages[i].Add(nextWeapon);
                        currCards.Add(nextWeapon);
                        playableWeapons.Remove(nextWeapon);
                        weapons.Remove(nextWeapon);
                        continue;
                    }
                }

                lastCards = currCards;
            }

            return(stages);
        }
Exemple #21
0
    // earlier foe behavior, we try to play using the smallest cards possible until we play 10 more than the previous foe encounter
    public List <Card> playEarlierFoe(List <Card> hand, int previous, bool amour, string questName, List <Player> players)
    {
        strategyUtil strat = new strategyUtil();
        // set our threshold
        int bpNeeded = previous + 10;
        // instantiate the list of cards were going to play and return
        List <Card> foeEncounter = new List <Card>();

        // if we haven't yet played the amour
        // check if we have an amour card and play it, deduct its BP from the bpNeeded
        if (amour == false)
        {
            for (int i = 0; i < hand.Count; i++)
            {
                if (hand[i].type == "Amour Card")
                {
                    foeEncounter.Add(hand[i]);
                    bpNeeded -= 10;
                }
            }
        }

        List <Card> weapons = new List <Card>();
        List <Card> allies  = new List <Card>();

        // make a list of the valid cards to play, non-duplicate weapons and Allies with more than 0 BP.
        List <Card> validCards = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card"))
            {
                weapons.Add(hand[i]);
            }
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints(questName, players) > 0)
                {
                    allies.Add(hand[i]);
                }
            }
        }

        // sort them by ascending order
        allies  = strat.sortAlliesByAscendingOrder(allies, questName, players);
        weapons = strat.sortWeaponsByAscendingOrder(weapons);

        while (allies.Count > 0 && bpNeeded > 0)
        {
            foeEncounter.Add(allies[0]);
            AllyCard ally = (AllyCard)allies[0];
            bpNeeded -= ally.getBattlePoints(questName, players);
            allies.Remove(allies[0]);
        }

        while (weapons.Count > 0 && bpNeeded > 0)
        {
            foeEncounter.Add(weapons[0]);
            WeaponCard weapon = (WeaponCard)weapons[0];
            bpNeeded -= weapon.battlePoints;
            weapons.Remove(weapons[0]);
        }
        // return the resulting list
        return(foeEncounter);
    }
    public void UpdateTargetDropdown(params object[] objects)
    {
        // ...................Seems like Unity's BUG.......................
        ScrollRect dropDownList = m_targetDropdown.GetComponentInChildren <ScrollRect>();

        if (dropDownList != null)
        {
            GameObject.Destroy(dropDownList.gameObject);
        }
        m_targetDropdown.ClearOptions();
        List <string> optionNames = new List <string>();

        switch (Player.Get().GetCurrentAction())
        {
        case PlayerAction.Move:
        {
            var destList = Player.Get().m_currentLocation.m_lstDestinations;

            optionNames.Add("请选择目的地...");
            destList.ForEach(dest => { optionNames.Add(dest.m_cardName); });
        }
        break;

        case PlayerAction.PlayCard:
        {
            optionNames.Add("请选择手牌...");
            var handCards = Player.Get().GetHandCards();

            handCards.ForEach(dest =>
                {
                    if (Player.Get().CanPlayHandCard(dest))
                    {
                        optionNames.Add(dest.m_cardName);
                    }
                });
        }
        break;

        case PlayerAction.Evade:
        {
            optionNames.Add("请选择目标...");
            var enemies = Player.Get().GetEnemyCards();

            enemies.ForEach(enemy => { optionNames.Add(enemy.m_cardName); });
        }
        break;

        case PlayerAction.Fight:
        case PlayerAction.BeatcopCardAction:
        {
            optionNames.Add("请选择目标...");
            var enemies = Player.Get().GetEnemyCards();

            enemies.ForEach(enemy => { optionNames.Add(enemy.m_cardName); });

            Player.Get().m_currentLocation.m_lstCardsAtHere.ForEach(card =>
                {
                    if (card is EnemyCard)
                    {
                        optionNames.Add(card.m_cardName);
                    }
                });
        }
        break;

        case PlayerAction.ReactiveEvent:
        {
            var cards = Player.Get().GetHandCards();

            optionNames.Add("是否要打出事件牌...");
            optionNames.Add("不打出");
            cards.ForEach(dest =>
                {
                    if (dest.m_eventTiming == GameLogic.Get().m_currentTiming)
                    {
                        optionNames.Add(dest.m_cardName);
                    }
                });
        }
        break;

        case PlayerAction.ReactiveAsset:
        {
            var cards = Player.Get().GetAssetAreaCards();

            optionNames.Add("是否要使用资产牌的技能...");
            optionNames.Add("不使用");
            cards.ForEach(dest =>
                {
                    if (dest.m_eventTiming == GameLogic.Get().m_currentTiming)
                    {
                        optionNames.Add(dest.m_cardName);
                    }
                });
        }
        break;

        case PlayerAction.AssignDamage:
        {
            optionNames.Add("请分配伤害...");
            AllyCard ally        = (AllyCard)objects[1];
            int      totalDamage = (int)objects[0];

            for (int i = 0; i <= ally.m_health && i <= totalDamage; ++i)
            {
                optionNames.Add(string.Format("你{0}点伤害,盟友{1}点伤害", totalDamage - i, i));
            }
        }
        break;

        case PlayerAction.AssignHorror:
        {
            optionNames.Add("请分配恐怖...");
            AllyCard ally        = (AllyCard)objects[1];
            int      totalDamage = (int)objects[0];

            for (int i = 0; i <= ally.m_sanity && i <= totalDamage; ++i)
            {
                optionNames.Add(string.Format("你{0}点恐怖,盟友{1}点恐怖", totalDamage - i, i));
            }
        }
        break;

        default:
            UnityEngine.Assertions.Assert.IsTrue(false, "Unknown player action in UpdateTargetDropdown()!!!");
            break;
        }

        m_targetDropdown.AddOptions(optionNames);
        m_targetDropdown.RefreshShownValue();
        m_targetDropdown.value = 0;
    }
Exemple #23
0
    public void getFreeBid_returnsBidif_bidBuffisZero()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", "", 5, 5, "Special", "quest", "ally", 0, 0, new NoBuff());

        Assert.AreEqual(ally.freeBid, ally.getFreeBid("quest", new List <Player>()));
    }
Exemple #24
0
    // Strategy 1 for an earlier foe encounter is as follows:

    /*
     * 1. Sort Amour/Allies/Weapons in decreasing order of BP
     *
     * 2. Play 2 if (if possible) allies /amours,
     *
     */
    public List <Card> playEarlierFoe(List <Card> hand, int previous, bool amour, string questName, List <Player> players)
    {
        strategyUtil strat        = new strategyUtil();
        List <Card>  allies       = new List <Card>();
        List <Card>  weapons      = new List <Card>();
        List <Card>  foeEncounter = new List <Card>();
        int          count        = 0;
        int          amourCount   = 0;

        for (int i = 0; i < hand.Count; i++)
        {
            if (amour == false)
            {
                if (hand[i].type == "Amour Card")
                {
                    foeEncounter.Add(hand[i]);
                    amourCount += 1;
                    amour       = true;
                }
            }
            if (hand[i].type == "Ally Card")
            { // && hand[i].battlePoints > 0){
                AllyCard ally = (AllyCard)hand[i];
                if (ally.battlePoints > 0)
                {
                    count++;
                    allies.Add(hand[i]);
                }
            }
            if (hand[i].type == "Weapon Card")
            {
                weapons.Add(hand[i]);
            }
        }

        if (count >= 2)
        {
            allies = strat.sortAlliesByAscendingOrder(allies, questName, players);
            foeEncounter.Add(allies[0]);
            hand.Remove(allies[0]);
            if (foeEncounter.Count == 2)
            {
                return(foeEncounter);
            }
            foeEncounter.Add(allies[1]);
            hand.Remove(allies[1]);
        }
        else
        {
            for (int i = 0; i < allies.Count; i++)
            {
                foeEncounter.Add(allies[i]);
            }
            weapons = strat.sortWeaponsByAscendingOrder(weapons);
            int index = 0;
            while (foeEncounter.Count < 2 && index < weapons.Count)
            {
                foeEncounter.Add(weapons[index]);
                index++;
            }
        }
        return(foeEncounter);
    }
Exemple #25
0
    public void getFreeBid_returnsBidPoints_Adds_allyEffectBuffOnQuest()
    {
        var ally = new AllyCard("Ally Card", "Ayrton", "", 5, 5, "Special", "quest", "ally", 1, 1, new BuffOnQuestEffect());

        Assert.AreEqual(6, ally.getFreeBid("quest", new List <Player>()));
    }
    // Load the cards up.
    public void loadCards(List <Card> cards, GameObject area)
    {
        Card currCard;

        // Create Card GameObject's.
        for (int i = 0; i < cards.Count; i++)
        {
            currCard = cards[i];

            area.GetComponent <CardArea>().addCard(currCard);
            GameObject CardUI = null;

            // TODO: Clean this up.
            if (currCard.GetType() == typeof(WeaponCard))
            {
                WeaponCard currWeapon = (WeaponCard)currCard;
                CardUI = Instantiate(WeaponCard, new Vector3(), Quaternion.identity);
                //CardUI = Instantiate(WeaponCard ,area.transform);
                CardUI.GetComponent <WeaponCard>().name  = currWeapon.name;
                CardUI.GetComponent <WeaponCard>().asset = currWeapon.asset;
                CardUI.GetComponent <WeaponCard>().power = currWeapon.power;
            }
            else if (currCard.GetType() == typeof(FoeCard))
            {
                FoeCard currFoe = (FoeCard)currCard;
                CardUI = Instantiate(FoeCard, new Vector3(), Quaternion.identity);
                //CardUI = Instantiate(FoeCard,area.transform);
                CardUI.GetComponent <FoeCard>().name    = currFoe.name;
                CardUI.GetComponent <FoeCard>().type    = currFoe.type;
                CardUI.GetComponent <FoeCard>().loPower = currFoe.loPower;
                CardUI.GetComponent <FoeCard>().hiPower = currFoe.hiPower;
                CardUI.GetComponent <FoeCard>().special = currFoe.special;
                CardUI.GetComponent <FoeCard>().asset   = currFoe.asset;
            }
            else if (currCard.GetType() == typeof(AllyCard))
            {
                AllyCard currAlly = (AllyCard)currCard;
                CardUI = Instantiate(AllyCard, new Vector3(), Quaternion.identity);
                //CardUI = Instantiate(AllyCard,area.transform);
                CardUI.GetComponent <AllyCard>().name           = currAlly.name;
                CardUI.GetComponent <AllyCard>().asset          = currAlly.asset;
                CardUI.GetComponent <AllyCard>().special        = currAlly.special;
                CardUI.GetComponent <AllyCard>().power          = currAlly.power;
                CardUI.GetComponent <AllyCard>().bid            = currAlly.bid;
                CardUI.GetComponent <AllyCard>().bonusPower     = currAlly.bonusPower;
                CardUI.GetComponent <AllyCard>().bonusBid       = currAlly.bonusBid;
                CardUI.GetComponent <AllyCard>().questCondition = currAlly.questCondition;
                CardUI.GetComponent <AllyCard>().allyCondition  = currAlly.allyCondition;
            }
            else if (currCard.GetType() == typeof(AmourCard))
            {
                AmourCard currAmour = (AmourCard)currCard;
                CardUI = Instantiate(AmourCard, new Vector3(), Quaternion.identity);
                CardUI = Instantiate(AmourCard, area.transform);
                CardUI.GetComponent <AmourCard>().name  = currAmour.name;
                CardUI.GetComponent <AmourCard>().asset = currAmour.asset;
                CardUI.GetComponent <AmourCard>().power = currAmour.power;
                CardUI.GetComponent <AmourCard>().bid   = currAmour.bid;
            }
            else if (currCard.GetType() == typeof(TestCard))
            {
                TestCard currTest = (TestCard)currCard;
                CardUI = Instantiate(TestCard, new Vector3(), Quaternion.identity);
                //CardUI = Instantiate(TestCard,area.transform);
                CardUI.GetComponent <TestCard>().name    = currTest.name;
                CardUI.GetComponent <TestCard>().asset   = currTest.asset;
                CardUI.GetComponent <TestCard>().minBids = currTest.minBids;
            }

            // Load the card sprite.
            Sprite card = Resources.Load <Sprite>(currCard.asset);
            CardUI.gameObject.GetComponent <Image>().sprite = card;

            currCard.obj = CardUI;
            currCard.obj.transform.parent = area.transform;
        }
    }
Exemple #27
0
    public void Test_AI()
    {
        AIPlayer      ai      = new AIPlayer(0, 1);
        List <Player> players = new List <Player> ();


        FoeCard    thieves    = new FoeCard("Thieves", "Thieves", 5, 5, false, "card_image/foe/foeCard4");
        FoeCard    thieves2   = new FoeCard("Thieves", "Thieves", 5, 5, false, "card_image/foe/foeCard4");
        FoeCard    boar       = new FoeCard("Boar", "Boar", 5, 15, false, "card_image/foe/foeCard3");
        WeaponCard excalibur  = new WeaponCard("Excalibur", 30, "card_image/weapons/weaponCard3");
        WeaponCard excalibur2 = new WeaponCard("Excalibur", 30, "card_image/weapons/weaponCard3");
        AllyCard   sirtristan = new AllyCard("Sir Tristan", 10, 0, 20, 0, null, "Queen Iseult", false, "card_image/special/specialCard4");
        WeaponCard lance      = new WeaponCard("Lance", 20, "card_image/weapons/weaponCard4");
        WeaponCard lance2     = new WeaponCard("Lance", 20, "card_image/weapons/weaponCard4");
        WeaponCard dagger     = new WeaponCard("Dagger", 5, "card_image/weapons/weaponCard2");


        players.Add(ai);
        players.Add(new Player(1));
        players.Add(new Player(2));

        //SPONSOR QUEST
        QuestCard quest = new QuestCard("Boar Hunt", 2, "Boar", "card_image/quest/questCard4");

        ai.addCard(thieves);
        Assert.IsNull(ai.sponsorQuest(quest, players));
        ai.addCard(thieves2);
        Assert.IsNull(ai.sponsorQuest(quest, players));
        ai.addCard(boar);
        List <List <Card> > stages = ai.sponsorQuest(quest, players);

        Assert.IsTrue(stages [0].Contains(thieves));
        Assert.IsTrue(stages [1].Contains(boar));
        ai.addCard(excalibur);
        ai.addCard(excalibur2);
        ai.addCard(lance);
        stages = ai.sponsorQuest(quest, players);
        Assert.IsTrue(stages [0].Contains(thieves));
        Assert.IsTrue(stages [0].Contains(excalibur2));
        Assert.AreEqual(stages [0].Count, 2);
        Assert.IsTrue(stages [1].Contains(boar));
        Assert.IsTrue(stages [1].Contains(excalibur));
        Assert.IsTrue(stages [1].Contains(lance));
        Assert.AreEqual(stages [1].Count, 3);
        players [1].AddShields(3);
        //2 shield to evolve
        Assert.IsNull(ai.sponsorQuest(quest, players));
        //reset player 1
        players [1] = new Player(1);

        //JOIN AND PLAY QUEST
        ai         = new AIPlayer(0, 1);
        players[0] = ai;
        Assert.IsFalse(ai.joinQuest(quest, players));
        ai.addCard(thieves);
        ai.addCard(boar);
        ai.addCard(lance);
        ai.addCard(lance2);
        ai.addCard(excalibur);
        Assert.IsFalse(ai.joinQuest(quest, players));
        ai.addCard(excalibur2);
        //2 foe cards from the quest sponsor
        Assert.IsTrue(ai.joinQuest(quest, players));
        ai          = new AIPlayer(0, 1);
        players [0] = ai;
        ai.addCard(thieves);
        ai.addCard(boar);
        ai.addCard(excalibur);
        ai.addCard(sirtristan);
        Assert.IsFalse(ai.joinQuest(quest, players));
        ai.addCard(lance);
        Assert.IsTrue(ai.joinQuest(quest, players));

        //will play lance and excalibur and sir tristan
        ai.addCard(dagger);
        List <Card> played = ai.playQuest(players, -1, true, false);

        Assert.IsTrue(played.Contains(sirtristan));
        Assert.IsTrue(played.Contains(excalibur));
        Assert.IsTrue(played.Contains(lance));
        Assert.IsTrue(played.Contains(dagger));
        Assert.AreEqual(played.Count, 4);

        ai          = new AIPlayer(0, 1);
        players [0] = ai;
        ai.addCard(excalibur);
        ai.addCard(sirtristan);
        ai.addCard(lance);
        ai.addCard(dagger);
        ai.addCard(excalibur2);
        ai.addCard(lance2);

        played = ai.playQuest(players, -1, false, false);
        Assert.IsTrue(played.Contains(dagger));
        Assert.IsTrue(played.Contains(lance));
        Assert.IsTrue(played.Contains(sirtristan));
        Assert.AreEqual(played.Count, 3);

        //TOURNAMENT
        TournamentCard tournament = new TournamentCard("Tournament at Camelot", 3, "card_image/tournament/TournamentCard");

        Assert.IsFalse(ai.joinTournament(tournament, players));
        players [1].AddShields(3);
        Assert.IsTrue(ai.joinTournament(tournament, players));
        //remove shields
        players [1] = new Player(1);

        played = ai.playTournament(tournament, players);
        Assert.IsTrue(played.Contains(lance));
        Assert.IsTrue(played.Contains(excalibur));
        Assert.AreEqual(played.Count, 2);

        players [1].AddShields(3);
        played = ai.playTournament(tournament, players);
        Assert.IsTrue(played.Contains(sirtristan));
        Assert.IsTrue(played.Contains(excalibur));
        Assert.IsTrue(played.Contains(lance));
        Assert.IsTrue(played.Contains(dagger));
        Assert.AreEqual(played.Count, 4);
    }