MCPcopy Create free account
hub / github.com/davemoore22/sorcery / _move_backward

Method _move_backward

src/engine/engine.cpp:609–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607 _ctx.game->state->set_player_prev_depth(
608 _ctx.game->state->get_depth());
609 _ctx.game->state->set_depth(to_level);
610 _set_tile_explored(_ctx.game->state->get_player_pos());
611
612 _ctx.controller->unset_flag("want_take_stairs_down");
613 }
614 }
615
616 _ctx.controller->unset_flag("want_take_stairs_up");
617}
618
619auto Sorcery::Engine::_move_backward() -> bool {
620
621 // Work out our new position
622 auto at_loc{_ctx.game->state->get_player_pos()};
623 auto x_d{at_loc.x};
624 auto y_d{at_loc.y};
625
626 switch (_ctx.game->state->get_player_facing()) {
627 using enum Enums::Map::Direction;
628 case NORTH:
629 --y_d;
630 break;
631 case SOUTH:
632 ++y_d;
633 break;
634 case EAST:
635 --x_d;
636 break;
637 case WEST:
638 ++x_d;
639 break;
640 default:
641 break;
642 }
643
644 if (x_d < 0)
645 x_d = MAP_SIZE - 1;
646 else if (x_d > MAP_SIZE - 1)
647 x_d = 0;
648 if (y_d < 0)
649 y_d = MAP_SIZE - 1;
650 else if (y_d > MAP_SIZE - 1)
651 y_d = 0;
652
653 const auto next_loc{Coordinate{x_d, y_d}};
654
655 // Check for walls etc between current square and new square
656 auto this_tile{_ctx.game->state->level->at(at_loc)};
657 const auto &next_tile{_ctx.game->state->level->at(next_loc)};
658
659 auto this_wall_to_check{Enums::Map::Direction::NO_DIRECTION};
660 switch (_ctx.game->state->get_player_facing()) {
661 using enum Enums::Map::Direction;
662 case NORTH:
663 this_wall_to_check = SOUTH;
664 break;
665 case SOUTH:
666 this_wall_to_check = NORTH;

Callers

nothing calls this directly

Calls 15

get_player_posMethod · 0.80
get_player_facingMethod · 0.80
walkableMethod · 0.80
set_player_prev_depthMethod · 0.80
get_depthMethod · 0.80
set_depthMethod · 0.80
set_player_posMethod · 0.80
set_can_undoMethod · 0.80
isMethod · 0.80
get_litMethod · 0.80
set_litMethod · 0.80
stairs_atMethod · 0.80

Tested by

no test coverage detected