Exemplo n.º 1
0
    public int GetStageBP(int index, QuestCard q)
    {
        strategyUtil util = new strategyUtil();
        int          sum  = 0;

        Debug.Log("GetStageBP index: " + index.ToString());

        if (index >= QuestState.stages.Length)
        {
            Debug.Log("Invalid index given to GetStageBP");
            return(-2);
        }
        if (QuestState.stages[index] == null)
        {
            Debug.Log("null index given to GetStageBP");
            return(-2);
        }
        if (QuestState.stages[index].Count < 1)
        {
            Debug.Log("Blank Stage");
            return(-2);
        }
        if (QuestState.stages[index][0] == null)
        {
            Debug.Log("Blank Stage");
            return(-2);
        }
        if (QuestState.stages[index][0].type != "Foe Card" && QuestState.stages[index][0].type != "Test Card")
        {
            Debug.Log("First card in stage[" + index.ToString() + "] is not a Foe or Test card");
            return(-2);
        }
        else
        {
            if (QuestState.stages[index][0].type == "Test Card")
            {
                return(-1);
            }
            else
            {
                //We have a foe and weapon card
                sum += util.getContextBP((FoeCard)QuestState.stages[index][0], QuestState.currentQuest.foe);
                for (int i = 1; i < QuestState.stages[index].Count; i++)
                {
                    if (QuestState.stages[index][i].type != "Weapon Card")
                    {
                        Debug.Log("Invalid quest stage config, stage[" + index.ToString() + "] has a " + QuestState.stages[index][i].type + " at index " + i.ToString() + ".");
                        return(-2);
                    }
                    else
                    {
                        sum += ((WeaponCard)QuestState.stages[index][i]).battlePoints;
                    }
                }
            }
            return(sum);
        }
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    // sets up the final stage of a quest for this CPU player, in this strategy:
    // we need to get 50BP in as few cards as possible
    public List <Card> setUpFinalFoe(List <Card> hand, string questFoe)
    {
        strategyUtil strat = new strategyUtil();
        // instantiate a List of foes and weapons from the user's hand
        List <Card> foes    = new List <Card>();
        List <Card> weapons = new List <Card>();

        // seperate the foes and weapons into their own lists from the hand
        for (var i = 0; i < hand.Count; i++)
        {
            //hand[i].display();
            if (hand[i].type == "Foe Card")
            {
                foes.Add(hand[i]);
            }
            // make sure that we sort out weapons that are already in the weapons
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card"))
            {
                weapons.Add(hand[i]);
            }
        }

        foes    = strat.sortFoesByDescendingOrder(foes, questFoe);
        weapons = strat.sortWeaponsByDescendingOrder(weapons);

        // instantiate the foeEncounter list
        List <Card> foeEncounter = new List <Card>();

        // subtract the foe with the MOST BP in the user's hand from 40, the AI threshold
        FoeCard firstFoe = (FoeCard)foes[0];
        //foes[0].display();
        int bpNeeded = (50 - strat.getContextBP(firstFoe, questFoe));

        // Add this foe to the foeEncounter as the foe to be played
        foeEncounter.Add(foes[0]);
        hand.Remove(foes[0]);

        // initialize index as 0 to loop through the weapons
        int index = 0;

        // while we still need BP toreach our 50 threshold
        while (bpNeeded > 0 && index < weapons.Count)
        {
            // if we still have weapons to loop through
            // subtract the BP of the next most powerful weapon from the threshold
            WeaponCard weapon = (WeaponCard)weapons[index];
            bpNeeded -= weapon.battlePoints;
            // add this weapon to the encounter
            // weapons[index].display();
            foeEncounter.Add(weapons[index]);
            hand.Remove(weapons[index]);
            // increment index
            index++;
        }

        Debug.Log("This is what is left of my hand...");

        for (int i = 0; i < hand.Count; i++)
        {
            //hand[i].display();
        }

        // return the most powerful foe we have with the set of weapons that most quickly gets us to 50 BP.
        Debug.Log("This is my foe encounter...");
        for (int i = 0; i < foeEncounter.Count; i++)
        {
            //foeEncounter[i].display();
        }
        return(foeEncounter);
    }
Exemplo n.º 4
0
    public static bool SponsorCapabilityHardCheck(Controller game)
    {
        //Current number of possible valid stages that can be created.
        int validStageCardsCount = 0;
        //Number of weapons in the player's hand.
        int          weaponCount = 0;
        bool         testInhand  = false;
        strategyUtil util        = new strategyUtil();

        //Parallel array of booleans for the player's hand representing available weapon slots in the hand.
        bool[] weaponAvailable = new bool[game.players[game.currentPlayerIndex].hand.Count];

        //Integer array which stores the number of instances of a given BP found in the player's hand.
        //All battle points are a multiple of 5, which means they're translatable from a 5 - 70 scale to a 0 - 14 scale
        //This is then widened to account for the highest possible BP to prevent a index out of bounds error
        //Maximum BP size of a stage
        //(Max Dragon + Excalibur + Lance + Battle Axe + Sword + Horse + Dagger)
        //(70 + 30 + 20 + 15 + 10 + 10 + 5) / 5 = 32
        int[] foeValues = new int[(70 + 30 + 20 + 15 + 10 + 10 + 5) / 5];

        //Setting values to 0
        for (int i = 0; i < foeValues.Length; i++)
        {
            foeValues[i] = 0;
        }

        for (int i = 0; i < game.players[game.currentPlayerIndex].hand.Count; i++)
        {
            if (game.players[game.currentPlayerIndex].hand[i] != null)
            {
                if (game.players[game.currentPlayerIndex].hand[i].type == "Foe Card")
                {
                    foeValues[(util.getContextBP((FoeCard)game.players[game.currentPlayerIndex].hand[i], game.currentQuest.name) / 5) - 1]++;
                    //Non-weapon found, thus weapon unavailable at i
                    weaponAvailable[i] = false;
                }

                //If a test is found in the hand, validStageCardsCount is incremented and will never be less than 1,
                //reducing the number of unique BPs required by 1.
                else if (!testInhand && game.players[game.currentPlayerIndex].hand[i].type == "Test Card")
                {
                    testInhand = true;
                    validStageCardsCount++;
                    //Non-weapon found, thus weapon unavailable at i
                    weaponAvailable[i] = false;
                }
                else if (game.players[game.currentPlayerIndex].hand[i].type == "Weapon Card")
                {
                    weaponCount++;
                    //Weapon found, thus weapon available at i
                    weaponAvailable[i] = true;
                }
            }
        }

        //Checks to see if there are 3 foes with unique BPs
        for (int i = 0; i < foeValues.Length; i++)
        {
            if (foeValues[i] != 0)
            {
                validStageCardsCount++;
            }
        }
        if (validStageCardsCount >= game.currentQuest.stages)
        {
            return(true);
        }

        //If the number foes with unique BPs plus
        else if (validStageCardsCount + weaponCount < game.currentQuest.stages)
        {
            return(false);
        }

        //Begins the check of whether or not adding weapon cards can create a valid hand
        else
        {
            //If there is a test in the player's hand, reduce the total
            //number of uniqueBP values required by one.
            if (testInhand)
            {
                validStageCardsCount = 1;
            }
            else
            {
                validStageCardsCount = 0;
            }

            //Goes through the array of foe values, if a given index has a value greater than 1
            //weapon cards are introduced to attempt finding a unique BP.
            for (int i = 0; i < foeValues.Length; i++)
            {
                if (foeValues[i] > 1)
                {
                    for (int j = 0; j < game.players[game.currentPlayerIndex].hand.Count; j++)
                    {
                        if (game.players[game.currentPlayerIndex].hand[j].type == "Weapon Card" && weaponAvailable[j])
                        {
                            //Stores the BP value of the weaponcard found.
                            int wbp = ((WeaponCard)game.players[game.currentPlayerIndex].hand[j]).battlePoints;

                            //Second check if foeValues[i] is a unique BP as this for loop will be
                            //run for the length of the hand, this prevents reducing foeValues[i] below 1.
                            if (foeValues[i] > 1)
                            {
                                //A new valid unique BP has been found using one weapon card, the value at foeValues[i]
                                //is decremented and the value at a new index equal to the the current index plus the weapon bp
                                //is incremented.
                                if (foeValues[i + (wbp / 5)] < 1)
                                {
                                    foeValues[i]--;
                                    foeValues[i + (wbp / 5)]++;
                                    weaponAvailable[j] = false;
                                    //Checks to see if this addition of a new unique BP value creates a valid quest configuration
                                    if (CVQP(validStageCardsCount, foeValues, game))
                                    {
                                        return(true);
                                    }
                                }
                                else
                                {
                                    //Itterates for each of the duplicate BPs at foeValues[i]
                                    for (int dupe_it = 0; dupe_it < foeValues[i]; dupe_it++)
                                    {
                                        //List of weapons already added to the foe.
                                        List <WeaponCard> addedWeapons = new List <WeaponCard>();
                                        addedWeapons.Add((WeaponCard)game.players[game.currentPlayerIndex].hand[j]);
                                        List <int> usedWeapons = new List <int>();

                                        //A "Hopping Index" which carries the current foeBP + sum of weapon BPs added
                                        int ii = i + (wbp / 5);
                                        //This is the section which tests if adding multiple weapons to a single foe allows the creation of a valid Quest
                                        for (int k = j + 1; k < game.players[game.currentPlayerIndex].hand.Count; k++)
                                        {
                                            if (game.players[game.currentPlayerIndex].hand[k].type == "Weapon Card" && weaponAvailable[k])
                                            {
                                                //holds the weapon card found in the player's hand, done in order to reduce line length
                                                WeaponCard foundWeaponCard = (WeaponCard)game.players[game.currentPlayerIndex].hand[k];

                                                //Checks to see if the weapon card found is a duplicate of
                                                //a weapon card already applied to the foe.
                                                bool duplicateWeaponCheck = false;
                                                for (int aW_it = 0; aW_it < addedWeapons.Count; aW_it++)
                                                {
                                                    if (addedWeapons[aW_it].name == foundWeaponCard.name)
                                                    {
                                                        duplicateWeaponCheck = true;
                                                    }
                                                }
                                                if (duplicateWeaponCheck)
                                                {
                                                    continue;
                                                }

                                                //alternate variable name performing the same duties as wbp
                                                int wbp_VERSION_K = foundWeaponCard.battlePoints;
                                                usedWeapons.Add(k);

                                                //A new valid unique BP has been found using multiple weapon cards, the value at foeValues[i]
                                                //is decremented and the value at a new index equal to the the current index plus the sum bp
                                                //of all weapons used is incremented.
                                                if (foeValues[ii + (wbp_VERSION_K / 5)] < 1)
                                                {
                                                    foeValues[i]--;
                                                    foeValues[ii + (wbp_VERSION_K / 5)]++;

                                                    for (int clean_up_it = 0; clean_up_it < usedWeapons.Count; clean_up_it++)
                                                    {
                                                        weaponAvailable[clean_up_it] = false;
                                                    }

                                                    weaponAvailable[j] = false;
                                                    //Checks to see if this addition of a new unique BP value creates a valid quest configuration
                                                    if (CVQP(validStageCardsCount, foeValues, game))
                                                    {
                                                        return(true);
                                                    }
                                                    //new unique BP found, break loop and attempt to find another valid BP for the next dupicate BP at i
                                                    break;
                                                }

                                                //A weapon is added to the current list of weapons being applied to the foe
                                                else
                                                {
                                                    addedWeapons.Add(foundWeaponCard);
                                                    ii += wbp_VERSION_K;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Final check if there are enough unique BP values to fill the quest before returning false
            if (CVQP(validStageCardsCount, foeValues, game))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }