Exemplo n.º 1
0
 //public List<Card> getCardsKnownInDeck()
 //{
 //    return cardsKnownInDeck;
 //}
 public void addCardsToHand(string card)
 {
     if (cardsInHand.Count < 2)
     {
         Card c = new Card(card);
         cardsInHand.Add(c);
     }
 }
Exemplo n.º 2
0
 public void addDeadCard(string card)
 {
     Card c = new Card(card);
     deadCards.Add(c);
 }
        private void handleChallengeBlockAssassination()
        {
            //person assassinating -> p1, person being assassinated -> p2, person blocking -> p3, person challenging -> p4
            //p1 -> Globals.PlayerAssassinating
            //p2 -> DropDownList1.SelectedItem.Text
            //p3 -> Globals.PlayerBlockingAssassination
            //p4 -> PlayerDD.SelectedItem.Text
            string[] id = Session["New"].ToString().Split(':');
            string[] p1 = Globals.PlayerAssassinating.Split(':');
            string p2 = DropDownList1.SelectedItem.Text;
            string p3 = Globals.PlayerBlockingAssassination;
            string p4 = PlayerDD.SelectedItem.Text;

            if (((p2 == p3 && p1[0] == p4) || (p2 == p3 && p1[0] != p4)) && p1[1] == "Won") //case one, challenger won and person being assassinated loses 2 cards
            {
                if (Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p2)] == 2) //if they have two cards
                {
                    string card = HiddenDDOne.SelectedItem.Text;
                    string card2 = HiddenDDTwo.SelectedItem.Text;

                    Globals.GlobalAnalysis.updatePlayerCardCount(p2, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p2)] - 2);

                    //if new number of cards is zero do something to kick them out of the game

                    int playerId = getUserId(p2);
                    insertAction(playerId, "Lose Card", "Lost a " + card + " and a " + card2, id[1]);

                    Globals.GlobalAnalysis.addActions(p2 + ": Lost the " + card + " and the " + card2);

                    updateDeadCardCounters(card);
                    updateDeadCardCounters(card2);
                }
                else if (Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p2)] == 1)  //if they only have one card
                {
                    string card = HiddenDDOne.SelectedItem.Text;

                    Globals.GlobalAnalysis.updatePlayerCardCount(p2, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p2)] - 1);

                    //if new number of cards is zero do something to kick them out of the game
                    int playerId = getUserId(p2);
                    insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                    Globals.GlobalAnalysis.addActions(p2 + ": Lost the " + card);

                    updateDeadCardCounters(card);
                }
                if(p2 == id[0])
                {
                    Globals.GlobalAnalysis.getCardsInHand().Clear();
                }
                Response.Redirect("GamePlayPage.aspx");
            }
            else if (((p2 != p3 && p1[0] == p4) || (p2 != p3 && p1[0] != p4)) && p1[1] == "Won") //second case, challenger won and two players loses one card
            {
                string card = HiddenDDOne.SelectedItem.Text;
                string card2 = HiddenDDThree.SelectedItem.Text;

                Globals.GlobalAnalysis.updatePlayerCardCount(p2, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p2)] - 1);
                Globals.GlobalAnalysis.updatePlayerCardCount(p3, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p3)] - 1);

                //if new number of cards is zero do something to kick them out of the game

                int playerId = getUserId(p2);
                insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                int playerIdTwo = getUserId(p3);
                insertAction(playerIdTwo, "Lose Card", "Lost a " + card2, id[1]);

                Globals.GlobalAnalysis.addActions(p2 + ": was assassinated and lost the " + card);
                Globals.GlobalAnalysis.addActions(p3 + ": Lost the " + card2);

                updateDeadCardCounters(card);
                updateDeadCardCounters(card2);

                if (p2 == id[1])
                {
                    Card c = new Card("Duke");
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card)
                            c = Globals.GlobalAnalysis.getCardsInHand()[i];
                    }
                    Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                }
                else if (p3 == id[1])
                {
                    Card c = new Card("Duke");
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card2)
                            c = Globals.GlobalAnalysis.getCardsInHand()[i];
                    }
                    Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                }
                Response.Redirect("GamePlayPage.aspx");
            }
            else //third case, challenger loses a card, and other player swaps out contessa
            {
                string card = HiddenDDOne.SelectedItem.Text;

                Globals.GlobalAnalysis.updatePlayerCardCount(p4, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(p4)] - 1);

                //if new number of cards is zero do something to kick them out of the game
                int playerId = getUserId(p4);
                insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                Globals.GlobalAnalysis.addActions(p4 + ": Lost the " + card);
                Globals.GlobalAnalysis.addActions(Globals.CorBPlayer + ": Gets new card");

                updateDeadCardCounters(card);
                if (p1[0] == id[0]) //lose a card
                {
                    Card c = new Card("Duke");
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card)
                            c = Globals.GlobalAnalysis.getCardsInHand()[i];
                    }
                    Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                    Response.Redirect("GamePlayPage.aspx");
                }
                else if (p2 == id[0]) //swap out the contessa
                {
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == "Contessa")
                            Globals.GlobalAnalysis.getCardsInHand().RemoveAt(i);
                    }

                    Label1.Text = "What is your new card?";
                    HiddenDDOne.Visible = true;
                    HiddenDDTwo.Visible = false;
                    SubmitButton.Visible = false;

                    HiddenDDOne.Items.Clear();
                    populateCardsLeftDropDownList(HiddenDDOne);

                    ChallengeSubmitButton.Visible = true;
                }
                else
                {
                    Response.Redirect("GamePlayPage.aspx");
                }
            }
        }
        private void handleChallengeAssassinate()
        {
            int index = Globals.AssassinatedPlayer.IndexOf(':');
            string playerUsername = Globals.AssassinatedPlayer.Substring(0, index);
            string[] id = Session["New"].ToString().Split(':');

            //if the challenger lost and the challenger was the one being assassinated, and if they have two cards they lose both otherwise they lose the one
            if (playerUsername == PlayerDD.SelectedItem.Text)
            {
                if(Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] == 2) //if they have two cards
                {
                    string card = HiddenDDOne.SelectedItem.Text;
                    string card2 = HiddenDDTwo.SelectedItem.Text;

                    Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 2);

                    //if new number of cards is zero do something to kick them out of the game

                    int playerId = getUserId(playerUsername);
                    insertAction(playerId, "Lose Card", "Lost a " + card + " and a " + card2, id[1]);

                    Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card + " and the " + card2);

                    updateDeadCardCounters(card);
                    updateDeadCardCounters(card2);
                }
                else if (Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] == 1)  //if they only have one card
                {
                    string card = HiddenDDOne.SelectedItem.Text;

                    Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);

                    //if new number of cards is zero do something to kick them out of the game
                    int playerId = getUserId(playerUsername);
                    insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                    Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card);

                    updateDeadCardCounters(card);
                }

                if (playerUsername == id[0]) //if that player was the user, clear their hand
                {
                    Globals.GlobalAnalysis.getCardsInHand().Clear();
                }
            }
            else  //if the challenger lost and the challenger is not the player being assassinated, they both lose one card
            {
                string card = HiddenDDOne.SelectedItem.Text;
                string card2 = HiddenDDTwo.SelectedItem.Text;
                playerUsername = HiddenDDThree.SelectedItem.Text;

                Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);
                Globals.GlobalAnalysis.updatePlayerCardCount(PlayerDD.SelectedItem.Text, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(PlayerDD.SelectedItem.Text)] - 1);

                //if new number of cards is zero do something to kick them out of the game

                int playerIdOne = getUserId(playerUsername);
                insertAction(playerIdOne, "Lose Card", "Lost a " + card, id[1]);

                int playerIdTwo = getUserId(PlayerDD.SelectedItem.Text);
                insertAction(playerIdTwo, "Lose Card", "Lost a " + card2, id[1]);

                Globals.GlobalAnalysis.addActions(playerUsername + ": was Assassinated and lost the " + card2);
                Globals.GlobalAnalysis.addActions(PlayerDD.SelectedItem.Text + ": Lost the " + card);

                if (playerUsername == id[0])
                {
                    Card c = new Card("Duke");
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card2)
                            c = Globals.GlobalAnalysis.getCardsInHand()[i];
                    }
                    Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                }
                else if(PlayerDD.SelectedItem.Text == id[0])
                {
                    Card c = new Card("Duke");
                    for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                    {
                        if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card)
                            c = Globals.GlobalAnalysis.getCardsInHand()[i];
                    }
                    Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                }

                updateDeadCardCounters(card);
                updateDeadCardCounters(card2);
            }

            if (Globals.CorBPlayer == id[0])
            {
                string cardToRemove = "Assassin";

                for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                {
                    if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == cardToRemove)
                        Globals.GlobalAnalysis.getCardsInHand().RemoveAt(i);
                }

                Label1.Text = "What is your new card?";
                HiddenDDOne.Visible = true;
                HiddenDDTwo.Visible = false;
                HiddenDDThree.Visible = false;
                AssassinatedPlayerLB.Visible = false;
                SubmitButton.Visible = false;

                HiddenDDOne.Items.Clear();
                populateCardsLeftDropDownList(HiddenDDOne);

                ChallengeSubmitButton.Visible = true;
            }
            else
            {
                Response.Redirect("GamePlayPage.aspx");
            }
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string[] id = Session["New"].ToString().Split(':');
            if (ActionDD.SelectedItem.Text == "Coup" || ActionDD.SelectedItem.Text == "Assassinate" || ActionDD.SelectedItem.Text.Contains("Challenge"))
            {
                if(ActionDD.SelectedItem.Text == "Challenge Assassinate" && Globals.AssassinatedPlayer.Contains(':'))
                {
                    handleChallengeAssassinate();
                }
                else if(ActionDD.SelectedItem.Text == "Challenge Block Assassination")
                {
                    handleChallengeBlockAssassination();
                }
                else
                {
                    string card = HiddenDDTwo.SelectedItem.Text;
                    string playerUsername = HiddenDDOne.SelectedItem.Text.ToString();
                    Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);
                    //if new number of cards is zero do something to kick them out of the game

                    int playerId = getUserId(playerUsername);
                    insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                    Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card);

                    updateDeadCardCounters(card);

                    if (HiddenDDOne.SelectedItem.Text == id[0])
                    {
                        Card c = new Card("Duke");
                        for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                        {
                            if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == HiddenDDTwo.SelectedItem.Text)
                                c = Globals.GlobalAnalysis.getCardsInHand()[i];
                        }
                        Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                    }
                    if (ActionDD.SelectedItem.Text.Contains("Challenge") && Globals.CorBPlayer == id[0])
                    {
                        string cardToRemove = "";
                        if (ActionDD.SelectedItem.Text == "Challenge Tax")
                            cardToRemove = "Duke";
                        else if (ActionDD.SelectedItem.Text == "Challenge Block Foreign Aid")
                            cardToRemove = "Duke";
                        else if (ActionDD.SelectedItem.Text == "Challenge Exchange")
                            cardToRemove = "Ambassador";
                        //else if (ActionDD.SelectedItem.Text == "Challenge Block Stealing")
                        //either lose Ambassador or Captain
                        else if (ActionDD.SelectedItem.Text == "Challenge Stealing")
                            cardToRemove = "Captain";

                        for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                        {
                            if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == cardToRemove)
                                Globals.GlobalAnalysis.getCardsInHand().RemoveAt(i);
                        }

                        Label1.Text = "What is your new card?";
                        HiddenDDOne.Visible = true;
                        HiddenDDTwo.Visible = false;
                        SubmitButton.Visible = false;

                        HiddenDDOne.Items.Clear();
                        populateCardsLeftDropDownList(HiddenDDOne);

                        ChallengeSubmitButton.Visible = true;
                    }
                    else
                    {
                        Response.Redirect("GamePlayPage.aspx");
                    }
                }

            }
            else if(ActionDD.SelectedItem.Text == "Exchange")
            {
                Globals.GlobalAnalysis.getCardsInHand().Clear();
                Globals.GlobalAnalysis.addCardsToHand(HiddenDDOne.SelectedItem.Text);
                if (HiddenDDTwo.Visible == true)
                    Globals.GlobalAnalysis.addCardsToHand(HiddenDDTwo.SelectedItem.Text);

                Response.Redirect("GamePlayPage.aspx");
            }
        }
        private void handleChallengeAssassinate()
        {
            //int index = Globals.AssassinatedPlayer.IndexOf(':');
            string playerUsername = Globals.AssassinatedPlayer;
            string[] id = Session["New"].ToString().Split(':');
            bool isError = false;
            //if the challenger lost and the challenger was the one being assassinated, and if they have two cards they lose both otherwise they lose the one
            if (playerUsername == PlayerDD.SelectedItem.Text)
            {
                if(Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] == 2) //if they have two cards
                {
                    if ((playerUsername == id[0] && isBothCardsInHand(HiddenDDOne.SelectedItem.Text, HiddenDDTwo.SelectedItem.Text)) || playerUsername != id[0])
                    {
                        string card = HiddenDDOne.SelectedItem.Text;
                        string card2 = HiddenDDTwo.SelectedItem.Text;

                        if (card == card2 && isPossibleToHaveBothCards(card, card2) || card != card2)
                        {
                            Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 2);

                            //if new number of cards is zero do something to kick them out of the game

                            int playerId = getUserId(playerUsername);
                            insertAction(playerId, "Lose Card", "Lost a " + card + " and a " + card2, id[1]);

                            Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card + " and the " + card2);

                            updateDeadCardCounters(card);
                            updateDeadCardCounters(card2);
                        }
                        else
                        {
                            ErrorLabel.Visible = true;
                            ErrorLabel.Text = "It is not possible for this player to get rid of two " + card + "s!";
                            isError = true;
                        }
                    }
                    else
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text = "One or both of thoses cards are not in your hand!";
                        isError = true;
                    }
                }
                else if (Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] == 1)  //if they only have one card
                {
                    if ((playerUsername == id[0] && isCardInHand(HiddenDDOne.SelectedItem.Text)) || playerUsername != id[0])
                    {
                        string card = HiddenDDOne.SelectedItem.Text;

                        Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);

                        //if new number of cards is zero do something to kick them out of the game
                        int playerId = getUserId(playerUsername);
                        insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                        Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card);

                        updateDeadCardCounters(card);
                    }
                    else
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text = "That card is not in your hand!";
                        isError = true;
                    }
                }
                if (!isError)
                {
                    if (playerUsername == id[0]) //if that player was the user, clear their hand
                    {
                        Globals.GlobalAnalysis.getCardsInHand().Clear();
                    }
                    Globals.GlobalAnalysis.getPossibleCard(playerUsername).Clear();
                    Globals.GlobalAnalysis.calculateStatistics();
                }
            }
            else  //if the challenger lost and the challenger is not the player being assassinated, they both lose one card
            {
                string card = HiddenDDOne.SelectedItem.Text;
                string card2 = HiddenDDTwo.SelectedItem.Text;
                playerUsername = HiddenDDThree.SelectedItem.Text;

                if ((playerUsername == id[0] && isCardInHand(card2)) || (PlayerDD.SelectedItem.Text == id[0] && isCardInHand(card)) || (playerUsername != id[0] && PlayerDD.SelectedItem.Text != id[0]))
                {
                    if (card == card2 && isPossibleToHaveBothCards(card, card2) || card != card2)
                    {
                        Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);
                        Globals.GlobalAnalysis.updatePlayerCardCount(PlayerDD.SelectedItem.Text, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(PlayerDD.SelectedItem.Text)] - 1);

                        //if new number of cards is zero do something to kick them out of the game

                        int playerIdOne = getUserId(playerUsername);
                        insertAction(playerIdOne, "Lose Card", "Lost a " + card2, id[1]);

                        int playerIdTwo = getUserId(PlayerDD.SelectedItem.Text);
                        insertAction(playerIdTwo, "Lose Card", "Lost a " + card, id[1]);

                        Globals.GlobalAnalysis.addActions(playerUsername + ": was Assassinated and lost the " + card2);
                        Globals.GlobalAnalysis.addActions(PlayerDD.SelectedItem.Text + ": Lost the " + card);

                        if (playerUsername == id[0])
                        {
                            Card c = new Card("Duke");
                            for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                            {
                                if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card2)
                                    c = Globals.GlobalAnalysis.getCardsInHand()[i];
                            }
                            Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                        }
                        else if (PlayerDD.SelectedItem.Text == id[0])
                        {
                            Card c = new Card("Duke");
                            for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                            {
                                if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == card)
                                    c = Globals.GlobalAnalysis.getCardsInHand()[i];
                            }
                            Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                        }

                        for (int i = 0; i < Globals.GlobalAnalysis.getPossibleCard(playerUsername).Count; i++)
                        {
                            if (Globals.GlobalAnalysis.getPossibleCard(playerUsername)[i].T == card)
                            {
                                Globals.GlobalAnalysis.getPossibleCard(playerUsername).RemoveAt(i);
                                break;
                            }
                        }
                        for (int i = 0; i < Globals.GlobalAnalysis.getPossibleCard(PlayerDD.SelectedItem.Text).Count; i++)
                        {
                            if (Globals.GlobalAnalysis.getPossibleCard(PlayerDD.SelectedItem.Text)[i].T == card2)
                            {
                                Globals.GlobalAnalysis.getPossibleCard(PlayerDD.SelectedItem.Text).RemoveAt(i);
                                break;
                            }
                        }
                        Globals.GlobalAnalysis.calculateStatistics();

                        updateDeadCardCounters(card);
                        updateDeadCardCounters(card2);
                    }
                    else
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text = "It is not possible for both to lose the " + card + "!";
                        isError = true;
                    }
                }
                else
                {
                    ErrorLabel.Visible = true;
                    ErrorLabel.Text = "That card is not in your hand!";
                    isError = true;
                }
            }

            if (Globals.CorBPlayer == id[0])
            {
                string cardToRemove = "Assassin";

                for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                {
                    if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == cardToRemove)
                        Globals.GlobalAnalysis.getCardsInHand().RemoveAt(i);
                }

                Label1.Text = "What is your new card?";
                HiddenDDOne.Visible = true;
                HiddenDDTwo.Visible = false;
                HiddenDDThree.Visible = false;
                AssassinatedPlayerLB.Visible = false;
                SubmitButton.Visible = false;

                HiddenDDOne.Items.Clear();
                populateCardsLeftDropDownList(HiddenDDOne);

                ChallengeSubmitButton.Visible = true;
            }
            else
            {
                if(!isError)
                    Response.Redirect("GamePlayPage.aspx");
            }
        }
 protected void SubmitChallengeBlockSteal_Click(object sender, EventArgs e)
 {
     //replace HiddenDDOne with HiddenDDThree
     foreach(Card c in Globals.GlobalAnalysis.getCardsInHand())
     {
         if(c.getCardType() == HiddenDDOne.SelectedItem.Text)
         {
             Card card = new Card(HiddenDDThree.SelectedItem.Text);
             Globals.GlobalAnalysis.getCardsInHand()[Globals.GlobalAnalysis.getCardsInHand().IndexOf(c)] = card;
             break;
         }
     }
     Response.Redirect("GamePlayPage.aspx");
 }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string[] id = Session["New"].ToString().Split(':');
            ErrorLabel.Visible = false;
            if (ActionDD.SelectedItem.Text == "Coup" || ActionDD.SelectedItem.Text == "Assassinate" || ActionDD.SelectedItem.Text.Contains("Challenge"))
            {
                if(ActionDD.SelectedItem.Text == "Challenge Assassinate" && Globals.ChallengeStatus == "Lost")
                {
                    handleChallengeAssassinate();
                }
                else if(ActionDD.SelectedItem.Text == "Challenge Block Assassination")
                {
                    handleChallengeBlockAssassination();
                }
                else if(ActionDD.SelectedItem.Text == "Challenge Exchange" && Globals.ChallengeStatus == "Lost")
                {
                    string card = HiddenDDOne.SelectedItem.Text;
                    string playerUsername = PlayerDD.SelectedItem.Text;
                    Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);

                    int playerId = getUserId(playerUsername);
                    insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                    Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card);

                    if (!playerUsername.Contains(id[0]))
                    {
                        for (int i = 0; i < Globals.GlobalAnalysis.getPossibleCard(playerUsername).Count; i++)
                        {
                            if (Globals.GlobalAnalysis.getPossibleCard(playerUsername)[i].T == card)
                            {
                                Globals.GlobalAnalysis.getPossibleCard(playerUsername).RemoveAt(i);
                                break;
                            }
                        }
                        Globals.GlobalAnalysis.calculateStatistics();
                    }

                    updateDeadCardCounters(card);

                    if (Globals.CorBPlayer == id[0])
                    {
                        Globals.GlobalAnalysis.getCardsInHand().Clear();
                        Globals.GlobalAnalysis.addCardsToHand(HiddenDDThree.SelectedItem.Text);
                        if (HiddenDDTwo.Visible == true)
                            Globals.GlobalAnalysis.addCardsToHand(HiddenDDTwo.SelectedItem.Text);
                    }
                    if(playerUsername == id[0])
                    {
                        foreach(Card c in Globals.GlobalAnalysis.getCardsInHand())
                        {
                            if(c.getCardType() == card)
                            {
                                Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                                break;
                            }
                        }
                    }
                    Response.Redirect("GamePlayPage.aspx");
                }
                else
                {
                    if (HiddenDDOne.SelectedItem.Text == id[0] && isCardInHand(HiddenDDTwo.SelectedItem.Text) || HiddenDDOne.SelectedItem.Text != id[0])
                    {
                        string card = HiddenDDTwo.SelectedItem.Text;
                        string playerUsername = HiddenDDOne.SelectedItem.Text.ToString();
                        Globals.GlobalAnalysis.updatePlayerCardCount(playerUsername, Globals.GlobalAnalysis.getPlayerCardCounts()[Globals.GlobalAnalysis.getPlayerUsernames().IndexOf(playerUsername)] - 1);
                        //if new number of cards is zero do something to kick them out of the game

                        int playerId = getUserId(playerUsername);
                        insertAction(playerId, "Lose Card", "Lost a " + card, id[1]);

                        Globals.GlobalAnalysis.addActions(playerUsername + ": Lost the " + card);

                        if (ActionDD.SelectedItem.Text.Contains("Challenge") && Globals.ChallengeStatus == "Lost" && Globals.CorBPlayer != id[0])
                        {
                            Globals.GlobalAnalysis.addActions(Globals.CorBPlayer + ": Gets new card");
                        }

                        if (!playerUsername.Contains(id[0]))
                        {
                            for (int i = 0; i < Globals.GlobalAnalysis.getPossibleCard(playerUsername).Count; i++)
                            {
                                if (Globals.GlobalAnalysis.getPossibleCard(playerUsername)[i].T == card)
                                {
                                    Globals.GlobalAnalysis.getPossibleCard(playerUsername).RemoveAt(i);
                                    break;
                                }
                            }

                            if (ActionDD.SelectedItem.Text.Contains("Challenge") && Globals.ChallengeStatus == "Lost")
                            {
                                for (int i = 0; i < Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).Count; i++)
                                {
                                    if (ActionDD.SelectedItem.Text == "Challenge Tax" && Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer)[i].T == "Duke")
                                    {
                                        Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).RemoveAt(i);
                                        break;
                                    }
                                    else if (ActionDD.SelectedItem.Text == "Challenge Block Foreign Aid" && Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer)[i].T == "Duke")
                                    {
                                        Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).RemoveAt(i);
                                        break;
                                    }
                                    else if (ActionDD.SelectedItem.Text == "Challenge Stealing" && Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer)[i].T == "Captain")
                                    {
                                        Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).RemoveAt(i);
                                        break;
                                    }
                                    else if (ActionDD.SelectedItem.Text == "Challenge Exchange")
                                    {
                                        Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).Clear();
                                        break;
                                    }
                                    else if (ActionDD.SelectedItem.Text == "Challenge Block Stealing")
                                    {
                                        if (Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer)[i].T == "Captain" && Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer)[i].B)
                                        {
                                            Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).RemoveAt(i); //remove captain
                                            Globals.GlobalAnalysis.getPossibleCard(Globals.CorBPlayer).RemoveAt(i); //remove ambassador both of which were added becuase the player blocked a steal
                                            break;
                                        }
                                    }
                                }
                            }
                            Globals.GlobalAnalysis.calculateStatistics();
                        }

                        updateDeadCardCounters(card);

                        if (HiddenDDOne.SelectedItem.Text == id[0])
                        {
                            Card c = new Card("Duke");
                            for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                            {
                                if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == HiddenDDTwo.SelectedItem.Text)
                                    c = Globals.GlobalAnalysis.getCardsInHand()[i];
                            }
                            Globals.GlobalAnalysis.getCardsInHand().Remove(c);
                        }
                        if (ActionDD.SelectedItem.Text.Contains("Challenge") && Globals.CorBPlayer == id[0] && Globals.ChallengeStatus == "Lost")
                        {
                            string cardToRemove = "";
                            if (ActionDD.SelectedItem.Text == "Challenge Tax")
                                cardToRemove = "Duke";
                            else if (ActionDD.SelectedItem.Text == "Challenge Block Foreign Aid")
                                cardToRemove = "Duke";
                            else if (ActionDD.SelectedItem.Text == "Challenge Exchange")
                                cardToRemove = "Ambassador";
                            else if (ActionDD.SelectedItem.Text == "Challenge Block Stealing")
                            {//what to do if player has both ambassador and captain
                                Label1.Text = "What Card did you swap out?";
                                HiddenDDOne.Items.Clear();
                                HiddenDDOne.Items.Add("Captain");
                                HiddenDDOne.Items.Add("Ambassador");

                                SubmitButton.Visible = false;
                                AssassinatedPlayerLB.Visible = true;
                                AssassinatedPlayerLB.Text = "What is your new card?";
                                HiddenDDThree.Visible = true;
                                HiddenDDTwo.Visible = false;
                                HiddenDDThree.Items.Clear();
                                populateCardsLeftDropDownList(HiddenDDThree);

                                SubmitChallengeBlockSteal.Visible = true;
                            }
                            else if (ActionDD.SelectedItem.Text == "Challenge Stealing")
                                cardToRemove = "Captain";
                            else if (ActionDD.SelectedItem.Text == "Challenge Assassinate")
                                cardToRemove = "Assassin";

                            if (ActionDD.SelectedItem.Text != "Challenge Block Stealing")
                            {
                                for (int i = 0; i < Globals.GlobalAnalysis.getCardsInHand().Count; i++)
                                {
                                    if (Globals.GlobalAnalysis.getCardsInHand()[i].getCardType() == cardToRemove)
                                        Globals.GlobalAnalysis.getCardsInHand().RemoveAt(i);
                                }

                                Label1.Text = "What is your new card?";
                                HiddenDDOne.Visible = true;
                                HiddenDDTwo.Visible = false;
                                SubmitButton.Visible = false;

                                HiddenDDOne.Items.Clear();
                                populateCardsLeftDropDownList(HiddenDDOne);

                                ChallengeSubmitButton.Visible = true;
                            }
                        }
                        else
                        {
                            Response.Redirect("GamePlayPage.aspx");
                        }
                    }
                    else
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text = "That Card is not in your hand!";
                    }
                }
            }
            else if(ActionDD.SelectedItem.Text == "Exchange")
            {
                Globals.GlobalAnalysis.getCardsInHand().Clear();
                Globals.GlobalAnalysis.addCardsToHand(HiddenDDOne.SelectedItem.Text);
                if (HiddenDDTwo.Visible == true)
                    Globals.GlobalAnalysis.addCardsToHand(HiddenDDTwo.SelectedItem.Text);

                Response.Redirect("GamePlayPage.aspx");
            }
        }