Skip to content

Commit a0147bf

Browse files
kichithewolfGin890
authored andcommitted
hyperspace reward table
1 parent 60c9ce4 commit a0147bf

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Hyperspace Reward Table
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "PokemonLZA/Resources/PokemonLZA_HyperspaceRewardNames.h"
8+
#include "PokemonLZA_HyperspaceRewardTable.h"
9+
10+
namespace PokemonAutomation{
11+
namespace NintendoSwitch{
12+
namespace PokemonLZA{
13+
14+
HyperspaceRewardRow::HyperspaceRewardRow(EditableTableOption& parent_table)
15+
: EditableTableRow(parent_table)
16+
, item("beast-ball")
17+
{
18+
PA_ADD_OPTION(item);
19+
}
20+
std::unique_ptr<EditableTableRow> HyperspaceRewardRow::clone() const{
21+
std::unique_ptr<HyperspaceRewardRow> ret(new HyperspaceRewardRow(parent()));
22+
ret->item.set_by_index(item.index());
23+
return ret;
24+
}
25+
26+
HyperspaceRewardTable::HyperspaceRewardTable(std::string label)
27+
: EditableTableOption_t<HyperspaceRewardRow>(
28+
std::move(label),
29+
LockMode::LOCK_WHILE_RUNNING,
30+
make_defaults()
31+
)
32+
{}
33+
34+
bool HyperspaceRewardTable::find_item(const std::string& item_slug) const{
35+
std::vector<std::unique_ptr<HyperspaceRewardRow>> table = copy_snapshot();
36+
for (const std::unique_ptr<HyperspaceRewardRow>& row : table){
37+
if (row->item.slug() == item_slug){
38+
return true;
39+
}
40+
}
41+
return false;
42+
}
43+
44+
std::vector<std::string> HyperspaceRewardTable::selected_items() const{
45+
std::vector<std::unique_ptr<HyperspaceRewardRow>> table = copy_snapshot();
46+
std::vector<std::string> slugs;
47+
for (const std::unique_ptr<HyperspaceRewardRow>& row : table){
48+
slugs.emplace_back(row->item.slug());
49+
}
50+
return slugs;
51+
}
52+
53+
54+
std::vector<std::string> HyperspaceRewardTable::make_header() const{
55+
return std::vector<std::string>{
56+
"Item",
57+
};
58+
}
59+
60+
std::vector<std::unique_ptr<EditableTableRow>> HyperspaceRewardTable::make_defaults(){
61+
std::vector<std::unique_ptr<EditableTableRow>> ret;
62+
ret.emplace_back(std::make_unique<HyperspaceRewardRow>(*this));
63+
return ret;
64+
}
65+
66+
67+
68+
69+
70+
71+
}
72+
}
73+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Hyperspace Reward Table
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLZA_HyperspaceRewardTable_H
8+
#define PokemonAutomation_PokemonLZA_HyperspaceRewardTable_H
9+
10+
#include "Common/Cpp/Options/EditableTableOption.h"
11+
#include "PokemonLZA_HyperspaceRewardOption.h"
12+
13+
namespace PokemonAutomation{
14+
namespace NintendoSwitch{
15+
namespace PokemonLZA{
16+
17+
18+
19+
class HyperspaceRewardRow : public EditableTableRow{
20+
public:
21+
HyperspaceRewardRow(EditableTableOption& parent_table);
22+
virtual std::unique_ptr<EditableTableRow> clone() const override;
23+
24+
public:
25+
HyperspaceRewardCell item;
26+
};
27+
28+
29+
30+
class HyperspaceRewardTable : public EditableTableOption_t<HyperspaceRewardRow>{
31+
public:
32+
HyperspaceRewardTable(std::string label);
33+
34+
35+
// Whether item_slug is among the selected items.
36+
bool find_item(const std::string& item_slug) const;
37+
std::vector<std::string> selected_items() const;
38+
39+
virtual std::vector<std::string> make_header() const override;
40+
41+
std::vector<std::unique_ptr<EditableTableRow>> make_defaults();
42+
};
43+
44+
45+
46+
47+
48+
}
49+
}
50+
}
51+
#endif

SerialPrograms/SourceFiles.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ file(GLOB LIBRARY_SOURCES
16211621
Source/PokemonLZA/Options/PokemonLZA_BattleAIOption.h
16221622
Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardOption.cpp
16231623
Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardOption.h
1624+
Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardTable.cpp
1625+
Source/PokemonLZA/Options/PokemonLZA_HyperspaceRewardTable.h
16241626
Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp
16251627
Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h
16261628
Source/PokemonLZA/PokemonLZA_Panels.cpp

0 commit comments

Comments
 (0)