@@ -82,7 +82,7 @@ SelfTouchTrade::SelfTouchTrade()
8282
8383bool SelfTouchTrade::trade_one (
8484 MultiSwitchProgramEnvironment& env, CancellableScope& scope,
85- std::map<std::string, uint8_t >& trades_left
85+ std::map<std::string, SimpleIntegerCell< uint8_t >* >& trades_left
8686){
8787 TradeStats& stats = env.current_stats <TradeStats>();
8888
@@ -99,7 +99,8 @@ bool SelfTouchTrade::trade_one(
9999 dump_image (host, env.program_info (), " ReadName" , snapshot);
100100 return false ;
101101 }
102- if (iter->second <= 0 ){
102+ uint8_t current_trades_left = iter->second ->current_value ();
103+ if (current_trades_left <= 0 ){
103104 host.log (STRING_POKEMON + " not needed anymore. Moving on..." );
104105 return false ;
105106 }
@@ -109,14 +110,14 @@ bool SelfTouchTrade::trade_one(
109110 }
110111
111112 // Perform trade.
112- host.log (" \" " + slug + " \" - Trades Remaining: " + std::to_string (iter-> second ));
113+ host.log (" \" " + slug + " \" - Trades Remaining: " + std::to_string (current_trades_left ));
113114#if 1
114115 MultiConsoleErrorState error_state;
115116 env.run_in_parallel (scope, [&](ConsoleHandle& console, ProControllerContext& context){
116117 trade_current_pokemon (console, context, error_state, stats);
117118 });
118119 stats.m_trades ++;
119- iter->second -- ;
120+ iter->second -> set (current_trades_left - 1 ) ;
120121#else
121122 env.wait_for(std::chrono::milliseconds(5000));
122123 return false;
@@ -154,9 +155,9 @@ bool SelfTouchTrade::move_to_next(Logger& logger, ProControllerContext& host, ui
154155
155156void SelfTouchTrade::program (MultiSwitchProgramEnvironment& env, CancellableScope& scope){
156157 // Build list of what's needed.
157- std::map<std::string, uint8_t > trades_left;
158- for (const StaticTableRow* item : TRADE_COUNTS.table ()){
159- trades_left[item->slug ()] = static_cast <const TradeCountTableRow&>(*item).count ;
158+ std::map<std::string, SimpleIntegerCell< uint8_t >* > trades_left;
159+ for (StaticTableRow* item : TRADE_COUNTS.table ()){
160+ trades_left[item->slug ()] = & static_cast <TradeCountTableRow&>(*item).count ;
160161 }
161162
162163 // Connect both controllers.
0 commit comments