Added End Turn button so we can do multiple actions per round - this will be limited by energy shortly

This commit is contained in:
Anna Rose 2011-07-03 17:45:11 -04:00
parent c5d6167e8c
commit cfe5666c04
4 changed files with 12 additions and 6 deletions

View File

@ -58,6 +58,8 @@ bool Game::init()
int col2 = 260; int col2 = 260;
int col3 = 365; int col3 = 365;
int col4 = 470; int col4 = 470;
int col5 = 575;
int col6 = 680;
buttons.push_back(new MenuButton("Move", font, col1, row1, BUTTON_MOVE)); buttons.push_back(new MenuButton("Move", font, col1, row1, BUTTON_MOVE));
buttons.push_back(new MenuButton("Build", font, col1, row2, buttons.push_back(new MenuButton("Build", font, col1, row2,
@ -70,6 +72,8 @@ bool Game::init()
BUTTON_BUILD_DEFENDER)); BUTTON_BUILD_DEFENDER));
buttons.push_back(new MenuButton("Producer", font, col4, row1, buttons.push_back(new MenuButton("Producer", font, col4, row1,
BUTTON_BUILD_PRODUCER)); BUTTON_BUILD_PRODUCER));
buttons.push_back(new MenuButton("End Turn", font, col6, row2,
BUTTON_END_TURN));
return GameState::init(); return GameState::init();
@ -236,6 +240,9 @@ void Game::handle_button_press(ButtonAction action)
case BUTTON_BUILD_PRODUCER: case BUTTON_BUILD_PRODUCER:
data.set_build_type(VERTEX_PRODUCER); data.set_build_type(VERTEX_PRODUCER);
break; break;
case BUTTON_END_TURN:
data.toggle_turn();
break;
} }
} }
@ -324,6 +331,7 @@ void Game::on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode)
else if (sym == SDLK_m) data.set_mode(MODE_MOVE); else if (sym == SDLK_m) data.set_mode(MODE_MOVE);
else if (sym == SDLK_b) data.set_mode(MODE_BUILD); else if (sym == SDLK_b) data.set_mode(MODE_BUILD);
else if (sym == SDLK_s || sym == SDLK_ESCAPE) data.set_mode(MODE_SELECT); else if (sym == SDLK_s || sym == SDLK_ESCAPE) data.set_mode(MODE_SELECT);
else if (sym == SDLK_e) data.toggle_turn();
#ifdef DEBUG #ifdef DEBUG
if (sym == SDLK_d && mod & (KMOD_ALT | KMOD_CTRL)) print_debug_info(); if (sym == SDLK_d && mod & (KMOD_ALT | KMOD_CTRL)) print_debug_info();

View File

@ -105,7 +105,6 @@ void GameData::handle_click(int x, int y)
{ {
current->x = x; current->x = x;
current->y = y; current->y = y;
toggle_turn();
} }
break; break;
} }
@ -162,7 +161,7 @@ bool GameData::add_vertex(int x, int y, int z, int r, int colour)
if (Graph::add_vertex(v, current)) if (Graph::add_vertex(v, current))
{ {
toggle_turn(); mode = MODE_SELECT;
return true; return true;
} }
@ -225,7 +224,7 @@ void GameData::attack_vertex(GameVertex* target)
fprintf(stderr, "debug: GameData::attack_vertex(): atk=%.2f, armor=%.2f, damage=%d\n", atk, armor, damage); fprintf(stderr, "debug: GameData::attack_vertex(): atk=%.2f, armor=%.2f, damage=%d\n", atk, armor, damage);
#endif #endif
toggle_turn(); mode = MODE_SELECT;
} }

View File

@ -21,8 +21,6 @@ class GameData : public Graph
GameVertex* get_current_vertex(bool only_mine = false) const; GameVertex* get_current_vertex(bool only_mine = false) const;
void clear_current_vertex(); void clear_current_vertex();
void toggle_turn();
// select or add vertex, as appropriate // select or add vertex, as appropriate
void handle_click(int x, int y); void handle_click(int x, int y);
bool select_vertex(int x, int y); bool select_vertex(int x, int y);
@ -42,6 +40,7 @@ class GameData : public Graph
// check for (and set, if needed) winner // check for (and set, if needed) winner
bool endgame(); bool endgame();
void toggle_turn();
Player* get_turn() const { return turn; } Player* get_turn() const { return turn; }
private: private:

View File

@ -15,7 +15,7 @@ using std::string;
// has me hard-pressed to figure out what it is. // has me hard-pressed to figure out what it is.
enum ButtonAction {BUTTON_BUILD=0x1, BUTTON_ATTACK=0x2, BUTTON_MOVE=0x4, enum ButtonAction {BUTTON_BUILD=0x1, BUTTON_ATTACK=0x2, BUTTON_MOVE=0x4,
BUTTON_BUILD_ATTACKER=0x8, BUTTON_BUILD_DEFENDER=0x10, BUTTON_BUILD_ATTACKER=0x8, BUTTON_BUILD_DEFENDER=0x10,
BUTTON_BUILD_PRODUCER=0x20}; BUTTON_BUILD_PRODUCER=0x20, BUTTON_END_TURN=0x40};
class MenuButton class MenuButton
{ {