void PlayerInst::purchase_from_store(GameState* gs, const GameAction& action) { StoreInst* store = (StoreInst*)gs->get_instance(action.use_id); if (!store) { return; } LANARTS_ASSERT(dynamic_cast<StoreInst*>(gs->get_instance(action.use_id))); StoreInventory& inv = store->inventory(); StoreItemSlot& slot = inv.get(action.use_id2); if (gold() >= slot.cost) { inventory().add(slot.item); gold() -= slot.cost; slot.item.clear(); } }