diff --git a/game/game.py b/game/game.py index c71cc688..a69da6d6 100644 --- a/game/game.py +++ b/game/game.py @@ -91,6 +91,7 @@ class Game: events = None # type: typing.List[Event] pending_transfers = None # type: typing.Dict[] ignored_cps = None # type: typing.Collection[ControlPoint] + turn = 0 def __init__(self, player_name: str, enemy_name: str, theater: ConflictTheater): self.settings = Settings() @@ -98,6 +99,7 @@ class Game: self.theater = theater self.player = player_name self.enemy = enemy_name + self.turn = 0 def _roll(self, prob, mult): if self.settings.version == "dev": @@ -265,6 +267,9 @@ class Game: def pass_turn(self, no_action=False, ignored_cps: typing.Collection[ControlPoint]=None): logging.info("Pass turn") + + self.turn = self.turn + 1 + for event in self.events: if self.settings.version == "dev": # don't damage player CPs in by skipping in dev mode diff --git a/ui/mainmenu.py b/ui/mainmenu.py index 79f95cfb..53aadbff 100644 --- a/ui/mainmenu.py +++ b/ui/mainmenu.py @@ -33,6 +33,7 @@ class MainMenu(Menu): def pass_turn(self): self.game.pass_turn(no_action=True) + self.upd.update() self.display() def configuration_menu(self): diff --git a/ui/overviewcanvas.py b/ui/overviewcanvas.py index 39d677d4..afd5eaa0 100644 --- a/ui/overviewcanvas.py +++ b/ui/overviewcanvas.py @@ -99,10 +99,16 @@ class OverviewCanvas: Button(self.options, text="Configuration", command=self.parent.configuration_menu, **STYLES["btn-primary"]).grid(column=col, row=0, sticky=NE) col += 1 - self.budget_label = Label(self.options, text="Budget: {}m (+{}m)".format(self.game.budget, self.game.budget_reward_amount), **STYLES["widget"]) + self.current_budget = StringVar() + self.budget_label = Label(self.options, textvariable=self.current_budget, **STYLES["widget"]) self.budget_label.grid(column=col, row=0, sticky=N+EW) col += 1 + self.current_turn = StringVar() + self.turn_label = Label(self.options, textvariable=self.current_turn, **STYLES["widget"]) + self.turn_label.grid(column=col, row=0, sticky=N+EW) + col += 1 + Button(self.options, text="Pass turn", command=self.parent.pass_turn, **STYLES["btn-primary"]).grid(column=col, row=0, sticky=NW) col += 1 @@ -180,6 +186,7 @@ class OverviewCanvas: i = 0 while not self.exited: self.clock.tick(30) + self.updateOptions() self.draw() i += 1 if i == 600: @@ -207,18 +214,19 @@ class OverviewCanvas: if event.type == pygame.MOUSEMOTION: self.redraw_required = True elif event.type == pygame.MOUSEBUTTONDOWN: + """ Due to rendering not really supporting the zoom this is currently disabled. @TODO: improve rendering so zoom would actually make sense - # Scroll wheel + # Scroll wheel""" if event.button == 4: self.zoom += 0.25 self.redraw_required = True elif event.button == 5: self.zoom -= 0.25 self.redraw_required = True - """ + """""" if event.button == 3: right_down = True @@ -226,6 +234,15 @@ class OverviewCanvas: if event.button == 1: left_down = True self.redraw_required = True + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_F2: + self.display_bases.set(not self.display_bases.get()) + elif event.key == pygame.K_F3: + self.display_forces.set(not self.display_forces.get()) + elif event.key == pygame.K_F4: + self.display_ground_targets.set(not self.display_ground_targets.get()) + elif event.key == pygame.K_F5: + self.display_road.set(not self.display_road.get()) # If Right click pressed if pygame.mouse.get_pressed()[2] == 1 and not right_down: @@ -320,7 +337,7 @@ class OverviewCanvas: for cp in self.game.theater.controlpoints: coords = self._transform_point(cp.position) radius = 12 * math.pow(cp.importance, 1) - radius_m = radius * max(cp.base.strength - 2, 0) + radius_m = max(radius * cp.base.strength - 2, 0) if cp.captured: color = self._player_color() @@ -588,7 +605,6 @@ class OverviewCanvas: def update(self): self.redraw_required = True self.draw() - self.budget_label.text = "Budget: {}m (+{}m)".format(self.game.budget, self.game.budget_reward_amount) def compute_display_rules(self): return sum([1 if a.get() else 0 for a in [self.display_forces, self.display_road, self.display_bases, self.display_ground_targets]]) @@ -598,3 +614,7 @@ class OverviewCanvas: return self.parent.go_cp(cp) return action + + def updateOptions(self): + self.current_turn.set("Turn : {}".format(self.game.turn)) + self.current_budget.set("Budget: {}m (+{}m)".format(self.game.budget, self.game.budget_reward_amount)) \ No newline at end of file