diff --git a/src/inventory_wars/gui/app.py b/src/inventory_wars/gui/app.py index 2fd6ec0..c8af7b1 100644 --- a/src/inventory_wars/gui/app.py +++ b/src/inventory_wars/gui/app.py @@ -12,7 +12,7 @@ from star_resonance_tracer.proto.enum_chit_chat_channel_type_pb2 import ChitChat from inventory_wars.game import Game from inventory_wars.models import Base, ItemShare -from inventory_wars.scoring import FirstGuess, FirstThenHighest +from inventory_wars.scoring import FirstGuess, FirstThenHighest, HighestAmount from inventory_wars.state import GameOngoing, GameIdle QML_IMPORT_NAME = "InventoryWars" @@ -37,6 +37,22 @@ class FirstGuessGui(FirstGuess): return result +class HighestAmountGui(HighestAmount): + def __init__(self, game: GameService): + super().__init__() + self.game = game + self.guessed = False + + def calculate_score(self, item: ItemShare) -> int: + previous_max = self.max + if not self.guessed: + self.game.reveal() + self.game.guessed.emit(item.user.username, self.game.elapsedSeconds) + if previous_max is not self.max: + self.game.highest.emit(item.user.username, item.count) + return 0 + + class FirstThenHighestGui(FirstThenHighest): def __init__(self, game: GameService): super().__init__() @@ -55,13 +71,16 @@ class FirstThenHighestGui(FirstThenHighest): class GameScoring(Enum): FirstGuess = 0 - FirstGuessThenHighestAmount = 1 + HighestAmount = 1 + FirstGuessThenHighestAmount = 2 @property - def as_scoring(self) -> type[FirstGuessGui | FirstThenHighestGui]: + def as_scoring(self) -> type[FirstGuessGui | HighestAmount | FirstThenHighestGui]: match self: case self.FirstGuess: return FirstGuessGui + case self.HighestAmount: + return HighestAmountGui case self.FirstGuessThenHighestAmount: return FirstThenHighestGui case _: