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 a857221bed - Show all commits

Refactor witch function

yoxu 2025-09-06 20:05:20 +02:00
Signed by: yoxu
GPG key ID: CC1DC0EBE5E7D4E8

12
main.py
View file

@ -275,12 +275,12 @@ class Game:
"""Interactively choose to kill or revive someone""" """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("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))) log.info("Players who might die are %s", ' '.join(map(str, self.dead_this_night)))
if len(self.used_potions) == 2: if len(self.used_potions) >= 2:
log.info("You already used all of your potions. ") log.info("You already used all of your potions. ")
elif len(self.used_potions) != 2: else:
while True: while True:
options = ("Death", "Revive", "Nothing") 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).capitalise() potionchoice = self.choose_between(options).capitalize()
if potionchoice == "Revive" and "Revive" not in self.used_potions: if potionchoice == "Revive" and "Revive" not in self.used_potions:
player = self.select_someone() player = self.select_someone()
if player in self.dead_this_night: if player in self.dead_this_night:
@ -289,7 +289,7 @@ class Game:
return return
elif player not in self.dead_this_night and not self.players[player].alive: 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.") log.info("You cannot bring this person back to life because they have been buried.")
elif elif self.players[player].alive:
log.info("This player is not dead.") log.info("This player is not dead.")
else: else:
log.info("Unknown error: Invalid player choice") log.info("Unknown error: Invalid player choice")
@ -313,10 +313,6 @@ class Game:
else: else:
log.critical("Unknown error: Invalid potion choice.") log.critical("Unknown error: Invalid potion choice.")
return return
else:
log.critical("Unknown error: Invalid check")
# ------------------------- # -------------------------
# game flow # game flow