private void yesButton_Click(object sender, RoutedEventArgs e) { if (counter == numWinners) { return; } ((Player)allPlayers[(int)winners[counter]]).balance += ((MusicalChairsTokenPage.gameBalances[(int)winners[0]] - 100000) / 2); GameIO.save(allPlayers, 0); counter++; string output = ""; if (counter < numWinners) { idLabel.Content = ((Player)allPlayers[(int)winners[counter]]).id.ToString(); nameLabel.Content = ((Player)allPlayers[(int)winners[counter]]).firstName + " " + ((Player)allPlayers[(int)winners[counter]]).lastName; output += "+ " + MusicalChairsTokenPage.gameBalances[(int)winners[counter]].ToString("F") + "\n"; output += "- 100000.00\n"; output += "- " + ((MusicalChairsTokenPage.gameBalances[(int)winners[counter]] - 100000) / 2).ToString("F") + "\n\n"; output += " " + ((MusicalChairsTokenPage.gameBalances[(int)winners[counter]] - 100000) / 2).ToString("F"); balancePreviewDynamicLabel.Content = output; } else { balancePreviewDynamicLabel.Content = ""; doneLabel.Content = "DONE"; idLabel.Content = ""; nameLabel.Content = ""; balancePreviewLabel.Content = ""; balancePreviewLabel_Copy2.Content = ""; balancePreviewLabel_Copy.Content = ""; } }
public AllPlayerDataForm() { InitializeComponent(); // allPlayerDataGrid.ItemsSource = gridSource; ArrayList allPlayers = GameIO.load(0); for (int i = 0; i < GameIO.numPlayers; i++) { //allPlayerDataGrid.Items.Add(new PlayerGrid(){ idCol = allPlayers[i].id, firstNameCol = allPlayers[i].firstName, lastNamecol = allPlayers[i].lastName, balanceCol = allPlayers[i].balance}); gridSourceIDSort.Add(new PlayerGrid() { ID = ((Player)allPlayers[i]).id, First_Name = ((Player)allPlayers[i]).firstName, Last_Name = ((Player)allPlayers[i]).lastName, Balance = ((Player)allPlayers[i]).balance }); } allPlayerDataGrid.ItemsSource = gridSourceIDSort; allPlayers.Sort(0, GameIO.numPlayers, new PlayerComparer()); for (int i = 0; i < GameIO.numPlayers; i++) { //allPlayerDataGrid.Items.Add(new PlayerGrid(){ idCol = allPlayers[i].id, firstNameCol = allPlayers[i].firstName, lastNamecol = allPlayers[i].lastName, balanceCol = allPlayers[i].balance}); gridSourceBalanceSort.Add(new PlayerGrid() { ID = ((Player)allPlayers[i]).id, First_Name = ((Player)allPlayers[i]).firstName, Last_Name = ((Player)allPlayers[i]).lastName, Balance = ((Player)allPlayers[i]).balance }); } }
public PandemicGame() { InitializeComponent(); allPlayersAsGame1 = GameIO.load(1); int numYes = 0; int numNo = 0; for (int i = 0; i < GameIO.numPlayers; i++) { if (Game1Form.playerVotes[i] == true) { numYes++; } else { numNo++; } } Boolean minority; if (numYes > numNo) { minority = false; } else if (numYes < numNo) { minority = true; } else { minority = false; } for (int i = 0; i < GameIO.numPlayers; i++) { if (Game1Form.playerVotes[i] == minority) { ((Game1)allPlayersAsGame1[i]).isInfected = false; ((Game1)allPlayersAsGame1[i]).vaccines = Game1Form.numVaccines; } else { ((Game1)allPlayersAsGame1[i]).isInfected = true; } } for (int i = 0; i < GameIO.numPlayers; i++) { for (int j = 0; j < GameIO.numPlayers; j++) { hasConnected[i, j] = false; } } for (int i = 0; i < GameIO.numPlayers; i++) { gotVictoryPoint[i] = false; } }
private void nextButton_Click(object sender, RoutedEventArgs e) { GameIO.game2Round++; CPass.saveCPasses(cpasses); GameIO.save(allPlayersAsGame2, 2); MusicalChairsResultsPage page = new MusicalChairsResultsPage(); this.Content = page; }
private void nextRoundButton_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < GameIO.numPlayers; i++) { Game1 temp = (Game1)allPlayersAsGame1[i]; if ((temp.vaccines >= 3 && temp.isInfected == false) || (temp.vaccines >= 4 && temp.isInfected == true)) { temp.victoryPoints++; gotVictoryPoint[i] = true; } } GameIO.save(allPlayersAsGame1, 1); PandemicGameVictoryPointsAfterRepeat form = new PandemicGameVictoryPointsAfterRepeat(); Game1Form win = (Game1Form)Window.GetWindow(this); win.Content = form; }
public MusicalChairsTransferPointsPage() { InitializeComponent(); for (int i = 0; i < GameIO.numPlayers; i++) { if (MusicalChairsTokenPage.gameBalances[i] > 100000) { winners.Add(i); numWinners++; } else { Player temp = (Player)allPlayers[i]; Player.editBalance(ref temp, -100000 + MusicalChairsTokenPage.gameBalances[i]); } } GameIO.save(allPlayers, 0); string output = ""; if (numWinners > 0) { idLabel.Content = ((Player)allPlayers[(int)winners[0]]).id.ToString(); nameLabel.Content = ((Player)allPlayers[(int)winners[0]]).firstName + " " + ((Player)allPlayers[(int)winners[0]]).lastName; output += "+ " + MusicalChairsTokenPage.gameBalances[(int)winners[0]].ToString("F") + "\n"; output += "- 100000.00\n"; output += "- " + ((MusicalChairsTokenPage.gameBalances[(int)winners[0]] - 100000) / 2).ToString("F") + "\n\n"; output += " " + ((MusicalChairsTokenPage.gameBalances[(int)winners[0]] - 100000) / 2).ToString("F"); balancePreviewDynamicLabel.Content = output; } else { balancePreviewDynamicLabel.Content = ""; doneLabel.Content = "DONE"; idLabel.Content = ""; nameLabel.Content = ""; balancePreviewLabel.Content = ""; balancePreviewLabel_Copy2.Content = ""; balancePreviewLabel_Copy.Content = ""; } }
public TransferToPersonalBankAfterPandemicGame() { InitializeComponent(); for (int i = 0; i < GameIO.numPlayers; i++) { if (((Game1)PandemicGameVictoryPointsAfterFinish.allPlayersAsGame1[i]).gameBalance > 100000) { winningPlayers.Add(PandemicGameVictoryPointsAfterFinish.allPlayersAsGame1[i]); numWinners++; } else { ((Game1)PandemicGameVictoryPointsAfterFinish.allPlayersAsGame1[i]).gameBalance -= 100000.00; Player temp = (Player)allPlayers[i]; Player.editBalance(ref temp, ((Game1)PandemicGameVictoryPointsAfterFinish.allPlayersAsGame1[i]).gameBalance); } } GameIO.save(allPlayers, 0); string output = ""; if (numWinners > 0) { idLabel.Content = ((Player)allPlayers[((Game1)winningPlayers[0]).id - 1]).id.ToString(); nameLabel.Content = ((Player)allPlayers[((Game1)winningPlayers[0]).id - 1]).firstName + " " + ((Player)allPlayers[((Game1)winningPlayers[0]).id - 1]).lastName; output += "+ " + ((Game1)winningPlayers[0]).gameBalance.ToString("F") + "\n"; output += "- 100000.00\n"; output += "- " + ((((Game1)winningPlayers[0]).gameBalance - 100000) / 2).ToString("F") + "\n\n"; output += " " + ((((Game1)winningPlayers[0]).gameBalance - 100000) / 2).ToString("F"); balancePreviewDynamicLabel.Content = output; } else { balancePreviewDynamicLabel.Content = ""; doneLabel.Content = "DONE"; idLabel.Content = ""; nameLabel.Content = ""; balancePreviewLabel.Content = ""; balancePreviewLabel_Copy2.Content = ""; balancePreviewLabel_Copy.Content = ""; } }
public PandemicGameVictoryPointsAfterRepeat() { InitializeComponent(); string results = ""; ArrayList allPlayers = GameIO.load(0); for (int i = 0; i < GameIO.numPlayers; i++) { Player temp = (Player)allPlayers[i]; if (((Game1)PandemicGame.allPlayersAsGame1[i]).isInfected == true) { results += "-" + temp.firstName + " " + temp.lastName + " - INFECTED - " + ((Game1)PandemicGame.allPlayersAsGame1[i]).vaccines + "\n"; } else { results += "-" + temp.firstName + " " + temp.lastName + " - NORMAL - " + ((Game1)PandemicGame.allPlayersAsGame1[i]).vaccines + "\n"; } } listOfWinners.Content = results; }
public PandemicGameVictoryPointsAfterFinish() { InitializeComponent(); string winners = ""; ArrayList allPlayers = GameIO.load(0); int totalVictoryPoints = 0; double prizePool = 100000 * GameIO.numPlayers; //get total number of victory points for (int j = 0; j < GameIO.numPlayers; j++) { Game1 temp = (Game1)allPlayersAsGame1[j]; totalVictoryPoints += temp.victoryPoints; } //award money to each player from prize pool according to victory points for (int k = 0; k < GameIO.numPlayers; k++) { Game1 temp = (Game1)allPlayersAsGame1[k]; if (temp.victoryPoints > 0) { double percentage = (double)temp.victoryPoints / (double)totalVictoryPoints; temp.gameBalance += percentage * prizePool; temp.gameBalance = Math.Round(temp.gameBalance, 2); } } for (int p = 0; p < GameIO.numPlayers; p++) { Game1 temp = (Game1)allPlayersAsGame1[p]; Player temp2 = (Player)allPlayers[p]; if (temp.gameBalance > 0) { winners += "-" + temp2.firstName + " " + temp2.lastName + " +" + temp.victoryPoints.ToString() + "VP" + " (+" + temp.gameBalance.ToString("F") + " Pts)" + "\n"; } } listOfWinners.Content = winners; }
//edits the two players' balances accordingly and DOES relay edits to master folder public static Boolean transferCurrency(int srcID, int destID, double value) { ArrayList allPlayers = GameIO.load(0); Player src; Player dest; if (srcID == 0) { src = (Player)allPlayers[GameIO.numPlayers]; } else { src = (Player)allPlayers[srcID - 1]; } if (destID == 0) { dest = (Player)allPlayers[GameIO.numPlayers]; } else { dest = (Player)allPlayers[destID - 1]; } if (src.balance < value) { //not enough funds to transfer return(false); } //make changes to balance accordingly src.balance -= value; dest.balance += value; //save src and dest changes to master folder return(GameIO.save(allPlayers, 0)); }
public DataForm() { InitializeComponent(); allPlayers = GameIO.load(0); }
public MusicalChairsResultsPage() { InitializeComponent(); minoritygametitle.Content = "-Musical Chairs Round " + (GameIO.game2Round - 1).ToString() + " Results-"; eliminatedPlayers.Content = ""; Boolean[] affectedThisRound = new Boolean[GameIO.numPlayers]; for (int i = 0; i < GameIO.numPlayers; i++) { affectedThisRound[i] = false; } int numLostALife = 0; int numLostTwoLives = 0; for (int i = 0; i < GameIO.numPlayers; i++) { Game2 temp = (Game2)Game2Form.allPlayersAsGame2[i]; Player temp2 = (Player)allPlayers[i]; if (temp.didSit == false) { temp.currentCPassID = 0; temp.prevCPassID = 0; affectedThisRound[i] = true; temp.isEliminated++; } } for (int j = 0; j < GameIO.numPlayers; j++) { Game2 temp = (Game2)Game2Form.allPlayersAsGame2[j]; Player temp2 = (Player)allPlayers[j]; if (temp.isEliminated == 1 && affectedThisRound[j]) { numLostALife++; eliminatedPlayers.Content += "-" + temp2.firstName + " " + temp2.lastName + "\n"; } } if (numLostALife == 1) { eliminatedPlayers.Content += "has lost a life.\n"; } else if (numLostALife > 1) { eliminatedPlayers.Content += "have each lost a life.\n"; } for (int k = 0; k < GameIO.numPlayers; k++) { Game2 temp = (Game2)Game2Form.allPlayersAsGame2[k]; Player temp2 = (Player)allPlayers[k]; if (temp.isEliminated == 2 && affectedThisRound[k]) { numLostTwoLives++; eliminatedPlayers.Content += "-" + temp2.firstName + " " + temp2.lastName + "\n"; } } if (numLostTwoLives == 1) { eliminatedPlayers.Content += "has been eliminated."; } else if (numLostTwoLives > 1) { eliminatedPlayers.Content += "have been eliminated."; } if (numLostALife == 0 && numLostTwoLives == 0) { eliminatedPlayers.Content += "No players have lost any lives."; } GameIO.save(Game2Form.allPlayersAsGame2, 2); }