public static void massCapture(Player Winner, Player Loser, int cardsCapt, int counter) { for (int i = 0; i <= cardsCapt; i++) { SingleCapture.captureCards(Winner, Loser, counter + i); } }
public static void AddImage(Player Player, int counter, Default page) { Image myImage = new Image(); myImage.ImageUrl = "Images/" + Player.CardsOwned[counter].CardNumber + Player.CardsOwned[counter].CardType + ".png"; myImage.Visible = true; page.Controls.Add(myImage); }
public static void captureCards(Player Winner, Player Loser, int counter) { Winner.CardsOwned.Add(Winner.CardsOwnedMaxIndex, new Card(Winner.CardsOwned[counter].CardNumber, Winner.CardsOwned[counter].CardType)); Winner.CardsOwnedMaxIndex++; Winner.CardsOwned.Remove(counter); Winner.CardsOwned.Add(Winner.CardsOwnedMaxIndex, new Card(Loser.CardsOwned[counter].CardNumber, Loser.CardsOwned[counter].CardType)); Winner.CardsOwnedMaxIndex++; Loser.CardsOwned.Remove(counter); }
public static void normalCombat(Player Player1, Player Player2, Player Winner, Player Loser, int counter, Default page) { MakeImage.AddImage(Player1, counter, page); MakeLabel.AddLabel(String.Format("{0} vs {1}", Player1.Name, Player2.Name), page); MakeImage.AddImage(Player2, counter, page); MakeLabel.AddLabel(String.Format("{0} has captured {1}'s unit!</br>", Winner.Name, Loser.Name), page); SingleCapture.captureCards(Winner, Loser, counter); }
public static void ClarifyCards(Player Player) { int cycle = 0; foreach (double deckCardNumber in Player.CardsAssigned) { string cardType = CardAssigner.DetermineCard(deckCardNumber); int cardNumber = (int)CardAssigner.DetermineCardNumber(deckCardNumber); Player.CardsOwned.Add(cycle, new Card(cardNumber, cardType)); cycle++; } }
public static void DeckAssign(Player Player1, Player Player2, Random Randomizer) { for (int i = 1; i < 53; i++) {StandardDeck.Add(i);} StandardDeck = StandardDeck.OrderBy(item => Randomizer.Next()).ToList(); int tracker = StandardDeck.Count(); while (tracker > 0 && Player1.CardsAssigned.Count() < 26) { Player1.CardsAssigned.Add(StandardDeck[tracker - 1]); tracker--; Player2.CardsAssigned.Add(StandardDeck[tracker - 1]); tracker--; } }
protected void warButton_Click(object sender, EventArgs e) { Random Randomizer = new Random(); Player Player1 = new Player("Chris"); Player Player2 = new Player("Reality"); DeckAssigner.DeckAssign(Player1, Player2, Randomizer); DeckFinalizer.ClarifyCards(Player1); DeckFinalizer.ClarifyCards(Player2); int counter = 0; int cardsCapt = 0; while ((Player1.CardsOwned.Count() > 0 && Player2.CardsOwned.Count() > 0) && counter < 5000) { cardsCapt = 1; if (Player1.CardsOwned[counter].CardNumber == Player2.CardsOwned[counter].CardNumber) { if (Player1.CardsOwned.Count() > 4 && Player2.CardsOwned.Count() > 4) { cardsCapt = 0; counter += WarCombat.warCombat(Player1, Player2, this, counter, cardsCapt); } else { MakeLabel.AddLabel("</br>", this); MakeImage.AddImage(Player1, counter, this); MakeLabel.AddLabel(String.Format(" {0} vs {1} ", Player1.Name, Player2.Name), this); MakeImage.AddImage(Player2, counter, this); MakeLabel.AddLabel(String.Format("{0} and {1} are locked in a heated battle. THIS IS WAR!!</br>", Player1.Name, Player2.Name), this); MakeLabel.AddLabel("But someone ran out of cards!", this); counter = 10000000; } } else if (Player1.CardsOwned[counter].CardNumber > Player2.CardsOwned[counter].CardNumber) { NormalCombat.normalCombat(Player1, Player2, Player1, Player2, counter, this); } else if (Player1.CardsOwned[counter].CardNumber < Player2.CardsOwned[counter].CardNumber) { NormalCombat.normalCombat(Player1, Player2, Player2, Player1, counter, this); } counter++; } resultLabel.Text = String.Format("</br> game has ended {2} has {0} cards and {3} has {1} cards!", Player1.CardsOwned.Count(), Player2.CardsOwned.Count(), Player1.Name, Player2.Name); if (Player1.CardsOwned.Count() > Player2.CardsOwned.Count()) resultLabel.Text += String.Format("{0} Wins!", Player1.Name); else if (Player2.CardsOwned.Count() > Player1.CardsOwned.Count()) resultLabel.Text += String.Format("{0} Wins!", Player2.Name); else if (Player1.CardsOwned.Count() == Player2.CardsOwned.Count()) resultLabel.Text += String.Format("The game has ended in a tie .... what randomness"); }
public static int warCombat(Player Player1, Player Player2, Default page, int counter, int cardsCapt) { MakeLabel.AddLabel("</br>", page); MakeImage.AddImage(Player1, (counter + cardsCapt), page); MakeLabel.AddLabel(String.Format(" {0} vs {1} ", Player1.Name, Player2.Name), page); MakeImage.AddImage(Player2, (counter + cardsCapt), page); MakeLabel.AddLabel(String.Format("{0} and {1} are locked in a heated battle. THIS IS WAR!!</br>", Player1.Name, Player2.Name), page); MakeLabel.AddLabel(String.Format("{0}'s at stake pool:", Player1.Name), page); MakeImage.AddImage(Player1, (counter + 1 + cardsCapt), page); MakeImage.AddImage(Player1, (counter + 2 + cardsCapt), page); MakeImage.AddImage(Player1, (counter + 3 + cardsCapt), page); MakeLabel.AddLabel(String.Format("</br>{0}'s at stake pool:", Player2.Name), page); MakeImage.AddImage(Player2, (counter + 1 + cardsCapt), page); MakeImage.AddImage(Player2, (counter + 2 + cardsCapt), page); MakeImage.AddImage(Player2, (counter + 3 + cardsCapt), page); cardsCapt += 4; if (Player1.CardsOwned[counter + cardsCapt].CardNumber == Player2.CardsOwned[counter + cardsCapt].CardNumber) { if (((Player1.CardsOwned.Count() + 4) > (8 + cardsCapt)) && (Player2.CardsOwned.Count() + 4) > (8 + cardsCapt)) { cardsCapt = warCombat(Player1, Player2, page, counter, cardsCapt); } else { MakeLabel.AddLabel("</br>", page); MakeImage.AddImage(Player1, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format(" {0} vs {1} ", Player1.Name, Player2.Name), page); MakeImage.AddImage(Player2, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format("{0} and {1} continue their stalemate. THE WAR RAGES ON!!</br>", Player1.Name, Player2.Name), page); MakeLabel.AddLabel("But someone ran out of cards!", page); cardsCapt = 10000000; } } else if (Player1.CardsOwned[counter + cardsCapt].CardNumber > Player2.CardsOwned[counter + cardsCapt].CardNumber) { MakeLabel.AddLabel("</br>", page); MakeImage.AddImage(Player1, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format(" {0} vs {1} ", Player1.Name, Player2.Name), page); MakeImage.AddImage(Player2, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format("{0} captured {1}'s unit and won the war!!!</br>", Player1.Name, Player2.Name), page); MassCapture.massCapture(Player1, Player2, cardsCapt, counter); } else if (Player1.CardsOwned[counter + cardsCapt].CardNumber < Player2.CardsOwned[counter + cardsCapt].CardNumber) { MakeLabel.AddLabel("</br>", page); MakeImage.AddImage(Player1, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format(" {0} vs {1} ", Player1.Name, Player2.Name), page); MakeImage.AddImage(Player2, counter + cardsCapt, page); MakeLabel.AddLabel(String.Format("{0} captured {1}'s unit and won the war!!!</br>", Player2.Name, Player1.Name), page); MassCapture.massCapture(Player2, Player1, cardsCapt, counter); } return cardsCapt; }