WIP: Add new role witch #2

Manually merged
yoxu merged 6 commits from dev into main 2025-09-06 20:59:12 +02:00
Showing only changes of commit ce60013fbd - Show all commits

Fix witch function

yoxu 2025-09-06 15:40:24 +02:00

21
main.py
View file

@ -274,12 +274,13 @@ class Game:
def witch(self) -> None:
"""Interactively choose to kill or revive someone"""
yoxu marked this conversation as resolved

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?

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?
log.info("With the Revive Potion, you can revive someone, and with the Death Potion, you can kill someone. You can only use each potion once, and you can also choose to do nothing.")
log.info("Players who might die are %s", ' '.join(map(str, self.dead_this_night)))
if len(self.used_potions) == 2:
log.info("You already used all of your potions. ")
else:
elif len(self.used_potions) != 2:
while True:
options = ("Death", "Revive", "Nothing")
anavoi marked this conversation as resolved

potionchoice = self.choose_between(options).capitalise()

`potionchoice = self.choose_between(options).capitalise()`
potionchoice = self.choose_between(options)
potionchoice = self.choose_between(options).capitalise()
if potionchoice == "Revive" and "Revive" not in self.used_potions:
player = self.select_someone()
if player in self.dead_this_night:
@ -288,8 +289,11 @@ class Game:
return
elif player not in self.dead_this_night and not self.players[player].alive:
log.info("You cannot bring this person back to life because they have been buried.")
else:
elif
log.info("This player is not dead.")
else:
log.info("Unknown error: Invalid player choice")
return
elif potionchoice == "Death" and "Death" not in self.used_potions:
player = self.select_someone()
if self.players[player].alive:
@ -297,13 +301,22 @@ class Game:
self.kill(player)
return
elif not self.players[player].alive:
self.used_potions.append("Death")
log.info("This player is already dead.")
else:
log.info("Unknown error: Invalid player choice")
return
elif potionchoice == "Nothing":
log.info("You are not doing anything tonight.")
return
elif potionchoice in self.used_potions:
log.info("You already used this potion.")
else:
log.critical("Unknown error: Invalid potion choice.")
return
else:
log.critical("Unknown error: Invalid check")
# -------------------------
# game flow