WIP: Add new role witch #2
2 changed files with 49 additions and 2 deletions
Added role witch
commit
798b4ce276
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"potionchoice"
|
||||||
|
]
|
||||||
|
}
|
||||||
46
main.py
46
main.py
|
|
@ -21,6 +21,11 @@ class Game:
|
||||||
# lovers
|
# lovers
|
||||||
self.lovers: Optional[Tuple[str, str]] = None
|
self.lovers: Optional[Tuple[str, str]] = None
|
||||||
|
|
||||||
|
# Dead this night
|
||||||
|
self.dead_this_night: [List[str]] = []
|
||||||
|
|
||||||
|
# Used potions
|
||||||
|
self.used_potions: [list[str]] = []
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# setup / I/O
|
# setup / I/O
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
@ -95,7 +100,7 @@ class Game:
|
||||||
Prompt the user to enter a player name until a valid one is entered.
|
Prompt the user to enter a player name until a valid one is entered.
|
||||||
Returns None on EOF/KeyboardInterrupt.
|
Returns None on EOF/KeyboardInterrupt.
|
||||||
"""
|
"""
|
||||||
prompt = prompt or "Enter the name of the player: "
|
prompt = prompt or "Enter the name of the player: "
|
||||||
while True:
|
while True:
|
||||||
selected = input(prompt).strip()
|
selected = input(prompt).strip()
|
||||||
|
|
||||||
|
|
@ -157,15 +162,18 @@ class Game:
|
||||||
for p in self.lovers:
|
for p in self.lovers:
|
||||||
# kill them and their lover
|
# kill them and their lover
|
||||||
log.debug("Killed %s", p)
|
log.debug("Killed %s", p)
|
||||||
|
self.dead_this_night.append(p)
|
||||||
p.alive = False
|
p.alive = False
|
||||||
return
|
return
|
||||||
|
|
||||||
# else just kill them
|
# else just kill them
|
||||||
log.debug("Killed %s" % p)
|
log.info("Killed %s" % player)
|
||||||
|
self.dead_this_night.append(player)
|
||||||
target.alive = False
|
target.alive = False
|
||||||
|
|
||||||
def revive(self, player: str) -> None:
|
def revive(self, player: str) -> None:
|
||||||
"""Revive a player."""
|
"""Revive a player."""
|
||||||
|
log.info("Players that will die this night are: %s", self.dead_this_night)
|
||||||
if player not in self.players:
|
if player not in self.players:
|
||||||
log.error("Tried to revive unknown player: %s", player)
|
log.error("Tried to revive unknown player: %s", player)
|
||||||
return
|
return
|
||||||
|
|
@ -237,6 +245,38 @@ class Game:
|
||||||
self.players[protected].protected = True
|
self.players[protected].protected = True
|
||||||
log.debug("Protected: %s", protected)
|
log.debug("Protected: %s", protected)
|
||||||
|
|
||||||
|
@role
|
||||||
|
def witch(self) -> None:
|
||||||
|
"""Interactively choose to kill or revive someone"""
|
||||||
|
log.info("Choose if you want to use your revive potion")
|
||||||
|
print(self.players)
|
||||||
|
while True:
|
||||||
|
potionchoice = input("What do you want to use Revive or Death potion: ")
|
||||||
|
if potionchoice == "Revive" and "Revive" not in self.used_potions:
|
||||||
|
player = self.select_someone()
|
||||||
|
if player in self.dead_this_night:
|
||||||
|
self.used_potions.append("Revive")
|
||||||
|
self.revive(player)
|
||||||
|
return
|
||||||
|
elif player not in self.dead_this_night:
|
||||||
|
log.info("This player didn't died this night.")
|
||||||
|
elif "Revive" not in self.used_potions:
|
||||||
|
log.info("This potion is already used.")
|
||||||
|
elif potionchoice == "Death" and "Death" not in self.used_potions:
|
||||||
|
player = self.select_someone()
|
||||||
|
if self.players[player]:
|
||||||
|
self.used_potions.append("Death")
|
||||||
|
self.kill(player)
|
||||||
|
return
|
||||||
|
elif not self.players[player]:
|
||||||
|
self.used_potions.append("Death")
|
||||||
|
return
|
||||||
|
elif potionchoice in self.used_potions:
|
||||||
|
log.info("You already used all of your potions")
|
||||||
|
yoxu marked this conversation as resolved
|
|||||||
|
return
|
||||||
|
else:
|
||||||
|
log.info("Please write Revive or Death")
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# game flow
|
# game flow
|
||||||
|
anavoi marked this conversation as resolved
anavoi
commented
`potionchoice = self.choose_between(options).capitalise()`
|
|||||||
|
|
@ -245,6 +285,8 @@ class Game:
|
||||||
log.info("All the villagers fall asleep.")
|
log.info("All the villagers fall asleep.")
|
||||||
self.cupidon()
|
self.cupidon()
|
||||||
self.savior()
|
self.savior()
|
||||||
|
self.witch()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
So we first ask the user to choose a potion then we tell them that they have no choice.
Would you mind adding a check before asking?