Compare commits

...

2 Commits

Author SHA1 Message Date
b69ff74c95 simple game statemachine 2021-03-21 14:23:30 +01:00
7437d683ad updated states 2021-03-14 14:21:33 +01:00
2 changed files with 24 additions and 95 deletions

103
README.md
View File

@@ -16,56 +16,15 @@ WaitingForPlayers --> StartGame: Start && ready
StartGame : Assign Player Roles
StartGame : Show Introduction
StartGame --> MainPhaseNight : all ready
state MainPhaseNight {
!include https://gitea.d1v3.de/matthias/pywerewolf/raw/branch/master/README.md!TheNight
}
MainPhaseNight --> Award: No Villagers left
MainPhaseNight --> MainPhaseDay: Some Villagers left
state MainPhaseDay {
!include https://gitea.d1v3.de/matthias/pywerewolf/raw/branch/master/README.md!TheDay
}
MainPhaseDay --> Award: No Werewolfes left
MainPhaseDay --> MainPhaseNight: Some Werewolfes left
@enduml
```
StartGame --> Night : All players ready
```plantuml
@startuml(id=TheNight)
hide empty description
[*] --> NightPhaseCupin:
NightPhaseCupin --> InformLovedOnes: Cupin selected
InformLovedOnes --> NightPhaseMain: ack
NightPhaseCupin --> NightPhaseMain : Cupin already selected or No Cupin
' state NightPhaseCupinEnd <<join>>
' NightPhaseCupin --> WaitToContinueCupin: !Cupin
' NightPhaseCupin --> SelectLovedOnes: Cupin
' WaitToContinueCupin --> NightPhaseCupinEnd
' SelectLovedOnes --> NightPhaseCupinEnd: selected and confirmed loved ones
Night --> SelectVictim
' state NightPhaseLovedOnes <<fork>>
' state NightPhaseLovedOnesEnd <<fork>>
' NightPhaseCupinEnd --> NightPhaseLovedOnes
' NightPhaseLovedOnes --> LovedOnesAwake: Selected Loved Ones
' NightPhaseLovedOnes --> WaitForLovedOnes: other
' LovedOnesAwake --> NightPhaseLovedOnesEnd: ready
' WaitForLovedOnes --> NightPhaseLovedOnesEnd
'
' NightPhaseLovedOnesEnd --> NightPhaseMain : all ready
SelectVictim --> KillVictim
KillVictim --> ShowDead: Some Villagers left
KillVictim --> Award: No Villagers left
state NightPhaseMain
NightPhaseMain --> NightPhaseLate : Witch/Leaderwolf &&\nvoted &&\nactions done and all ready
state NightPhaseLate
NightPhaseMain --> [*]: no Witch/Leaderwolf &&\nvoted &&\nactions done and all ready
NightPhaseLate --> [*]: actions taken
@enduml
```
```plantuml
@startuml(id=TheDay)
hide empty description
[*] --> ShowDead: Done
ShowDead: Show the Dead of the night
ShowDead --> Election: No Major
Election --> Discussion: Major elected
@@ -75,55 +34,8 @@ Accuse --> Poll : Accuse ok
Poll --> ShootTheConvict: Poll successfull
Poll --> Voting: Poll unsuccessfull
Voting --> ShootTheConvict: Voting Completed
ShootTheConvict --> [*]: Done
@enduml
```
```plantuml
@startuml(id=NightPhaseMain)
hide empty description
state NightPhaseMainStart <<fork>>
[*] --> NightPhaseMainStart
NightPhaseMainStart --> SelectVictim: Werewolfes || Spy
NightPhaseMainStart --> SelectIdentity: Seer
NightPhaseMainStart --> SelectProtectee: Protector
NightPhaseMainStart --> SeeWerewolfes: ParanormalInvestigator
NightPhaseMainStart --> Sleep: Villager
state NightPhaseMainEnd <<join>>
SelectVictim --> NightPhaseMainEnd: Werewolfes || Spy
SelectIdentity --> NightPhaseMainEnd: Done
SelectProtectee --> NightPhaseMainEnd: Done
SeeWerewolfes --> NightPhaseMainEnd: Done
Sleep --> NightPhaseMainEnd: Ready
NightPhaseMainEnd --> [*]
@enduml
```
```plantuml
@startuml(id=NightPhaseLate)
hide empty description
state NightPhaseLateStart <<fork>>
[*] --> NightPhaseLateStart
state "Witch selects\nHealing or Poison" as SelectHealOrPoison
state "Leaderwolf selects victim\nfor conversion" as SelectLeaderVictim
NightPhaseLateStart --> SelectHealOrPoison: Witch
NightPhaseLateStart --> SelectLeaderVictim: Leaderwolf
NightPhaseLateStart --> SleepAgain: Villager
state NightPhaseLateEnd <<join>>
SelectHealOrPoison --> NightPhaseLateEnd: Selection finished
SelectHealOrPoison -left-> SelectHealOrPoison: Next selection
SelectLeaderVictim --> NightPhaseLateEnd: Done
SleepAgain --> NightPhaseLateEnd
NightPhaseLateEnd --> [*]
ShootTheConvict --> Award: No Werewolfes left
ShootTheConvict --> Night: Some Werewolfes left
@enduml
```
@@ -132,3 +44,4 @@ NightPhaseLateEnd --> [*]

View File

@@ -149,6 +149,22 @@ class Game(object):
next=GameState.start_game,
)
],
GameState.start_game: [
TransitionObject(
name = "StartGame 2 MainPhaseNight",
inputType=GameMasterStartGame,
condition=[self.players_ready, self.no_cupin],
transition=self.assign_roles,
next=GameState.night_phase,
),
TransitionObject(
name = "StartGame 2 CupinSelect",
inputType=GameMasterStartGame,
condition=[self.has_cupin],
transition=self.assign_roles,
next=GameState.night_phase,
)
],
}
if game_id is None: