Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1fe2192
PokemonFRLG: S12, Fuchsia Gym and Koga (12.01, 12.02) on the 11.03 stack
dayfine Nov 12, 2026
de696a7
PokemonFRLG: 12.01 out of the Center by its walls, 12.02 taps to the …
dayfine Nov 12, 2026
52ede51
PokemonFRLG: segment 12's row tests registered from their own header
dayfine Nov 12, 2026
78f3dac
PokemonFRLG: 12.01 passes Juggler Kayden on his turn south, as pokeguy
dayfine Nov 12, 2026
9ad59b4
PokemonFRLG: trainer pass and the sim's trainer turns in their own fi…
dayfine Nov 12, 2026
4121f19
PokemonFRLG: read Kayden's facing on screen for trainer_pass
dayfine Nov 12, 2026
665d3a6
PokemonFRLG: 12.01 fights Juggler Kayden again (user decision 2026-11…
dayfine Nov 12, 2026
a6fe97f
FRLG 12.01: heal to full HP before Koga, Fuchsia Mart buys the shortfall
dayfine Nov 12, 2026
137916a
FRLG 12.01: golden plan lines for the Fuchsia Mart detour
dayfine Nov 12, 2026
209a482
FRLG 12.01: Fuchsia Mart via the east ledge and the Cut tree; nurse h…
dayfine Nov 12, 2026
2215236
FRLG 12.01: golden plan lines and notes for the ledge and Cut tree way
dayfine Nov 12, 2026
c99f7f4
FRLG AutoStory: note where our helpers overlap upstream Navigation
dayfine Nov 12, 2026
7c2e36a
CI: link Pokemon_Direction.cpp into runtime-map tests; ItemListReader…
dayfine Nov 12, 2026
13fc72d
FRLG teach: keep lists instead of one move to forget
dayfine Nov 12, 2026
ef1d107
FRLG 12.01: floor 3762 for buy_super_potions; every Mart step needs a…
dayfine Nov 13, 2026
66baa7e
FRLG Mart: the item list reader names every item the Marts sell
dayfine Nov 13, 2026
c269877
CI: CommandLineTests with the Fuchsia Mart BUY list image
dayfine Nov 13, 2026
5551f77
FRLG Mart tests: string_view for the Mart maps
dayfine Nov 13, 2026
a63973d
FRLG 12.01: the Fuchsia Mart fills the bag to 5 Super Potions
dayfine Nov 13, 2026
da549f4
FRLG battle policy: PokeGuy's C2 goal-based setup at Koga and the Tow…
dayfine Nov 13, 2026
9cf0cf0
FRLG battle policy: Supplies::end_trainer_battle keeps Events.cpp und…
dayfine Nov 13, 2026
ea6619d
FRLG battle policy: red tests for the 2026-11-12 Koga loss (futile Po…
dayfine Nov 13, 2026
172c0b3
FRLG battle policy: a heal that loses ground to poison and the foe's …
dayfine Nov 13, 2026
a2c0bd1
FRLG 12.02: a thin bag goes to the Fuchsia Mart before Koga
dayfine Nov 13, 2026
d1f4acc
FRLG 12.02 tests: include the Mart plan header
dayfine Nov 13, 2026
e589d3f
FRLG 12.02: the detour's last tile by a tap, so Koga's A press follow…
dayfine Nov 13, 2026
f2fa699
FRLG 12.02: the detour's way down to Koga by taps from the wall
dayfine Nov 13, 2026
c11c3f4
FRLG 12.02: golden plan lines for the Mart detour
dayfine Nov 13, 2026
2217675
FRLG healing: bag_holds moves to HealingSteps, planning_heal back und…
dayfine Nov 13, 2026
6829d52
FRLG Mart: buy blind, no budget, floor or money read
dayfine Nov 13, 2026
e27f5e0
FRLG battle: attack choice honors foe abilities, STAB and two-turn moves
dayfine Nov 13, 2026
aa3629a
FRLG policy: keep Full Restore for the last foe, cure status with che…
dayfine Nov 13, 2026
101b378
FRLG 12.02: no Mart detour; start west of Koga and challenge him; Ful…
dayfine Nov 13, 2026
bde966b
FRLG battle: drop the STAB factor from the matchup (the data has no p…
dayfine Nov 13, 2026
bdea6af
FRLG 12.02: Koga's foe_threats are PokemonSimulation's planning_risk …
dayfine Nov 13, 2026
fef61c2
FRLG 12.02: the Koga pin reads the koga battle step
dayfine Nov 13, 2026
f3bd31c
FRLG 12.02: Koga's old pin rows follow the generator; Strength note n…
dayfine Nov 13, 2026
4b8f80a
FRLG 12.02: Koga alone; the Warden, Strength and the nurse heal are 1…
dayfine Nov 13, 2026
de559d7
FRLG 12.02b: the Warden, Strength and the nurse heal get their plan file
dayfine Nov 13, 2026
69068bb
Merge frlg/stage11-safari into frlg/stage12-fuchsia-gym: upstream #18…
dayfine Nov 13, 2026
7718bbd
Merge frlg/stage11-safari into frlg/stage12-fuchsia-gym
dayfine Nov 14, 2026
bcba200
Merge frlg/stage11-safari into frlg/stage12-fuchsia-gym
dayfine Nov 14, 2026
8695db3
Merge frlg/stage11-safari into frlg/stage12-fuchsia-gym
dayfine Nov 14, 2026
ff87daa
Merge frlg/stage11-safari into frlg/stage12-fuchsia-gym
dayfine Nov 14, 2026
243c0c9
Merge origin/frlg/stage11-safari into frlg/stage12-fuchsia-gym
dayfine Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@
// Mt. Moon's, which top the pocket above the story's items.
{"moon-stone", "Moon Stone"},
{"nugget", "Nugget"},
// The rest of the Marts' stock. The Fuchsia Mart's ULTRA BALL row read
// as PARLYZ HEAL, the nearest name there was, and 12.01 bought
// nothing (console B, 2026-11-12).
{"great-ball", "Great Ball"},
{"ultra-ball", "Ultra Ball"},
{"hyper-potion", "Hyper Potion"},
{"max-potion", "Max Potion"},
{"revive", "Revive"},
{"burn-heal", "Burn Heal"},
{"ice-heal", "Ice Heal"},
{"full-heal", "Full Heal"},
{"x-attack", "X Attack"},
{"x-defend", "X Defend"},
{"dire-hit", "Dire Hit"},
{"cancel", "Cancel"},
};

Expand Down Expand Up @@ -241,7 +255,7 @@

virtual UnitTestResult run(Logger&, CancellableScope&) const override{
const ItemNameMatcher& matcher = ItemNameMatcher::instance();
for (const std::string& text : {"FARE CANCY", "RARE CANOY", "RARE CANDY"}){
for (const char* text : {"FARE CANCY", "RARE CANOY", "RARE CANDY"}){

Check failure on line 258 in SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: no char* / char[] in new code; use std::string, or std::string_view (inline constexpr std::string_view for constants) (fork AGENTS.md "Strings")
const std::string item = matcher.match(Language::English, text);
if (item != "rare-candy"){
return std::format("Expected \"{}\" read as rare-candy, got \"{}\".", text, item);
Expand Down Expand Up @@ -337,6 +351,9 @@
database.add<Test_BagPocket>("PokemonFRLG/ItemListReader/ItemsPocketMoonStone_eng.png");
// The Viridian Mart's BUY list, the same day, the cursor on POTION.
database.add<Test_MartList>("PokemonFRLG/ItemListReader/MartBuyList_eng.png");
// The Fuchsia Mart's, the cursor on ULTRA BALL (console B, 2026-11-12): six
// rows, none of them in the reader's dictionary yet.
database.add<Test_MartList>("PokemonFRLG/ItemListReader/FuchsiaMartBuyList_eng.png");
database.add<Test_Route17ItemNames>();
database.add<Test_StoryItemNames>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ constexpr std::string_view MAP_NAMES[] = {
"Route18",
"Route18_EastEntrance_1F",
"FuchsiaCity",
// Fuchsia's Mart: Super Potions before Koga's gym (12.01).
"FuchsiaCity_Mart",
// The Safari Zone, pokeguy's way through it: its entrance, the
// center, east, north and west areas, and the Secret House (HM03).
"FuchsiaCity_SafariZone_Entrance",
Expand All @@ -136,6 +138,9 @@ constexpr std::string_view MAP_NAMES[] = {
"SafariZone_North",
"SafariZone_West",
"SafariZone_SecretHouse",
// Koga's gym, and the Warden's house (GOLD TEETH for HM04).
"FuchsiaCity_Gym",
"FuchsiaCity_WardensHouse",
"CeruleanCave_1F",
"CeruleanCave_2F",
"CeruleanCave_B1F",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include "Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows12_Tests.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryTable.h"
#include "Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h"
#include "Programs/AutoStory/Data/Json_Tests.h"
Expand Down Expand Up @@ -105,6 +107,8 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){
add_tests_AutoStorySnorlax(database);
add_tests_AutoStorySlope(database);
add_tests_AutoStorySafari(database);
add_tests_AutoStoryFuchsiaGym(database);
add_tests_AutoStoryHealing(database);
}

void add_tests(UnitTestDatabase& database){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ Outcome mart(Logger& logger, const MartPlan& plan, StoryAbilities& abilities){
const MartResult result = run_mart(logger, abilities.mart, plan);
const std::string message = mart_message(plan, result);
logger.log(message, result.end == MartEnd::DONE ? COLOR_BLACK : COLOR_RED);
if (result.end == MartEnd::NOTHING_TO_BUY){
return Pokemon::outcome_unchanged();
}
return result.end == MartEnd::DONE ? Pokemon::outcome_ok() : Pokemon::outcome_failed(std::format("mart_{}", mart_end_name(result.end)), message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
virtual void log(const std::string&, Color) override{}
};

// A game where nothing happens: a lead whose level is set, a Mart whose
// money is set, a patch whose one battle is shiny if set.
// A game where nothing happens: a lead whose level is set, a patch whose one battle is shiny if set.
class StubMart : public MartActions{

Check warning on line 32 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::StubMart: public_methods=6 (advisory above 5, limit 7)
public:
size_t money = 3000;

virtual bool open_buy_list() override{ return true; }
virtual std::optional<size_t> read_money() override{ return money; }
virtual void press_cursor(bool) override{}
virtual std::string read_row(size_t) override{ return ""; }
virtual void dump_screen(std::string_view) override{}
Expand Down Expand Up @@ -152,13 +148,12 @@

std::vector<StepCase> step_cases(){
const auto none = [](StubGame&){};
const Pokemon::StoryStep mart = mart_step("mart", "", {.map = "PewterCity_Mart", .lines = {{"potion", 5}}, .budget = 2000});
const Pokemon::StoryStep mart = mart_step("mart", "", {.map = "PewterCity_Mart", .lines = {{"potion", 5}}});
const Pokemon::StoryStep grind = grind_step("grind", "", {.member = 0, .level = 20, .max_encounters = 5, .pace = Pokemon::Direction::EAST, .heal_every = 0}, {});
return {
{"level reached", none, level_step("check", "", {.slot = 0, .level = 16}), "unchanged"},
{"level below", none, level_step("check", "", {.slot = 0, .level = 17}), "level_below"},
{"level unread", [](StubGame& game){ game.level.reset(); }, level_step("check", "", {.slot = 0, .level = 16}), "level_unread"},
{"a Mart with too little money succeeds", [](StubGame& game){ game.mart.money = 100; }, mart, "unchanged"},
{"a Mart purchase that fails", none, mart, "mart_failed"},
{"a move it knows already succeeds", none, teach_step("teach", "", {.item = "hm03", .move = "surf", .member = 0}), "unchanged"},
{"a TM not in the TM Case is skipped", none, teach_step("teach", "", {.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "water-gun"}), "unchanged"},
Expand Down Expand Up @@ -189,7 +184,7 @@
UnitTestResult test_once_per_save_steps(){
const std::vector<Pokemon::StoryStep> once{
teach_step("teach", "", {.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}),
mart_step("mart", "", {.map = "CeruleanCity_Mart", .lines = {{.item = "potion", .quantity = 3}}, .budget = 1500, .money_floor = 1500}),
mart_step("mart", "", {.map = "CeruleanCity_Mart", .lines = {{.item = "potion", .quantity = 3}}}),
};
for (const Pokemon::StoryStep& step : once){
if (!step.once_per_save){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ constexpr Milliseconds INTRO_A_EVERY = 1500ms;
constexpr Milliseconds INTRO_QUIET = 3000ms;
constexpr Milliseconds INTRO_STUCK = 15000ms;
constexpr Milliseconds INTRO_TIMEOUT = 600000ms;
// "Wait about 8 s" after YES at the nurse (console B, 2026-11-01): 1.5 s
// between presses did not heal.
constexpr Milliseconds HEAL_TIME = 8000ms;

DpadPosition dpad(Direction direction){
switch (direction){
Expand Down Expand Up @@ -116,6 +113,10 @@ std::optional<int> start_cursor_row(ConsoleHandle& console, ProControllerContext

// The START menu's cursor onto `row`, read from the arrow. As
// move_cursor_to_position(), for a menu of any length.
// Overlaps move_cursor_to_position() in PokemonFRLG_StartMenuNavigation.h.
// Upstream only has fixed-menu overloads (Start, Safari, NoDex); ours takes a row count,
// so it also fits the 5-row menu before the starter.
// Could be unified with upstream if needed.
bool move_start_cursor(ConsoleHandle& console, ProControllerContext& context, int rows, int row){
const std::optional<int> current = start_cursor_row(console, context, rows);
if (!current){
Expand All @@ -134,6 +135,9 @@ bool move_start_cursor(ConsoleHandle& console, ProControllerContext& context, in
// The START menu's cursor onto SAVE, in a menu of any length: up past the
// top wraps to EXIT, the last row, whose place gives the length; SAVE is
// two above it.
// Overlaps move_cursor_to_position(SelectionArrowPositionStartMenu::SAVE) in PokemonFRLG_StartMenuNavigation.h.
// Upstream's SAVE position only fits the full menu; ours finds the menu length first, so it fits any menu.
// Could be unified with upstream if needed.
bool move_start_cursor_to_save(ConsoleHandle& console, ProControllerContext& context){
const int most = start_menu_rows(StartMenu::FULL);
const std::optional<int> current = start_cursor_row(console, context, most);
Expand All @@ -154,6 +158,9 @@ bool move_start_cursor_to_save(ConsoleHandle& console, ProControllerContext& con
return true;
}

// Overlaps open_start_menu() and move_cursor_to_position() in PokemonFRLG_StartMenuNavigation.h.
// Ours wraps open_start_menu() and then moves the cursor by row for any START menu variant.
// Could be unified with upstream if needed.
void open_start_menu_row(ConsoleHandle& console, ProControllerContext& context, StartMenu menu, int row){
open_start_menu(console, context);
if (!move_start_cursor(console, context, start_menu_rows(menu), row)){
Expand Down Expand Up @@ -880,19 +887,6 @@ void set_options(ConsoleHandle& console, ProControllerContext& context, StartMen
mash_until_overworld(console, context, 20000ms);
}

void heal_at_center(ConsoleHandle& console, ProControllerContext& context){
console.log("Healing at the Pokemon Center.");
// The nurse's YES/NO isn't seen by the selection detector (console B,
// 2026-11-01); YES is the default, so A after her lines is YES.
// "Welcome ... We heal your POKEMON ... Shall we heal?" is 3 lines.
press(context, BUTTON_A, 1500ms);
press(context, BUTTON_A, 1500ms);
press(context, BUTTON_A, 2500ms);
press(context, BUTTON_A, 1000ms);
pbf_wait(context, HEAL_TIME);
mash_until_overworld(console, context, 30000ms);
}

// A picture of the Mart screen for the run's record: the list with the
// cursor, the quantity, the bag after.
static void mart_shot(ConsoleHandle& console, ProControllerContext& context, const std::string& label){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ std::optional<size_t> option_right_presses(
// presses, fails with a screenshot and leaves the menu open.
void set_options(ConsoleHandle& console, ProControllerContext& context, StartMenu menu, Language language);

// Facing the nurse: A, YES, the heal, and the text to its end.
void heal_at_center(ConsoleHandle& console, ProControllerContext& context);

// One line of a Mart's BUY list: the row (from 0) and how many.
struct MartOrder{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Battle

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=973 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -29,6 +29,8 @@
#include "PokemonFRLG_AutoStoryBattleData.h"
#include "PokemonFRLG_AutoStoryBattleDecisions.h"
#include "PokemonFRLG_AutoStoryBattle.h"
#include "PokemonFRLG_AutoStoryHealing.h"
#include "PokemonFRLG_AutoStoryHealingSteps.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand Down Expand Up @@ -209,6 +211,10 @@
}

// RUN, bottom right of the battle menu.
// Overlaps flee_battle() in PokemonFRLG_Navigation.h.
// Ours is one blind turn that resets the cursor first, since the battle loop reads the result itself;
// upstream needs the cursor on FIGHT and assumes the run always works.
// Could be unified with upstream if needed.
void run_away(ProControllerContext& context){
tap(context, DPAD_LEFT);
tap(context, DPAD_UP);
Expand Down Expand Up @@ -567,6 +573,7 @@
m_supplies.hurt = status.hp_red || status.hp_yellow;
m_supplies.hp_red = status.hp_red;
m_supplies.hp_fill = status.hp_fill;
measured_hp(m_supplies, status.hp_fill);
}
m_supplies.status = status.status;
}
Expand All @@ -586,7 +593,18 @@
m_last_press = now;
}

void log_turn(const PartyStatus& status, const TurnAction& action){
m_console.log(std::format(
"Battle: turn {}, HP {} ({:.0f}% of the bar), {}, {} Potions, {} Antidotes, {} Parlyz Heals, {} Awakenings.",
m_decisions.turns(), status.hp_red ? "red" : status.hp_yellow ? "yellow" : "green", 100 * status.hp_fill,
status_name(status.status), m_supplies.potions, m_supplies.antidotes, m_supplies.parlyz_heals, m_supplies.awakenings
));
if (!action.heal_reason.empty()){
m_console.log("Battle: " + action.heal_reason + ".");

Check warning on line 603 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
}
}

void take_turn(const ImageViewRGB32& screen){

Check warning on line 607 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::BattleLoop::take_turn( const ImageViewRGB32 & screen): function_lines=45 (advisory above 25, limit 50)
m_faint_polls = 0;
if (m_kind != BattleKind::TRAINER && m_decisions.turns() == 0){
m_supplies.wild_foes = read_wild_foes(m_console.logger(), m_language, screen);
Expand All @@ -601,14 +619,7 @@
const PartyStatus status = read_party_status(screen);
const TurnAction action = m_decisions.turn(status);
m_evolution.turn_taken(action.choice);
m_console.log(std::format(
"Battle: turn {}, HP {} ({:.0f}% of the bar), {}, {} Potions, {} Antidotes, {} Parlyz Heals, {} Awakenings.",
m_decisions.turns(), status.hp_red ? "red" : status.hp_yellow ? "yellow" : "green", 100 * status.hp_fill,
status_name(status.status), m_supplies.potions, m_supplies.antidotes, m_supplies.parlyz_heals, m_supplies.awakenings
));
if (!action.heal_reason.empty()){
m_console.log("Battle: " + action.heal_reason + ".");
}
log_turn(status, action);
dump_debug_image(m_console, "AutoStory/battle", std::format("turn{}-menu", m_decisions.turns()), screen);
switch (action.choice){
case TurnChoice::RUN:
Expand All @@ -624,6 +635,9 @@
case TurnChoice::AWAKENING:
m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, "awakening", ItemTarget::PARTY_MEMBER, m_checks, m_language)));
return;
case TurnChoice::MEDICINE:
m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, action.item, ItemTarget::PARTY_MEMBER, m_checks, m_language)));
return;
case TurnChoice::BATTLE_ITEM:
m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, action.item, ItemTarget::POKEMON_OUT, m_checks, m_language)));
return;
Expand Down Expand Up @@ -673,6 +687,9 @@


// From the overworld: the bag open on the Items pocket, cursor on its top.
// Overlaps open_bag_from_overworld() in PokemonFRLG_Navigation.h.
// Ours wraps it, then waits for the bag to slide in and moves the cursor to the top of the Items pocket.
// Could be unified with upstream if needed.
void open_items_pocket(ConsoleHandle& console, ProControllerContext& context){
open_bag_from_overworld(console, context);
// The bag ignores presses while it slides in.
Expand Down Expand Up @@ -895,26 +912,25 @@
return rows;
}

bool use_recovery_item(
ConsoleHandle& console, ProControllerContext& context,
const std::string& item, Pokemon::StoryCheckLevel checks, Language language, Supplies& supplies
){
// The row before the count drops: a counted item with none left takes
// no row.
if (!use_item_on_overworld(console, context, supplies, item, checks, language)){
return false;
}
took_recovery_item(supplies, item);
return true;
}

void recover_after_battle(
ConsoleHandle& console, ProControllerContext& context,
Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language
){
for (const std::string& item : recovery_items(supplies)){
// The row before the count drops: a counted item with none left
// takes no row.
if (!use_item_on_overworld(console, context, supplies, item, checks, language)){
continue;
}
spend_item(supplies, item);
if (item == "potion"){
// One Potion (20 HP) takes a starter of these levels from red
// to green; the bar can't be read again on the overworld.
supplies.hurt = false;
supplies.hp_red = false;
supplies.hp_fill = 1.0;
}else{
supplies.status = StatusCondition::NONE;
}
use_recovery_item(console, context, item, checks, language, supplies);
}
if (supplies.status != StatusCondition::NONE){
console.log(std::format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,32 @@ size_t type_effectiveness(PokemonType attack, PokemonType defend){
return it == CHART.end() ? 10 : it->second;
}

PokemonType ability_immunity(std::string_view species){
struct Immunity{
std::string_view species;
PokemonType type;
};
// Gen 3 species with one ability only, so the foe has it for sure.
static constexpr Immunity IMMUNITIES[] = {
{"gastly", PokemonType::GROUND}, {"haunter", PokemonType::GROUND}, {"gengar", PokemonType::GROUND},
{"koffing", PokemonType::GROUND}, {"weezing", PokemonType::GROUND},
{"vulpix", PokemonType::FIRE}, {"ninetales", PokemonType::FIRE}, {"flareon", PokemonType::FIRE},
{"jolteon", PokemonType::ELECTRIC},
{"vaporeon", PokemonType::WATER},
};
for (const Immunity& immunity : IMMUNITIES){
if (immunity.species == species){
return immunity.type;
}
}
return PokemonType::NONE;
}

bool takes_two_turns(std::string_view move){
static constexpr std::string_view TWO_TURN_MOVES[] = {"dig", "fly", "solar-beam", "skull-bash", "razor-wind", "sky-attack"};
return std::ranges::find(TWO_TURN_MOVES, move) != std::end(TWO_TURN_MOVES);
}

std::string read_trainer_foe(Logger& logger, Language language, const ImageViewRGB32& screen, const std::vector<std::string>& party){
if (language == Language::None || party.empty()){
return "";
Expand Down
Loading
Loading