Commit ccdb503d authored by Arnaud B.'s avatar Arnaud B.

Rename enum members.

parent a0ce2fa5
Pipeline #139146 passed with stage
in 2 minutes and 2 seconds
......@@ -51,7 +51,7 @@ private class FourInARow : Gtk.Application
// game status
private bool gameover = true;
private PlayerID player = PlayerID.PLAYER1;
private PlayerID player = PlayerID.NOBODY;
private PlayerID winner = PlayerID.NOBODY;
private PlayerID last_first_player = PlayerID.NOBODY;
private Board game_board = new Board ();
......@@ -317,17 +317,17 @@ private class FourInARow : Gtk.Application
}
if (one_player_game)
{
player = settings.get_string ("first-player") == "computer" ? PlayerID.PLAYER2 : PlayerID.PLAYER1;
settings.set_string ("first-player", player == PlayerID.PLAYER1 ? "computer" : "human");
player = settings.get_string ("first-player") == "computer" ? PlayerID.OPPONENT : PlayerID.HUMAN;
settings.set_string ("first-player", player == PlayerID.HUMAN ? "computer" : "human");
ai_level = (uint8) settings.get_int ("opponent");
}
else
{
switch (last_first_player)
{
case PlayerID.PLAYER1: player = PlayerID.PLAYER2; break;
case PlayerID.PLAYER2:
case PlayerID.NOBODY : player = PlayerID.PLAYER1; break;
case PlayerID.HUMAN : player = PlayerID.OPPONENT; break;
case PlayerID.OPPONENT:
case PlayerID.NOBODY : player = PlayerID.HUMAN; break;
}
last_first_player = player;
}
......@@ -463,11 +463,11 @@ private class FourInARow : Gtk.Application
{
string who;
if (gameover)
who = player == PLAYER1 ? theme_get_player_win (PlayerID.PLAYER1, theme_id)
: theme_get_player_win (PlayerID.PLAYER2, theme_id);
who = player == HUMAN ? theme_get_player_win (PlayerID.HUMAN, theme_id)
: theme_get_player_win (PlayerID.OPPONENT, theme_id);
else
who = player == PLAYER1 ? theme_get_player_turn (PlayerID.PLAYER1, theme_id)
: theme_get_player_turn (PlayerID.PLAYER2, theme_id);
who = player == HUMAN ? theme_get_player_turn (PlayerID.HUMAN, theme_id)
: theme_get_player_turn (PlayerID.OPPONENT, theme_id);
set_status_message (_(who));
}
......@@ -475,7 +475,7 @@ private class FourInARow : Gtk.Application
private void swap_player ()
{
player = (player == PlayerID.PLAYER1) ? PlayerID.PLAYER2 : PlayerID.PLAYER1;
player = (player == PlayerID.HUMAN) ? PlayerID.OPPONENT : PlayerID.HUMAN;
move_cursor (3);
prompt_player ();
}
......@@ -540,7 +540,7 @@ private class FourInARow : Gtk.Application
private bool is_player_human ()
{
if (one_player_game)
return player == PlayerID.PLAYER1;
return player == PlayerID.HUMAN;
else
return true;
}
......@@ -577,7 +577,7 @@ private class FourInARow : Gtk.Application
private inline void drop ()
{
PlayerID tile = player == PlayerID.PLAYER1 ? PlayerID.PLAYER1 : PlayerID.PLAYER2;
PlayerID tile = player == PlayerID.HUMAN ? PlayerID.HUMAN : PlayerID.OPPONENT;
game_board [row, column] = PlayerID.NOBODY;
game_board_view.draw_tile (row, column);
......@@ -593,7 +593,7 @@ private class FourInARow : Gtk.Application
game_board_view.draw_tile (0, column);
column = c;
game_board [0, c] = player == PlayerID.PLAYER1 ? PlayerID.PLAYER1 : PlayerID.PLAYER2;
game_board [0, c] = player == PlayerID.HUMAN ? PlayerID.HUMAN : PlayerID.OPPONENT;
game_board_view.draw_tile (0, c);
}
......@@ -1111,7 +1111,7 @@ private class FourInARow : Gtk.Application
}
private enum PlayerID {
PLAYER1,
PLAYER2,
HUMAN,
OPPONENT,
NOBODY;
}
......@@ -132,15 +132,15 @@ private class GameBoardView : Gtk.DrawingArea
if (row == 0)
switch (tile)
{
case PlayerID.PLAYER1 : os = offset [Tile.PLAYER1_CURSOR]; break;
case PlayerID.PLAYER2 : os = offset [Tile.PLAYER2_CURSOR]; break;
case PlayerID.HUMAN : os = offset [Tile.PLAYER1_CURSOR]; break;
case PlayerID.OPPONENT: os = offset [Tile.PLAYER2_CURSOR]; break;
case PlayerID.NOBODY : os = offset [Tile.CLEAR_CURSOR]; break;
}
else
switch (tile)
{
case PlayerID.PLAYER1 : os = offset [Tile.PLAYER1]; break;
case PlayerID.PLAYER2 : os = offset [Tile.PLAYER2]; break;
case PlayerID.HUMAN : os = offset [Tile.PLAYER1]; break;
case PlayerID.OPPONENT: os = offset [Tile.PLAYER2]; break;
case PlayerID.NOBODY : assert_not_reached ();
}
......
......@@ -55,25 +55,25 @@ private class Scorebox : Dialog {
grid.add(grid2);
grid2.column_spacing = 6;
label_name[PlayerID.PLAYER1] = new Label(null);
grid2.attach(label_name[PlayerID.PLAYER1], 0, 0, 1, 1);
label_name[PlayerID.PLAYER1].xalign = 0;
label_name[PlayerID.PLAYER1].yalign = 0.5f;
label_score[PlayerID.PLAYER1] = new Label(null);
grid2.attach(label_score[PlayerID.PLAYER1], 1, 0, 1, 1);
label_score[PlayerID.PLAYER1].xalign = 0;
label_score[PlayerID.PLAYER1].yalign = 0.5f;
label_name[PlayerID.PLAYER2] = new Label(null);
grid2.attach(label_name[PlayerID.PLAYER2], 0, 1, 1, 1);
label_name[PlayerID.PLAYER2].xalign = 0;
label_name[PlayerID.PLAYER2].yalign = 0.5f;
label_score[PlayerID.PLAYER2] = new Label(null);
grid2.attach(label_score[PlayerID.PLAYER2], 1, 1, 1, 1);
label_score[PlayerID.PLAYER2].set_xalign(0);
label_score[PlayerID.PLAYER2].set_yalign(0.5f);
label_name[PlayerID.HUMAN] = new Label(null);
grid2.attach(label_name[PlayerID.HUMAN], 0, 0, 1, 1);
label_name[PlayerID.HUMAN].xalign = 0;
label_name[PlayerID.HUMAN].yalign = 0.5f;
label_score[PlayerID.HUMAN] = new Label(null);
grid2.attach(label_score[PlayerID.HUMAN], 1, 0, 1, 1);
label_score[PlayerID.HUMAN].xalign = 0;
label_score[PlayerID.HUMAN].yalign = 0.5f;
label_name[PlayerID.OPPONENT] = new Label(null);
grid2.attach(label_name[PlayerID.OPPONENT], 0, 1, 1, 1);
label_name[PlayerID.OPPONENT].xalign = 0;
label_name[PlayerID.OPPONENT].yalign = 0.5f;
label_score[PlayerID.OPPONENT] = new Label(null);
grid2.attach(label_score[PlayerID.OPPONENT], 1, 1, 1, 1);
label_score[PlayerID.OPPONENT].set_xalign(0);
label_score[PlayerID.OPPONENT].set_yalign(0.5f);
/* Translators: in the Scores dialog, label of the line where is indicated the number of tie games */
label_name[PlayerID.NOBODY] = new Label(_("Drawn:"));
......@@ -95,15 +95,15 @@ private class Scorebox : Dialog {
*/
internal void update(uint[] scores, bool one_player_game) {
if (one_player_game) {
if (scores[PlayerID.PLAYER1] >= scores[PlayerID.PLAYER2]) {
if (scores[PlayerID.HUMAN] >= scores[PlayerID.OPPONENT]) {
/* Translators: in the Scores dialog, label of the line where is indicated the number of games won by the human player */
label_name[0].set_text(_("You:"));
/* Translators: in the Scores dialog, label of the line where is indicated the number of games won by the computer player */
label_name[1].set_text(_("Me:"));
label_score[0].label = scores[PlayerID.PLAYER1].to_string();
label_score[1].label = scores[PlayerID.PLAYER2].to_string();
label_score[0].label = scores[PlayerID.HUMAN].to_string();
label_score[1].label = scores[PlayerID.OPPONENT].to_string();
} else {
/* Translators: in the Scores dialog, label of the line where is indicated the number of games won by the computer player */
label_name[0].set_text(_("Me:"));
......@@ -115,11 +115,11 @@ private class Scorebox : Dialog {
label_score[1].label = scores[0].to_string();
}
} else {
label_name[0].label = theme_get_player(PlayerID.PLAYER1, (uint8) theme_id); // FIXME missing ":" at end
label_name[1].label = theme_get_player(PlayerID.PLAYER2, (uint8) theme_id); // idem
label_name[0].label = theme_get_player(PlayerID.HUMAN, (uint8) theme_id); // FIXME missing ":" at end
label_name[1].label = theme_get_player(PlayerID.OPPONENT, (uint8) theme_id); // idem
label_score[PlayerID.PLAYER1].label = scores[PlayerID.PLAYER1].to_string();
label_score[PlayerID.PLAYER2].label = scores[PlayerID.PLAYER2].to_string();
label_score[PlayerID.HUMAN].label = scores[PlayerID.HUMAN].to_string();
label_score[PlayerID.OPPONENT].label = scores[PlayerID.OPPONENT].to_string();
}
label_score[PlayerID.NOBODY].label = scores[PlayerID.NOBODY].to_string();
......
......@@ -46,7 +46,7 @@ private static string theme_get_title (uint8 id)
private static string theme_get_player_turn (PlayerID who, uint8 theme_id)
{
if (who == PlayerID.PLAYER1)
if (who == PlayerID.HUMAN)
return theme [theme_id].player1_turn;
else
return theme [theme_id].player2_turn;
......@@ -54,7 +54,7 @@ private static string theme_get_player_turn (PlayerID who, uint8 theme_id)
private static string theme_get_player_win (PlayerID who, uint8 theme_id)
{
if (who == PlayerID.PLAYER1)
if (who == PlayerID.HUMAN)
return theme [theme_id].player1_win;
else
return theme [theme_id].player2_win;
......@@ -62,7 +62,7 @@ private static string theme_get_player_win (PlayerID who, uint8 theme_id)
private static string theme_get_player (PlayerID who, uint8 theme_id)
{
if (who == PlayerID.PLAYER1)
if (who == PlayerID.HUMAN)
return theme [theme_id].player1;
else
return theme [theme_id].player2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment