コード例 #1
0
    public void CheatPanelToggle()
    {
        if (GameUtil.CheckSponsorship(players) >= 0 && GameUtil.CheckParticipation(players) > 0)
        {
            if (!cheatPanel.activeSelf)
            {
                cheatPanel.SetActive(true);
                int cheatPanelStageNumber = System.Int32.Parse(cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text.Substring(6)) + 1;

                cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + (cheatPanelStageNumber);
                cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + QuestState.stages[cheatPanelStageNumber].Count;
            }
            else
            {
                int cheatPanelStageNumber = System.Int32.Parse(cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text.Substring(6));

                if (cheatPanelStageNumber >= QuestState.currentQuest.stages)
                {
                    cheatPanel.SetActive(false);
                    cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + 0;
                    cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + 0;
                }
                else
                {
                    cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + (cheatPanelStageNumber + 1);
                    cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + QuestState.stages[cheatPanelStageNumber].Count;
                }
            }
        }
    }
コード例 #2
0
ファイル: iStoryQuest.cs プロジェクト: ahmed-alzahrani/QUEST
    public void execute(List <Player> players, Card storyCard, Controller game)
    {
        //FIND A SPONSOR FOR THE QUEST
        if (QuestState.state == "FindingSponsor")
        {
            QuestState.currentQuest = game.currentQuest;
            QueryingUtil.SponsorCheck(game);

            if (game.numIterations >= game.numPlayers)
            {
                game.numIterations = 0;

                Debug.Log("CheckSponsorship" + GameUtil.CheckSponsorship(game.players));
                if (GameUtil.CheckSponsorship(game.players) != -1)
                {
                    QuestState.state = "Sponsoring";

                    QuestState.invalidQuestSubmitted = false;

                    game.userInput.DeactivateUI();
                    game.userInput.ActivateCardUIPanel("What FOE or TEST cards would you like to add?");
                }
                else
                {
                    game.isDoneStoryEvent = true;
                }
            }
        }

        // GET SPONSOR'S CARDS FOR THE QUEST
        if (QuestState.state == "Sponsoring")
        {
            //Displays a prompt for the player if the quest they submitted is invalid.
            if (QuestState.invalidQuestSubmitted)
            {
                InvalidQuestPrompt(game);
            }
            else
            {
                QueryingUtil.SponsorQuery(game);

                if (game.numIterations >= game.currentQuest.stages)
                {
                    QuestState.stages = new List <Card> [game.currentQuest.stages];
                    System.Array.Copy(game.sponsorQueriedCards, QuestState.stages, game.currentQuest.stages);
                    game.numIterations = 0;

                    if (ValidQuest())
                    {
                        QuestState.state = "CheckingForParticipants";
                        UIUtil.UpdatePlayerTurn(game);
                        game.userInput.DeactivateUI();
                        game.userInput.ActivateBooleanCheck("Participate in the QUEST?");
                    }
                    else
                    {
                        QuestState.invalidQuestSubmitted = true;

                        for (int i = 0; i < game.sponsorQueriedCards.Length; i++)
                        {
                            if (game.sponsorQueriedCards[i] != null)
                            {
                                for (int j = 0; j < game.sponsorQueriedCards[i].Count; j++)
                                {
                                    game.players[game.currentPlayerIndex].hand.Add(game.sponsorQueriedCards[i][j]);
                                    UIUtil.AddCardToPanel(UIUtil.CreateUIElement(game.sponsorQueriedCards[i][j], game.cardPrefab), game.handPanel);
                                    game.sponsorQueriedCards[i].RemoveAt(j);
                                    j--;
                                }
                            }
                        }

                        UIUtil.PopulatePlayerBoard(game);
                        game.userInput.DeactivateUI();
                        game.userInput.ActivateBooleanCheck("Invalid Quest Submitted. Please try again.");
                    }
                }
            }
        }

        //CHECKING FOR QUEST PARTICIPANTS
        if (QuestState.state == "CheckingForParticipants")
        {
            QueryingUtil.ParticipationCheck("Quest", game);

            if (game.numIterations >= game.numPlayers)
            {
                Debug.Log("Done Participation Check");
                if (GameUtil.CheckParticipation(game.players) < 1)
                {
                    EndQuest(game);
                }
                else
                {
                    QuestState.state  = "PlayingQuest";
                    QuestState.amours = new List <Card> [game.numPlayers];

                    for (int i = 0; i < QuestState.amours.Length; i++)
                    {
                        QuestState.amours[i] = new List <Card>();
                    }

                    QuestState.testBids         = new int[game.numPlayers];
                    QuestState.testBidSubmitted = false;
                    QuestState.bidsOver         = false;

                    DrawForStageStart(game);
                    //game.populatePlayerBoard();
                    //game.populateQuestBoard(false);
                    UIUtil.PopulatePlayerBoard(game);
                    UIUtil.PopulateQuestBoard(game, false);
                    game.numIterations = 0;
                    game.userInput.DeactivateUI();
                    if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                    {
                        QuestState.round = 0;
                        TestCard tempTestCard = (TestCard)QuestState.stages[0][0];
                        string[] minBidString = new string[1];
                        minBidString[0] = GetMinRequiredBid().ToString();
                        game.userInput.ActivateUserInputCheck("A Test is in play, the minimum bid is: " + GetMinRequiredBid().ToString());
                    }
                    else
                    {
                        game.userInput.ActivateCardUIPanel("Play Ally, Weapon and/or Amour cards for this stage of the quest");
                    }
                }
            }
        }

        //QUEST GAMEPLAY HERE
        else if (QuestState.state == "PlayingQuest")
        {
            if (QuestState.currentStage >= game.currentQuest.getStages() || GameUtil.CheckParticipation(game.players) < 1)
            {
                Debug.Log("Called EndQuest here");
                EndQuest(game);
            }
            else
            {
                if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                {
                    if (!QuestState.bidsOver)
                    {
                        TestQuery(game);
                        if (GameUtil.CheckParticipation(game.players) < 2 && QuestState.testBidSubmitted == true)
                        {
                            //check for test card thing

                            QuestState.bidsOver = true;
                            game.userInput.DeactivateUI();
                            //game.populatePlayerBoard();
                            UIUtil.PopulatePlayerBoard(game);
                            game.userInput.ActivateCardUIPanel("Please submit " + (Mathf.Max(QuestState.testBids[game.currentPlayerIndex] - game.players[game.currentPlayerIndex].calculateBid(game.currentQuest.name, game.players), 0)).ToString() + " cards to discard.");
                        }
                    }
                    else
                    {
                        DiscardCards(game);
                    }
                }
                else
                {
                    QueryingUtil.CardQuerying("Quest", game);

                    //get player's cards for the quest
                    if (game.userInput.cardPrompt.selectedCards.Count > 0)
                    {
                        //game.populateQuestBoard(false);

                        UIUtil.PopulateQuestBoard(game, false);
                    }
                    if (game.numIterations >= game.numPlayers)
                    {
                        for (int i = 0; i < game.queriedCards.Length; i++)
                        {
                            if (GameUtil.CheckSponsorship(game.players) == i)
                            {
                                continue;
                            }
                            if (!game.players[i].participating)
                            {
                                continue;
                            }

                            int sum = 0;

                            if (game.queriedCards[i] != null)
                            {
                                for (int j = 0; j < game.queriedCards[i].Count; j++)
                                {
                                    if (game.queriedCards[i][j] == null)
                                    {
                                        continue;
                                    }

                                    if (game.queriedCards[i][j].type == "Weapon Card")
                                    {
                                        Debug.Log("Weapon Card at " + j.ToString() + " bp value is " + ((WeaponCard)game.queriedCards[i][j]).battlePoints.ToString());
                                        sum += ((WeaponCard)game.queriedCards[i][j]).battlePoints;
                                    }
                                    else if (game.queriedCards[i][j].type == "Amour Card")
                                    {
                                        QuestState.amours[i].Add(game.queriedCards[i][j]);
                                        game.queriedCards[i].RemoveAt(j);
                                        j--;
                                    }
                                }

                                if (QuestState.amours[i] != null)
                                {
                                    for (int j = 0; j < QuestState.amours[i].Count; j++)
                                    {
                                        AmourCard tempAmourCard = (AmourCard)QuestState.amours[i][j];
                                        sum += tempAmourCard.battlePoints;
                                    }
                                }

                                sum += game.players[i].CalculateBP(storyCard.name, players);
                                if (sum < GetStageBP(QuestState.currentStage, game.currentQuest))
                                {
                                    Debug.Log("Stage Failed Result: GetStageBP = " + GetStageBP(QuestState.currentStage, game.currentQuest).ToString() + " Sum of player strength = " + sum.ToString());
                                    game.players[i].participating = false;
                                }
                            }
                        }
                    }
                }
            }

            if (game.numIterations >= game.numPlayers)
            {
                Debug.Log("currentStage: " + QuestState.currentStage);
                //game.populateQuestBoard(true);
                UIUtil.PopulateQuestBoard(game, true);

                if (!(QuestState.stages[QuestState.currentStage][0].type == "Test Card"))
                {
                    QuestState.previousQuestBP = GetStageBP(QuestState.currentStage, QuestState.currentQuest);
                }

                QuestState.currentStage++;
                if (QuestState.currentStage >= game.currentQuest.getStages())
                {
                    EndQuest(game);
                }
                else if (GameUtil.CheckParticipation(game.players) < 1)
                {
                    EndQuest(game);
                }
                else
                {
                    DrawForStageStart(game);
                    UIUtil.PopulatePlayerBoard(game);
                    game.numIterations = 0;
                    game.userInput.DeactivateUI();
                    System.Array.Clear(game.queriedCards, 0, game.queriedCards.Length);

                    //check for discard at the end of each stage
                    game.playerStillOffending = GameUtil.PlayerOffending(game.players);

                    if (game.playerStillOffending)
                    {
                        game.numIterations = 0;
                        //find first offending player
                        while (!game.players[game.currentPlayerIndex].handCheck() && game.numIterations < game.numPlayers)
                        {
                            //doesn't need to discard update turn
                            game.numIterations++;
                            UIUtil.UpdatePlayerTurn(game);
                        }
                        game.userInput.ActivateDiscardCheck("You need to Discard " + (players[game.currentPlayerIndex].hand.Count - 12).ToString() + " Cards");
                    }

                    if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                    {
                        QuestState.round = 0;
                        TestCard tempTestCard = (TestCard)QuestState.stages[QuestState.currentStage][0];
                        string[] minBidString = new string[1];
                        minBidString[0] = GetMinRequiredBid().ToString();
                        game.userInput.ActivateUserInputCheck("A Test is in play, the minimum bid you must make is: " + (GetMinRequiredBid()).ToString());
                    }
                    else
                    {
                        game.userInput.ActivateCardUIPanel("Play Ally, Weapon and/or Amour cards for this stage of the quest");
                    }
                }
            }
        }
    }
