Skip to content

Commit f457ade

Browse files
committed
Log the move effectiveness results.
1 parent 6bd0723 commit f457ade

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,15 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
314314
VideoOverlaySet overlays(overlay);
315315

316316

317-
close_game_from_home(console, context);
317+
std::string move_results = "Move Effectiveness:";
318+
move_results += "\n- Top: " + std::string("asdf");
319+
move_results += "\n- Left: " + std::string("asdf");
320+
move_results += "\n- Right: " + std::string("asdf");
321+
move_results += "\n- Bottom: " + std::string("asdf");
322+
console.log(move_results);
323+
324+
325+
// close_game_from_home(console, context);
318326

319327

320328
#if 0

SerialPrograms/Source/PokemonLZA/Inference/Battles/PokemonLZA_MoveEffectivenessSymbol.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ const char* template_path(MoveEffectivenessSymbol symbol){
3535
}
3636

3737

38+
const char* to_string(MoveEffectivenessSymbol symbol){
39+
switch (symbol){
40+
case MoveEffectivenessSymbol::NoEffect:
41+
return "No Effect";
42+
case MoveEffectivenessSymbol::NotVeryEffective:
43+
return "Not Very Effective";
44+
case MoveEffectivenessSymbol::Normal:
45+
return "Effective";
46+
case MoveEffectivenessSymbol::SuperEffective:
47+
return "Super Effective";
48+
default:
49+
return nullptr;
50+
}
51+
}
52+
53+
54+
55+
3856
MoveEffectivenessSymbolMatcher::MoveEffectivenessSymbolMatcher(MoveEffectivenessSymbol symbol)
3957
: WaterfillTemplateMatcher(
4058
template_path(symbol),

SerialPrograms/Source/PokemonLZA/Inference/Battles/PokemonLZA_MoveEffectivenessSymbol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum class MoveEffectivenessSymbol{
2828
Normal,
2929
SuperEffective,
3030
};
31+
const char* to_string(MoveEffectivenessSymbol symbol);
3132

3233

3334

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_TrainerBattle.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "PokemonLZA/Inference/Battles/PokemonLZA_MoveEffectivenessSymbol.h"
1515
#include "PokemonLZA_TrainerBattle.h"
1616

17+
//#include <iostream>
18+
//using std::cout;
19+
//using std::endl;
20+
1721
namespace PokemonAutomation{
1822
namespace NintendoSwitch{
1923
namespace PokemonLZA{
@@ -25,6 +29,13 @@ TrainerBattleState::TrainerBattleState(BattleAIOption& settings)
2529
{}
2630

2731

32+
std::string move_effectiveness_detection(MoveEffectivenessSymbol symbol){
33+
const char* str = to_string(symbol);
34+
if (str){
35+
return str;
36+
}
37+
return "(Unable to Detect)";
38+
}
2839

2940

3041
bool TrainerBattleState::attempt_one_attack(
@@ -34,7 +45,7 @@ bool TrainerBattleState::attempt_one_attack(
3445
){
3546
AsyncCommandSession<ProController> command(
3647
context,
37-
env.logger(),
48+
console.logger(),
3849
env.realtime_dispatcher(),
3950
context
4051
);
@@ -44,7 +55,7 @@ bool TrainerBattleState::attempt_one_attack(
4455
pbf_press_button(context, BUTTON_ZL, 5000ms, 0ms);
4556
});
4657

47-
env.log("Begin looking for type symbols.");
58+
console.log("Begin looking for type symbols.");
4859

4960
int ret = wait_until(
5061
console, context, 1000ms,
@@ -61,6 +72,13 @@ bool TrainerBattleState::attempt_one_attack(
6172
return false;
6273
}
6374

75+
std::string move_results = "Move Effectiveness:";
76+
move_results += "\n- Top: " + move_effectiveness_detection(move_watcher[0]);
77+
move_results += "\n- Left: " + move_effectiveness_detection(move_watcher[1]);
78+
move_results += "\n- Right: " + move_effectiveness_detection(move_watcher[2]);
79+
move_results += "\n- Bottom: " + move_effectiveness_detection(move_watcher[3]);
80+
console.log(move_results);
81+
6482
static const Button BUTTON_INDEX[] = {
6583
BUTTON_X,
6684
BUTTON_Y,
@@ -90,7 +108,7 @@ bool TrainerBattleState::attempt_one_attack(
90108
}
91109
}
92110

93-
env.log(STRING_INDEX[best_index], COLOR_BLUE);
111+
console.log(STRING_INDEX[best_index], COLOR_BLUE);
94112
console.overlay().add_log(STRING_INDEX[best_index]);
95113

96114
command.dispatch([&](ProControllerContext& context){

0 commit comments

Comments
 (0)