public void GetCurrentPlayer1Test() { // Act (execute the method under test) string player = game.GetCurrentPlayer(); // Assert (check the result) Assert.Equal(PLAYER1, player); }
void UpdateWhosTurn() { // set turn points in UI if (game.CheckForWinner().Length > 0) { // game is over return; } FindViewById <TextView>(Resource.Id.TurnLabel).Text = game.GetCurrentPlayer() + "'s turn"; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); View view = inflater.Inflate(Resource.Layout.Fragment2, container, false); int roll = 0; var textViewPlayer1 = view.FindViewById <TextView>(Resource.Id.textPlayer1Actual); var textViewPlayer2 = view.FindViewById <TextView>(Resource.Id.textPlayer2Actual); var textViewPlayersTurn = view.FindViewById <TextView>(Resource.Id.textViewPlayersTurn); if (savedInstanceState == null) { game = new PigLogic(); SetPlayersName("player1", "player2"); } //SetPlayersName(); /*if (Arguments != null) * { * game.Player1Name = Arguments.GetString("player1name"); * game.Player2Name = Arguments.GetString("player2name"); * }*/ textViewPlayersTurn.Text = game.Player1Name + "'s Turn"; textViewPlayer1.Text = game.Player1Name; textViewPlayer2.Text = game.Player2Name; var buttonRollDie = view.FindViewById <Button>(Resource.Id.buttonRollDie); var textViewPoint4ThisTurn = view.FindViewById <TextView>(Resource.Id.textViewPoint4ThisTurn); var imageViewDie = view.FindViewById <ImageView>(Resource.Id.imageViewDie); var textViewPlayer1Score = view.FindViewById <TextView>(Resource.Id.textViewPlayer1Score); var textViewPlayer2Score = view.FindViewById <TextView>(Resource.Id.textViewPlayer2Score); DisplayScores(textViewPlayer1Score, textViewPlayer2Score, textViewPlayersTurn); DisplayTurnScore(roll, textViewPoint4ThisTurn, imageViewDie); buttonRollDie.Click += delegate { roll = game.RollDie(); DisplayTurnScore(roll, textViewPoint4ThisTurn, imageViewDie); //when the roll is a bad number, it changes turn with giving 0 score to current player. if (roll == PigLogic.BAD_NUMBER) { game.ChangeTurn(); DisplayScores(textViewPlayer1Score, textViewPlayer2Score, textViewPlayersTurn); Android.Widget.Toast.MakeText(Activity, game.GetCurrentPlayer() + " rolled 0! Turn changed", Android.Widget.ToastLength.Short).Show(); // Check whether points are same or over the point's limit // only after both player's playing same amount of rolling if (game.Turn == 1) { if (game.CheckForWinner() != "") { CheckWinner(); ResetGame(); } } } }; var buttonEndTurn = view.FindViewById <Button>(Resource.Id.buttonEndTurn); buttonEndTurn.Click += delegate { game.ChangeTurn(); DisplayScores(textViewPlayer1Score, textViewPlayer2Score, textViewPlayersTurn); DisplayTurnScore(roll, textViewPoint4ThisTurn, imageViewDie); // Check whether points are same or over the point's limit // only after both player's playing same amount of rolling if (game.Turn == 1) { if (game.CheckForWinner() != "") { CheckWinner(); ResetGame(); } } }; var buttonNewGame = view.FindViewById <Button>(Resource.Id.buttonNewGame); buttonNewGame.Click += delegate { ResetGame(); }; return(view); //return base.OnCreateView(inflater, container, savedInstanceState); }