コード例 #3
0
    public void execute(List <Player> player, Card storyCard, Controller game)
    {
        //Ally cards on field do not matter !!!!!!! so only player rank and what he adds in
        if (TournamentState.state == "Participation" && TournamentState.tourneyRound == 1)
        {
            //do participation check code
            QueryingUtil.ParticipationCheck("Tournament", game);

            //done checking for participation
            if (game.numIterations >= game.numPlayers)
            {
                TournamentState.numberOfParticipants = GameUtil.CheckParticipation(game.players);
                if (GameUtil.CheckParticipation(game.players) > 1)
                {
                    //there are more than 1 person participating
                    TournamentState.state = "CardQuery";

                    //participants draw one card
                    for (int i = 0; i < game.players.Count; i++)
                    {
                        if (game.players[i].participating)
                        {
                            game.players[i].hand.Add(GameUtil.DrawFromDeck(game.adventureDeck, 1)[0]);
                        }
                    }
                    UIUtil.PopulatePlayerBoard(game); //just in case
                    game.numIterations = 0;           //for next part of tourney
                    game.userInput.DeactivateUI();
                    game.userInput.ActivateCardUIPanel("What AMOUR , ALLY , OR WEAPON CARDS do you want to use?");
                }
                else
                {
                    //game is done resolve the tournament no one or 1 person participating
                    //resolve tournament
                    TournamentCard myCard = (TournamentCard)storyCard;
                    for (int i = 0; i < game.players.Count; i++)
                    {
                        if (game.players[i].participating)
                        {
                            Debug.Log("number of shields" + myCard.shields);
                            game.players[i].addShields(1 + myCard.shields);
                        }
                    }

                    //reset values
                    game.isDoneStoryEvent = true;
                    TournamentState.state = "Participation";
                    TournamentState.numberOfParticipants = 0;
                    TournamentState.tourneyRound         = 1;
                    TournamentState.undiscardedCards     = null;
                    TournamentState.cardsToBeDiscarded   = new List <Card>();
                }
            }
        }
        else if (TournamentState.state == "CardQuery")
        {
            //query players for cards
            QueryingUtil.CardQuerying("Tournament", game);

            //done querying
            if (game.numIterations >= game.numPlayers)
            {
                int        maximumBP    = 0;
                int        totalPlayer  = 0;
                List <int> playerTotals = new List <int>();

                //concatonate results
                //ensuring deep copy
                List <List <Card> > temp = new List <List <Card> >(game.queriedCards);

                if (TournamentState.tourneyRound == 1)
                {
                    TournamentState.undiscardedCards = new List <Card> [game.queriedCards.Length];
                    //copy everything
                    System.Array.Copy(game.queriedCards, TournamentState.undiscardedCards, game.queriedCards.Length);
                }
                else
                {
                    //concat results
                    for (int i = 0; i < game.queriedCards.Length; i++)
                    {
                        if (game.queriedCards[i] != null)
                        {
                            for (int j = 0; j < game.queriedCards[i].Count; j++)
                            {
                                TournamentState.undiscardedCards[i].Add(game.queriedCards[i][j]);
                            }
                        }
                    }
                }

                //debugging purposes
                for (int i = 0; i < TournamentState.undiscardedCards.Length; i++)
                {
                    if (TournamentState.undiscardedCards[i] != null)
                    {
                        for (int j = 0; j < TournamentState.undiscardedCards[i].Count; j++)
                        {
                            Debug.Log(TournamentState.undiscardedCards[i][j].name);
                        }
                    }
                }

                for (int i = 0; i < TournamentState.undiscardedCards.Length; i++)
                {
                    //not participating
                    if (!(game.players[i].participating))
                    {
                        playerTotals.Add(-100); continue;
                    }
                    else
                    {
                        if (TournamentState.undiscardedCards[i] != null)
                        {
                            //sum up card battle pts
                            for (int j = 0; j < TournamentState.undiscardedCards[i].Count; j++)
                            {
                                if (TournamentState.undiscardedCards[i][j].type == "Weapon Card")
                                {
                                    WeaponCard weapon = (WeaponCard)TournamentState.undiscardedCards[i][j];
                                    totalPlayer += weapon.battlePoints;
                                }
                                else if (TournamentState.undiscardedCards[i][j].type == "Amour Card")
                                {
                                    AmourCard amour = (AmourCard)TournamentState.undiscardedCards[i][j];
                                    totalPlayer += amour.battlePoints;
                                }
                            }
                            //add player's rank BP only
                            totalPlayer += game.players[i].CalculateBP("", player);
                        }
                        else
                        {
                            //if he is participating and didn't add anything use his rank only
                            totalPlayer = game.players[i].CalculateBP("", player);
                        }
                    }

                    //add all totals to trace winner
                    playerTotals.Add(totalPlayer);
                    Debug.Log(i.ToString() + ": " + totalPlayer);

                    //check for maximum
                    if (maximumBP < totalPlayer)
                    {
                        maximumBP = totalPlayer;
                    }
                    totalPlayer = 0;
                }

                //discard weapon Cards
                for (int i = 0; i < TournamentState.undiscardedCards.Length; i++)
                {
                    if (TournamentState.undiscardedCards[i] != null)
                    {
                        for (int j = 0; j < TournamentState.undiscardedCards[i].Count; j++)
                        {
                            if (TournamentState.undiscardedCards[i][j].type == "Weapon Card")
                            {
                                //discard weapon card
                                TournamentState.cardsToBeDiscarded.Add(TournamentState.undiscardedCards[i][j]);
                                TournamentState.undiscardedCards[i].RemoveAt(j);
                                j--;
                            }
                        }
                    }
                }

                //discard weapon cards
                if (TournamentState.cardsToBeDiscarded != null && TournamentState.cardsToBeDiscarded.Count > 0)
                {
                    GameUtil.DiscardCards(game.adventureDeck, TournamentState.cardsToBeDiscarded, game.adventureDeckDiscardPileUIButton);
                }

                //discard all cards at the end of tourney
                if (TournamentState.tourneyRound == 2)
                {
                    //discard everything
                    //discard undiscarded cards
                    for (int i = 0; i < TournamentState.undiscardedCards.Length; i++)
                    {
                        if (TournamentState.undiscardedCards[i] != null && TournamentState.undiscardedCards[i].Count > 0)
                        {
                            GameUtil.DiscardCards(game.adventureDeck, TournamentState.undiscardedCards[i], game.adventureDeckDiscardPileUIButton);
                        }
                    }
                }

                Debug.Log("Deciding winners");

                List <int> winners = new List <int>();
                for (int i = 0; i < playerTotals.Count; i++)
                {
                    if (playerTotals[i] < maximumBP)
                    {
                        //ppl who got beat
                        game.players[i].participating = false;
                    }
                    else
                    {
                        //winners
                        winners.Add(i);
                    }
                }

                //check for player discard
                game.playerStillOffending = GameUtil.PlayerOffending(game.players);

                if (game.playerStillOffending)
                {
                    game.numIterations = 0;

                    //find first offending player
                    while (!game.players[game.currentPlayerIndex].handCheck() && game.numIterations < game.numPlayers)
                    {
                        //doesn't need to discard update turn
                        game.numIterations++;
                        UIUtil.UpdatePlayerTurn(game);
                    }

                    game.userInput.ActivateDiscardCheck("You need to Discard " + (game.players[game.currentPlayerIndex].hand.Count - 12).ToString() + " Cards");
                }

                //undecided another round
                if (winners.Count >= 2 && TournamentState.tourneyRound == 1)
                {
                    Debug.Log("Couldn't find winners");

                    TournamentState.tourneyRound = 2;
                    game.numIterations           = 0;
                    game.userInput.ActivateCardUIPanel("What AMOUR , ALLY , OR WEAPON CARDS do you want to use?");
                    Debug.Log("There is a draw");
                    //requery cards
                    System.Array.Clear(game.queriedCards, 0, game.queriedCards.Length);

                    // game.queriedCards.Clear();
                    TournamentState.cardsToBeDiscarded.Clear();
                }
                else
                {
                    Debug.Log("found winners");

                    //we are done we have a winner or winners
                    for (int i = 0; i < winners.Count; i++)
                    {
                        TournamentCard myCard = (TournamentCard)storyCard;
                        Debug.Log("shields: " + myCard.shields);
                        game.players[winners[i]].addShields(TournamentState.numberOfParticipants + myCard.shields);
                    }

                    //reset everything
                    game.isDoneStoryEvent = true;
                    TournamentState.state = "Participation";
                    TournamentState.numberOfParticipants = 0;
                    TournamentState.tourneyRound         = 1;
                    System.Array.Clear(game.queriedCards, 0, game.queriedCards.Length);
                    System.Array.Clear(TournamentState.undiscardedCards, 0, TournamentState.undiscardedCards.Length);
                    TournamentState.cardsToBeDiscarded.Clear();
                }
            }
        }
    }