feat: add separate highest amount gui logic
This commit is contained in:
@@ -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.game import Game
|
||||||
from inventory_wars.models import Base, ItemShare
|
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
|
from inventory_wars.state import GameOngoing, GameIdle
|
||||||
|
|
||||||
QML_IMPORT_NAME = "InventoryWars"
|
QML_IMPORT_NAME = "InventoryWars"
|
||||||
@@ -37,6 +37,22 @@ class FirstGuessGui(FirstGuess):
|
|||||||
return result
|
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):
|
class FirstThenHighestGui(FirstThenHighest):
|
||||||
def __init__(self, game: GameService):
|
def __init__(self, game: GameService):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -55,13 +71,16 @@ class FirstThenHighestGui(FirstThenHighest):
|
|||||||
|
|
||||||
class GameScoring(Enum):
|
class GameScoring(Enum):
|
||||||
FirstGuess = 0
|
FirstGuess = 0
|
||||||
FirstGuessThenHighestAmount = 1
|
HighestAmount = 1
|
||||||
|
FirstGuessThenHighestAmount = 2
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def as_scoring(self) -> type[FirstGuessGui | FirstThenHighestGui]:
|
def as_scoring(self) -> type[FirstGuessGui | HighestAmount | FirstThenHighestGui]:
|
||||||
match self:
|
match self:
|
||||||
case self.FirstGuess:
|
case self.FirstGuess:
|
||||||
return FirstGuessGui
|
return FirstGuessGui
|
||||||
|
case self.HighestAmount:
|
||||||
|
return HighestAmountGui
|
||||||
case self.FirstGuessThenHighestAmount:
|
case self.FirstGuessThenHighestAmount:
|
||||||
return FirstThenHighestGui
|
return FirstThenHighestGui
|
||||||
case _:
|
case _:
|
||||||
|
|||||||
Reference in New Issue
Block a user