Fix GroundObjectBuy Menu after buy or sell

- Close the Buy Menu after complete buy
- Update the Ground Object Dialog with the changes
- Update the Game & map correctly
This commit is contained in:
RndName
2022-03-22 15:20:42 +01:00
parent f0a3fd1e3a
commit e93639e1ab
2 changed files with 26 additions and 19 deletions

View File

@@ -202,21 +202,25 @@ class QGroundObjectMenu(QDialog):
self.update_total_value()
self.game.blue.budget = self.game.blue.budget + self.total_value
self.ground_object.groups = []
self.update_game()
# Replan if the tgo was a target of the redfor
def buy_group(self) -> None:
self.subwindow = QGroundObjectBuyMenu(
self, self.ground_object, self.game, self.total_value
)
if self.subwindow.exec_():
self.update_game()
def update_game(self) -> None:
events = GameUpdateEvents()
events.update_tgo(self.ground_object)
if any(
package.target == self.ground_object
for package in self.game.ato_for(player=False).packages
):
events = GameUpdateEvents()
# Replan if the tgo was a target of the redfor
self.game.initialize_turn(events, for_red=True, for_blue=False)
EventStream.put_nowait(events)
self.do_refresh_layout()
EventStream.put_nowait(events)
GameUpdateSignal.get_instance().updateGame(self.game)
def buy_group(self):
self.subwindow = QGroundObjectBuyMenu(
self, self.ground_object, self.game, self.total_value
)
self.subwindow.show()
# Refresh the dialog
self.do_refresh_layout()