Skip to content

Commit f544236

Browse files
committed
Rest auto market state when game begin
1 parent a8973b5 commit f544236

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

mods/auto_market/main.py

+34-38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import copy
2+
13
from api import Lord
24
from api import Ui
35
from api import Game
@@ -68,49 +70,36 @@
6870

6971
back = ui.load_image("./mods/auto_market/images/back.bmp")
7072

73+
default_list_of_number_of_goods = {"wood": -1, "stone": -1,
74+
"hops": -1,
75+
"iron": -1,
76+
"pitch": -1,
77+
"wheat": -1,
78+
"bread": -1,
79+
"cheese": -1,
80+
"meat": -1,
81+
"fruit": -1,
82+
"ale": -1,
83+
"flour": -1,
84+
"bows": -1,
85+
"crossbows": -1,
86+
"spears": -1,
87+
"pikes": -1,
88+
"maces": -1,
89+
"swords": -1,
90+
"leather_armor": -1,
91+
"metal_armor": -1}
92+
7193

7294
class MenuStatus:
7395
is_market_menu_open = False
7496
is_good_selected = False
7597
selected_good = None
76-
list_of_number_of_goods_to_sell = {"wood": -1, "stone": -1,
77-
"hops": -1,
78-
"iron": -1,
79-
"pitch": -1,
80-
"wheat": -1,
81-
"bread": -1,
82-
"cheese": -1,
83-
"meat": -1,
84-
"fruit": -1,
85-
"ale": -1,
86-
"flour": -1,
87-
"bows": -1,
88-
"crossbows": -1,
89-
"spears": -1,
90-
"pikes": -1,
91-
"maces": -1,
92-
"swords": -1,
93-
"leather_armor": -1,
94-
"metal_armor": -1}
95-
list_of_number_of_goods_to_buy = {"wood": -1, "stone": -1,
96-
"hops": -1,
97-
"iron": -1,
98-
"pitch": -1,
99-
"wheat": -1,
100-
"bread": -1,
101-
"cheese": -1,
102-
"meat": -1,
103-
"fruit": -1,
104-
"ale": -1,
105-
"flour": -1,
106-
"bows": -1,
107-
"crossbows": -1,
108-
"spears": -1,
109-
"pikes": -1,
110-
"maces": -1,
111-
"swords": -1,
112-
"leather_armor": -1,
113-
"metal_armor": -1}
98+
list_of_number_of_goods_to_sell = copy.copy(default_list_of_number_of_goods)
99+
list_of_number_of_goods_to_buy = copy.copy(default_list_of_number_of_goods)
100+
101+
102+
DefaultMenuStatus = MenuStatus
114103

115104

116105
def on_ui_tick_listener():
@@ -414,5 +403,12 @@ def on_game_tick_listener():
414403
my_lord.buy(24, 5)
415404

416405

406+
def on_game_begin():
407+
# Rest auto market state
408+
MenuStatus.list_of_number_of_goods_to_sell = copy.copy(default_list_of_number_of_goods)
409+
MenuStatus.list_of_number_of_goods_to_buy = copy.copy(default_list_of_number_of_goods)
410+
411+
417412
ui.set_on_tick_listener(on_ui_tick_listener)
418413
game.set_on_tick_listener(on_game_tick_listener)
414+
game.register_game_begin_listener(on_game_begin)

0 commit comments

Comments
 (0)