Skip to content

Commit 63aeeba

Browse files
committed
wip flavor table
1 parent 3c69644 commit 63aeeba

File tree

4 files changed

+217
-1
lines changed

4 files changed

+217
-1
lines changed

SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.cpp

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,39 @@ namespace PokemonAutomation{
1212
namespace NintendoSwitch{
1313
namespace PokemonLZA{
1414

15+
const EnumDropdownDatabase<Flavor_Powers>& flavor_power_enum_database(){
16+
static EnumDropdownDatabase<Flavor_Powers> database{
17+
{Flavor_Powers::alpha, "alpha", "Alpha"},
18+
{Flavor_Powers::humungo, "humungo", "Humungo"},
19+
{Flavor_Powers::teensy, "teensy", "Teensy"},
20+
{Flavor_Powers::sparkling, "sparkling", "Sparkling"},
21+
{Flavor_Powers::item, "item", "Item"},
22+
};
23+
return database;
24+
}
25+
const EnumDropdownDatabase<Power_Pokemon_Types>& pokemon_power_enum_database(){
26+
static EnumDropdownDatabase<Power_Pokemon_Types> database{
27+
{Power_Pokemon_Types::all, "all", "All Types"},
28+
{Power_Pokemon_Types::fire, "fire", "Fire"},
29+
};
30+
return database;
31+
}
32+
const EnumDropdownDatabase<Power_Item_Types>& item_power_enum_database(){
33+
static EnumDropdownDatabase<Power_Item_Types> database{
34+
{Power_Item_Types::berries, "berries", "Berry"},
35+
{Power_Item_Types::candies, "candies", "Candy"},
36+
};
37+
return database;
38+
}
39+
const EnumDropdownDatabase<Power_Level>& power_level_enum_database(){
40+
static EnumDropdownDatabase<Power_Level> database{
41+
{Power_Level::one, "one", "Lv.1"},
42+
{Power_Level::two, "two", "Lv.2"},
43+
{Power_Level::three, "three", "Lv.3"},
44+
};
45+
return database;
46+
}
47+
1548
StringSelectDatabase make_donut_berries_database(){
1649
StringSelectDatabase ret;
1750
for (const auto& slug : DONUT_BERRIES_SLUGS()){
@@ -77,6 +110,81 @@ std::vector<std::unique_ptr<EditableTableRow>> DonutBerriesTable::make_defaults(
77110

78111

79112

113+
114+
FlavorPowerTableRow::~FlavorPowerTableRow(){
115+
power.remove_listener(*this);
116+
}
117+
FlavorPowerTableRow::FlavorPowerTableRow(EditableTableOption& parent_table)
118+
: EditableTableRow(parent_table)
119+
, power(flavor_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Flavor_Powers::alpha)
120+
, type_pokemon(pokemon_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Pokemon_Types::all)
121+
, type_item(item_power_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Item_Types::berries)
122+
, level(power_level_enum_database(), LockMode::LOCK_WHILE_RUNNING, Power_Level::three)
123+
{
124+
PA_ADD_OPTION(power);
125+
PA_ADD_OPTION(type_pokemon);
126+
PA_ADD_OPTION(type_item);
127+
PA_ADD_OPTION(level);
128+
129+
FlavorPowerTableRow::on_config_value_changed(this);
130+
power.add_listener(*this);
131+
}
132+
std::unique_ptr<EditableTableRow> FlavorPowerTableRow::clone() const{
133+
std::unique_ptr<FlavorPowerTableRow> ret(new FlavorPowerTableRow(parent()));
134+
ret->power.set(power);
135+
ret->type_pokemon.set(type_pokemon);
136+
ret->type_item.set(type_item);
137+
ret->level.set(level);
138+
return ret;
139+
}
140+
void FlavorPowerTableRow::on_config_value_changed(void* object){
141+
Flavor_Powers power = this->power;
142+
143+
type_item.set_visibility(
144+
power == Flavor_Powers::item
145+
? ConfigOptionState::ENABLED
146+
: ConfigOptionState::HIDDEN
147+
);
148+
149+
bool req_poke_types =
150+
power == Flavor_Powers::sparkling ||
151+
power == Flavor_Powers::catching ||
152+
power == Flavor_Powers::move ||
153+
power == Flavor_Powers::resistance;
154+
155+
type_pokemon.set_visibility(
156+
req_poke_types
157+
? ConfigOptionState::ENABLED
158+
: ConfigOptionState::HIDDEN
159+
);
160+
}
161+
162+
FlavorPowerTable::FlavorPowerTable()
163+
: EditableTableOption_t<FlavorPowerTableRow>(
164+
"<b>Flavor Powers Table:</b><br>"
165+
"Add all desired flavor powers to this table. "
166+
"The program will check the powers of any baked donut and compare them against the selected items in the table. "
167+
"Be sure to set Number of Powers to Match above.",
168+
LockMode::LOCK_WHILE_RUNNING,
169+
make_defaults()
170+
)
171+
{}
172+
std::vector<std::string> FlavorPowerTable::make_header() const{
173+
return {
174+
"Flavor Power ",
175+
"Pokemon Type ",
176+
"Item Type ",
177+
"Level ",
178+
};
179+
}
180+
std::vector<std::unique_ptr<EditableTableRow>> FlavorPowerTable::make_defaults(){
181+
std::vector<std::unique_ptr<EditableTableRow>> ret;
182+
ret.emplace_back(new FlavorPowerTableRow(*this));
183+
return ret;
184+
}
185+
186+
187+
80188
}
81189
}
82190
}

SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,72 @@
99

1010
#include "CommonTools/Options/StringSelectOption.h"
1111
#include "Common/Cpp/Options/EditableTableOption.h"
12+
#include "Common/Cpp/Options/EnumDropdownOption.h"
13+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
1214

1315
namespace PokemonAutomation{
1416
namespace NintendoSwitch{
1517
namespace PokemonLZA{
1618

19+
enum class Flavor_Powers {
20+
alpha,
21+
humungo,
22+
teensy,
23+
sparkling,
24+
atk,
25+
spatk,
26+
move,
27+
speed,
28+
bighaul,
29+
item,
30+
mega,
31+
def,
32+
spdef,
33+
resistance,
34+
encounter,
35+
catching,
36+
};
37+
38+
enum class Power_Pokemon_Types {
39+
any, //Accept any of the below options
40+
all, //Accept only the All type (ex. Sparkling Power: All Types (Lv. 3)) Applies to catching and sparkling, but not move or resist
41+
normal,
42+
fire,
43+
water,
44+
electric,
45+
grass,
46+
ice,
47+
fighting,
48+
poison,
49+
ground,
50+
flying,
51+
psychic,
52+
bug,
53+
rock,
54+
ghost,
55+
dragon,
56+
dark,
57+
steel,
58+
fairy,
59+
};
60+
61+
enum class Power_Item_Types {
62+
berries,
63+
candies,
64+
treasure,
65+
pokeballs,
66+
special,
67+
coins,
68+
};
69+
70+
enum class Power_Level{
71+
one,
72+
two,
73+
three,
74+
};
75+
1776

77+
//Berry + Hyperspace Berry selection
1878
class DonutBerriesTableCell : public StringSelectCell{
1979
public:
2080
DonutBerriesTableCell(const std::string& default_slug);
@@ -41,6 +101,35 @@ class DonutBerriesTable : public EditableTableOption_t<DonutBerriesTableRow>{
41101

42102

43103

104+
//Donut Flavor Power selection
105+
class FlavorPowerTableRow : public EditableTableRow, public ConfigOption::Listener{
106+
public:
107+
~FlavorPowerTableRow();
108+
FlavorPowerTableRow(EditableTableOption& parent_table);
109+
virtual std::unique_ptr<EditableTableRow> clone() const override;
110+
111+
private:
112+
virtual void on_config_value_changed(void* object) override;
113+
114+
private:
115+
EnumDropdownCell<Flavor_Powers> power;
116+
EnumDropdownCell<Power_Pokemon_Types> type_pokemon;
117+
EnumDropdownCell<Power_Item_Types> type_item;
118+
EnumDropdownCell<Power_Level> level;
119+
};
120+
121+
122+
class FlavorPowerTable : public EditableTableOption_t<FlavorPowerTableRow>{
123+
public:
124+
FlavorPowerTable();
125+
126+
virtual std::vector<std::string> make_header() const;
127+
128+
std::vector<std::unique_ptr<EditableTableRow>> make_defaults();
129+
130+
};
131+
132+
44133
}
45134
}
46135
}

SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ DonutOptionsTest_Descriptor::DonutOptionsTest_Descriptor()
3636
DonutOptionsTest::DonutOptionsTest()
3737
: LANGUAGE(
3838
"<b>Game Language:</b>",
39-
PokemonSwSh::IV_READER().languages(), //TODO: replace?
39+
PokemonSwSh::IV_READER().languages(), //TODO: replace later or something
4040
LockMode::LOCK_WHILE_RUNNING,
4141
true
4242
)
4343
, BERRIES("<b>Berries:</b><br>The berries used to make the donut. Minimum 3 berries, maximum 8 berries.")
44+
, NUM_POWER_REQUIRED(
45+
"<b>Number of Powers to Match:</b><br>How many of a dount's powers must be in the the table below. Minimum 1, maximum 3. "
46+
"<br>Ex. For a target dount of Big Haul Lv.3, Berry Lv.3, and any or none for the 3rd power, set the number as 2."
47+
"<br>Then, in the flavor powers table, make sure to add Big Haul Lv.3 and Berry Lv. 3.",
48+
LockMode::LOCK_WHILE_RUNNING,
49+
1, 1, 3
50+
)
4451
, NUM_DONUTS(
4552
"<b>Number of Donuts:</b><br>The number of donuts to make.",
4653
LockMode::LOCK_WHILE_RUNNING,
@@ -56,6 +63,8 @@ DonutOptionsTest::DonutOptionsTest()
5663
{
5764
PA_ADD_OPTION(LANGUAGE);
5865
PA_ADD_OPTION(BERRIES);
66+
PA_ADD_OPTION(NUM_POWER_REQUIRED);
67+
PA_ADD_OPTION(FLAVOR_POWERS);
5968
PA_ADD_OPTION(NUM_DONUTS);
6069
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
6170
PA_ADD_OPTION(NOTIFICATIONS);
@@ -82,6 +91,10 @@ void DonutOptionsTest::program(SingleSwitchProgramEnvironment& env, ProControlle
8291
env.log("Number of berries validated.", COLOR_BLACK);
8392

8493

94+
//Validate flavor power table
95+
//(not all powers can have all types)
96+
97+
8598
GO_HOME_WHEN_DONE.run_end_of_program(context);
8699
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
87100
}

SerialPrograms/Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_DonutOptionsTest.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
1313
#include "Common/Cpp/Options/SimpleIntegerOption.h"
1414
#include "CommonTools/Options/LanguageOCROption.h"
15+
#include "Common/Cpp/Options/EnumDropdownOption.h"
1516
#include "PokemonLZA/Options/PokemonLZA_DonutBerriesOption.h"
1617

1718
namespace PokemonAutomation{
@@ -32,6 +33,11 @@ class DonutOptionsTest : public SingleSwitchProgramInstance{
3233
private:
3334
OCR::LanguageOCROption LANGUAGE;
3435
DonutBerriesTable BERRIES;
36+
37+
SimpleIntegerOption<uint8_t> NUM_POWER_REQUIRED;
38+
39+
FlavorPowerTable FLAVOR_POWERS;
40+
3541
SimpleIntegerOption<uint8_t> NUM_DONUTS;
3642

3743
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;

0 commit comments

Comments
 (0)