Example #1
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);
    }
Example #2
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);
    }
Example #3
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);
    }