Add shop sell-back

This commit is contained in:
2026-06-18 03:17:25 +09:00
parent 618a780796
commit 6bba22a562
6 changed files with 148 additions and 8 deletions

View File

@@ -256,6 +256,25 @@ func try_buy_item(item_id: String, price: int) -> bool:
return false
func try_sell_item(item_id: String, sale_price: int) -> bool:
if item_id.is_empty() or sale_price <= 0:
return false
var previous_count := int(inventory.get(item_id, 0))
if previous_count <= 0:
return false
var previous_gold := gold
gold += sale_price
if previous_count > 1:
inventory[item_id] = previous_count - 1
else:
inventory.erase(item_id)
if save_game():
return true
gold = previous_gold
inventory[item_id] = previous_count
return false
func try_save_prebattle_loadout(roster_snapshot: Dictionary, inventory_snapshot: Dictionary) -> bool:
var previous_roster := roster.duplicate(true)
var previous_inventory := inventory.duplicate(true)