/** Changes all the textviews so they have the updated text */ private void setText() { guessedView.setText(game.guessedString()); guessesView.setText(game.guessesString()); wordView.setText(game.wordString()); setImage(); }
/** * Tests if the game has ended. It tests if you have lost or you won and you can continue to the * next word. It gives the message to the user with a dialog. */ public void gameEnd() { // the player has no guesses left and lost if (game.leftGuesses == 0) { AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this); end.setTitle(R.string.gameover); end.setMessage(getResources().getString(R.string.end) + game.word); end.setPositiveButton( R.string.end_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(GameActivity.this, HighscoreActivity.class); intent.putExtra("gamescore", game.score); intent.putExtra("wordlength", game.setLength); if (evilType) { intent.putExtra("gametype", "evil"); } else { intent.putExtra("gametype", "good"); } startActivity(intent); finish(); } }); // he must go to the highscorescreen end.setCancelable(false); end.create(); end.show(); // All the letters of the word have been guessed } else if (game.wordString().indexOf("-") < 0) { // The player gets a point game.addScore(1); AlertDialog.Builder end = new AlertDialog.Builder(GameActivity.this); end.setTitle(R.string.guessed); end.setMessage(getResources().getString(R.string.guess_end) + game.word); end.setPositiveButton( R.string.next_word, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { nextWord(); } }); // The player must go to the next word end.setCancelable(false); end.create(); end.show(); } }