diff --git a/source/tm/clients/pokemon_showdown/battle_message_handler_impl.cpp b/source/tm/clients/pokemon_showdown/battle_message_handler_impl.cpp index 1d4ead9e..405a86b7 100644 --- a/source/tm/clients/pokemon_showdown/battle_message_handler_impl.cpp +++ b/source/tm/clients/pokemon_showdown/battle_message_handler_impl.cpp @@ -198,6 +198,13 @@ auto BattleMessageHandler::handle_message(std::span const b auto & move_builder = make_move_builder(); move_builder.still_asleep(message.party); }, + [&](DisableMessage const message) { + m_client_battle->active_has( + message.party == m_party, + message.move + ); + // TODO: Implement Generation 1 Disable + }, [&](RechargingMessage const message) { use_previous_action(); auto & move_builder = make_move_builder(); diff --git a/source/tm/clients/pokemon_showdown/event_block.cpp b/source/tm/clients/pokemon_showdown/event_block.cpp index 647d5d77..e3238742 100644 --- a/source/tm/clients/pokemon_showdown/event_block.cpp +++ b/source/tm/clients/pokemon_showdown/event_block.cpp @@ -107,6 +107,9 @@ constexpr auto parse_message(InMessage message) -> tv::optional { // TODO: Should I send this as a message? return tv::none; }, + [](FromDisable) -> tv::optional { + throw std::runtime_error("Unexpected -activate source FromDisable"); + }, [](FromEntryHazards) -> tv::optional { throw std::runtime_error("Unexpected -activate source FromEntryHazards"); }, @@ -205,6 +208,9 @@ constexpr auto parse_message(InMessage message) -> tv::optional { [&](FromConfusion) -> tv::optional { return HitSelfMessage(parsed.party, parsed.status, parsed.hp); }, + [](FromDisable) -> tv::optional { + throw std::runtime_error("Invalid -damage source of FromDisable"); + }, [&](FromEntryHazards) -> tv::optional { return HPMessage(parsed.party, parsed.status, parsed.hp); }, @@ -435,6 +441,10 @@ constexpr auto parse_message(InMessage message) -> tv::optional { [](MainEffect) -> tv::optional { throw std::runtime_error("Unexpected -start source MainEffect"); }, + [&](FromDisable) -> tv::optional { + auto const move_str = message.pop(); + return DisableMessage(party, from_string(move_str)); + }, [](FromRecoil) -> tv::optional { throw std::runtime_error("Unexpected -start source FromRecoil"); }, @@ -460,6 +470,9 @@ constexpr auto parse_message(InMessage message) -> tv::optional { [&](MainEffect) -> tv::optional { return MoveStatus(party, status); }, + [](FromDisable) -> tv::optional { + throw std::runtime_error("Disable cannot cause a status"); + }, [](FromEntryHazards) -> tv::optional { return tv::none; }, diff --git a/source/tm/clients/pokemon_showdown/parse_effect_source.cpp b/source/tm/clients/pokemon_showdown/parse_effect_source.cpp index 6e3d4a89..9514acd8 100644 --- a/source/tm/clients/pokemon_showdown/parse_effect_source.cpp +++ b/source/tm/clients/pokemon_showdown/parse_effect_source.cpp @@ -27,12 +27,24 @@ using namespace std::string_view_literals; export struct MainEffect {}; export struct FromMove {}; export struct FromConfusion {}; +export struct FromDisable {}; export struct FromEntryHazards {}; export struct FromMiscellaneous {}; export struct FromRecoil {}; export struct FromSubstitute {}; -export using EffectSource = tv::variant; +export using EffectSource = tv::variant< + MainEffect, + Item, + Ability, + FromMove, + FromConfusion, + FromDisable, + FromEntryHazards, + FromMiscellaneous, + FromRecoil, + FromSubstitute +>; export constexpr auto parse_effect_source(std::string_view const type, std::string_view const source) -> EffectSource { return @@ -41,6 +53,7 @@ export constexpr auto parse_effect_source(std::string_view const type, std::stri (type == "ability") ? EffectSource(from_string(source)) : (type == "move") ? EffectSource(FromMove()) : (type == "confusion") ? EffectSource(FromConfusion()) : + (type == "Disable") ? EffectSource(FromDisable()) : (type == "Recoil") ? EffectSource(FromRecoil()) : (type == "Spikes") ? EffectSource(FromEntryHazards()) : (type == "Stealth Rock") ? EffectSource(FromEntryHazards()) : diff --git a/source/tm/clients/pokemon_showdown/parsed_message.cpp b/source/tm/clients/pokemon_showdown/parsed_message.cpp index 3af0a970..40f6c700 100644 --- a/source/tm/clients/pokemon_showdown/parsed_message.cpp +++ b/source/tm/clients/pokemon_showdown/parsed_message.cpp @@ -92,6 +92,12 @@ export struct StillAsleepMessage { friend auto operator==(StillAsleepMessage, StillAsleepMessage) -> bool = default; }; +export struct DisableMessage { + Party party; + MoveName move; + friend auto operator==(DisableMessage, DisableMessage) -> bool = default; +}; + export struct RechargingMessage { Party party; friend auto operator==(RechargingMessage, RechargingMessage) -> bool = default; @@ -237,6 +243,7 @@ export using ParsedMessage = tv::variant< FullyParalyzedMessage, PartiallyTrappedMessage, StillAsleepMessage, + DisableMessage, RechargingMessage, CriticalHitMessage, StatusClearMessage,