| 244 | } |
| 245 | |
| 246 | void Scene_Shop::UpdateBuySelection() { |
| 247 | status_window->SetItemId(buy_window->GetItemId()); |
| 248 | party_window->SetItemId(buy_window->GetItemId()); |
| 249 | |
| 250 | if (Input::IsTriggered(Input::CANCEL)) { |
| 251 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cancel)); |
| 252 | if (allow_sell) { |
| 253 | SetMode(BuySellLeave2); |
| 254 | } else { |
| 255 | Scene::Pop(); |
| 256 | } |
| 257 | } else if (Input::IsTriggered(Input::DECISION)) { |
| 258 | int item_id = buy_window->GetItemId(); |
| 259 | |
| 260 | // checks the money and number of items possessed before buy |
| 261 | if (buy_window->CheckEnable(item_id)) { |
| 262 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision)); |
| 263 | |
| 264 | // Items are guaranteed to be valid |
| 265 | const lcf::rpg::Item* item = lcf::ReaderUtil::GetElement(lcf::Data::items, item_id); |
| 266 | |
| 267 | int max = Main_Data::game_party->GetMaxItemCount(item_id) - Main_Data::game_party->GetItemCount(item_id); |
| 268 | if (item->price > 0) { |
| 269 | max = std::min<int>(max, Main_Data::game_party->GetGold() / item->price); |
| 270 | } |
| 271 | number_window->SetData(item_id, max, item->price); |
| 272 | |
| 273 | SetMode(BuyHowMany); |
| 274 | } |
| 275 | else { |
| 276 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Buzzer)); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | void Scene_Shop::UpdateSellSelection() { |
| 282 | if (Input::IsTriggered(Input::CANCEL)) { |
nothing calls this directly
no test coverage detected