Skip to content

Commit

Permalink
[wip] start save orders
Browse files Browse the repository at this point in the history
  • Loading branch information
theludovyc committed Jan 3, 2025
1 parent 360c4e5 commit 35cdb2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions theLudovyc/Game2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class_name Game2D
@onready var the_storage := $TheStorage
@onready var the_bank := $TheBank
@onready var the_factory := $TheFactory
@onready var the_market := $TheMarket
@onready var the_builder := $TheBuilder

@onready var gui := $GUI
Expand Down Expand Up @@ -264,6 +265,7 @@ func _on_PauseMenu_ask_to_save() -> void:
dicoToSave.merge(the_storage.get_storage_save())
dicoToSave.merge(the_bank.get_bank_save())
dicoToSave.merge(the_factory.get_factory_save())
dicoToSave.merge(the_market.get_market_save())
dicoToSave.merge(the_builder.get_buildings_save())

pause_menu.save_this_please(dicoToSave)
14 changes: 13 additions & 1 deletion theLudovyc/TheMarket.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class Order:
var buy_amount := 0
var sell_amount := 0

func _to_json() -> Array:
return [buy_amount, sell_amount]

var orders = {}
var orders := {}


func _ready():
Expand Down Expand Up @@ -99,3 +101,13 @@ func _on_TheTicker_cycle():

if the_storage.try_to_sell_resource(order_key, order.sell_amount):
the_bank.conclude_sale(order_key, order.sell_amount)

func get_market_save() -> Dictionary:
var data_to_save := {}

for resource_type in orders:
var order = orders[resource_type]

data_to_save[resource_type] = order._to_json()

return {"Market": data_to_save}

0 comments on commit 35cdb2d

Please sign in to comment.