updated roles, init tests, added states

This commit is contained in:
2021-03-12 00:59:38 +01:00
parent 8654e795fe
commit c6e8cc7d29
6 changed files with 193 additions and 39 deletions

View File

@@ -21,6 +21,13 @@ class GamePhase(enum.Enum):
PollResult = enum.auto()
Award = enum.auto()
class RoleGroup(enum.Enum):
NoGroup = enum.auto()
Villagers = enum.auto()
Werewolfs = enum.auto()
LovedOnes = enum.auto()
class Roles(enum.Enum):
NoRole = enum.auto()
Villager = enum.auto()
@@ -31,35 +38,52 @@ class Roles(enum.Enum):
Cupid = enum.auto()
Protector = enum.auto()
ParanormalInvestigator = enum.auto()
Lycantrop = enum.auto()
Lycantroph = enum.auto()
Spy = enum.auto()
Murder = enum.auto()
Pacifist = enum.auto()
OldMan = enum.auto()
Murder = enum.auto()
Leaderwolf = enum.auto()
@classmethod
def isWerwolf(cls, role: Roles):
return role in [cls.Werewolf, cls.Leaderwolf]
@classmethod
def getGroup(cls, role: Roles):
return RoleGroup.Werewolfs if role in [cls.Werewolf, cls.Leaderwolf] else RoleGroup.Villagers
class Rules(object):
showRoles: bool #`charaktereAufdecken` INT ( 2 ) DEFAULT 0,
passMajor: bool #`buergermeisterWeitergeben` INT ( 2 ) DEFAULT 0,
seerSeesIdentity: bool #`seherSiehtIdentitaet` INT ( 2 ) DEFAULT 1,
roleCount: t.Dict[Roles, int]
#`werwolfzahl` INT ( 5 ) DEFAULT 0 ,
#`hexenzahl` INT ( 5 ) DEFAULT 0 ,
#`seherzahl` INT ( 5 ) DEFAULT 0 ,
#`jaegerzahl` INT ( 5 ) DEFAULT 0 ,
#`amorzahl` INT ( 2 ) DEFAULT 0 ,
#`beschuetzerzahl` INT ( 5 ) DEFAULT 0 ,
#`parErmZahl` INT (5) DEFAULT 0 ,
#`lykantrophenzahl` INT ( 5 ) DEFAULT 0 ,
#`spionezahl` INT ( 5 ) DEFAULT 0 ,
#`idiotenzahl` INT ( 5 ) DEFAULT 0 ,
#`pazifistenzahl` INT ( 5 ) DEFAULT 0 ,
#`altenzahl` INT ( 5 ) DEFAULT 0 ,
#`urwolfzahl` INT ( 5 ) DEFAULT 0 ,
werewolfes: int
witches: int
seers: int
hunters: int
cupids: int
protectors: int
paranormals: int
lycantrophs: int
spys: int
murders: int
pacifists: int
oldmans: int
leaderwolfs: int
randomSelect: bool #`zufaelligeAuswahl` INT ( 2 ) DEFAULT 0 ,
randomBonus: int #`zufaelligeAuswahlBonus` INT ( 5 ) DEFAULT 0 ,
unanimously: bool #`werwolfeinstimmig` INT ( 2 ) DEFAULT 1 ,
timer_unanimously: int
timer_unanimously_per_wolf: int
timer_unsuccessfull: int
timer_unsuccessfull_per_wolf: int
timer_accusation: int
timer_accusation_per_player: int
timer_votation: int
timer_votation_per_player: int
timer_inactivity: int
timer_inactivity_per_player: int
@@ -74,6 +98,10 @@ class Player(object):
diedInRound: int
accusedBy: "Player"
@property
def isWerwolf(self):
return Roles.isWerwolf(self.role)
# `wahlAuf` INT ( 5 ) DEFAULT -1 ,
# `angeklagtVon` INT ( 5 ) DEFAULT -1 ,
@@ -92,29 +120,11 @@ class Player(object):
# `countdownBis` INT (10) DEFAULT 0 ,
# `countdownAb` INT (10) DEFAULT 0 ,
class Game(object):
class GameState(object):
currentPhase: GamePhase #`spielphase` INT( 5 ) DEFAULT 0,
gameRound: int
rules: Rules
log: t.List[str]
players: t.List[Player]
#`werwolfopfer` INT ( 5 ) DEFAULT -1 ,
#`werwolftimer1` INT ( 10 ) DEFAULT 60 ,
#`werwolfzusatz1` INT ( 10 ) DEFAULT 4 ,
#`werwolftimer2` INT ( 10 ) DEFAULT 50 ,
#`werwolfzusatz2` INT ( 10 ) DEFAULT 3 ,
#`dorftimer` INT ( 10 ) DEFAULT 550 ,
#`dorfzusatz` INT ( 10 ) DEFAULT 10 ,
#`dorfstichwahltimer` INT ( 10 ) DEFAULT 200 ,
#`dorfstichwahlzusatz` INT ( 10 ) DEFAULT 5 ,
#`inaktivzeit` INT ( 10 ) DEFAULT 40 ,
#`inaktivzeitzusatz` INT ( 10 ) DEFAULT 0 ,
#`tagestext` TEXT ,
#`nacht` INT ( 5 ) DEFAULT 1 ,
#`log` LONGTEXT ,
#`list_lebe` LONGTEXT,
#`list_lebe_aktualisiert` BIGINT DEFAULT 0,
#`list_tot` LONGTEXT,
#`list_tot_aktualisiert` BIGINT DEFAULT 0,
#`waiting_for_others_time` BIGINT,
#`letzterAufruf` BIGINT