Add shop sell-back
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user