| 833 | _ctx.controller->set_can_undo(false); |
| 834 | |
| 835 | const auto at{_ctx.game->state->get_player_pos()}; |
| 836 | if (_ctx.game->state->level->at(at).has_spinner()) { |
| 837 | |
| 838 | auto new_facing{static_cast<Enums::Map::Direction>( |
| 839 | _ctx.get_random(Enums::System::Random::ZERO_TO_3))}; |
| 840 | _ctx.game->state->set_player_facing(new_facing); |
| 841 | |
| 842 | DEBUG_LOG("Player triggered spinner"); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | auto Sorcery::Engine::_pit_oops() -> void { |
| 847 | |
| 848 | std::vector<int> deaths{}; |
| 849 | deaths.clear(); |
| 850 | |
| 851 | auto party{_ctx.game->state->get_party_characters()}; |
| 852 | for (auto &[id, character] : _ctx.game->characters) { |
| 853 | if (std::find(party.begin(), party.end(), id) != party.end()) { |
| 854 | |
| 855 | const auto chance{ |
| 856 | (character.get_cur_attr(Enums::Character::Attribute::AGILITY) - |
| 857 | _ctx.game->state->get_depth()) * |
| 858 | 4}; |
| 859 | const auto roll(_ctx.get_random(Enums::System::Random::D100)); |
| 860 | //_ctx.game->state->add_log_dice_roll( |
| 861 | // fmt::format("{:>16} - {}", character.get_name(), "Avoid Pit"), |
| 862 | // 100, roll, chance); |
| 863 | if (roll < chance) { |
| 864 | |
| 865 | // Damage is avoided |
| 866 | |
| 867 | } else { |
| 868 | |
| 869 | // Now in the original Apple 2 version, pit damage is based upon |
| 870 | // 3 extra values stored in the square in the TMaze records - |
| 871 | // AUX0, AUX1, and AUX2. Thanks to the data extraction by Tommy |
| 872 | // Ewers, the relevant values for each pit in the game are 0, 8 |
| 873 | // and depth respectively. This is a long-winded way of saying |
| 874 | // that the pit damage (calculated in APIT and ROCKWATR) is 0 + |
| 875 | // (depth * d8), i.e. a d8 for level depth. |
| 876 | |
| 877 | // Inflict damage! (remember depth is negative here and positve |
| 878 | // in original wizardry) |
| 879 | auto pit_damage{0U}; |
| 880 | const auto dice{std::abs(_ctx.game->state->get_depth())}; |
| 881 | for (int i = 1; i <= dice; i++) |
| 882 | pit_damage += _ctx.get_random(Enums::System::Random::D8); |
| 883 | |
| 884 | //_ctx.game->state->add_log_message( |
| 885 | // fmt::format( |
| 886 | // "{} fell into a pit and took {} points of damage!", |
| 887 | // character.get_name(), pit_damage), |
| 888 | // IMT::GAME); |
| 889 | |
| 890 | if (const auto alive{character.damage(pit_damage)}; !alive) { |
| 891 | |
| 892 | // Oh dear, death from a pit! |
nothing calls this directly
no test coverage detected