work in progress
This commit is contained in:
82
src/game.cc
82
src/game.cc
@ -40,10 +40,89 @@ void game::new_level() {
|
||||
rng, enabled_features));
|
||||
}
|
||||
|
||||
result game::player_moves(game_command cmd) {
|
||||
switch (cmd) {
|
||||
case game_command_terminate:
|
||||
return result::terminate;
|
||||
|
||||
case move_east: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(east);
|
||||
|
||||
return player->move(east, levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_west: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(west);
|
||||
|
||||
return player->move(west, levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_north: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(north);
|
||||
|
||||
return player->move(north, levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_south: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(south);
|
||||
|
||||
return player->move(south, levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_northeast: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(northeast);
|
||||
|
||||
return player->move(northeast,
|
||||
levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_northwest: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(northwest);
|
||||
|
||||
return player->move(northwest,
|
||||
levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_southeast: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(southeast);
|
||||
|
||||
return player->move(southeast,
|
||||
levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
|
||||
case move_southwest: {
|
||||
if (enabled_features & FEATURE_NCURSES)
|
||||
return player_move_or_attack(southwest);
|
||||
|
||||
return player->move(southwest,
|
||||
levels[curr_level]->get_available_around(
|
||||
player->get_position()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game_status game::run() {
|
||||
player->start_turn();
|
||||
auto res = player_moves(in->get_command());
|
||||
|
||||
switch (res) {
|
||||
case result::terminate:
|
||||
return terminated;
|
||||
|
||||
case result::died:
|
||||
return game_status::dead;
|
||||
|
||||
@ -70,7 +149,10 @@ game_status game::run() {
|
||||
break;
|
||||
}
|
||||
|
||||
move_enemies();
|
||||
|
||||
if (player->get_HP() <= 0)
|
||||
return game_status::dead;
|
||||
|
||||
return game_status::in_game;
|
||||
}
|
||||
|
Reference in New Issue
Block a user