Compare commits
No commits in common. "9e8b7a3e4018e49ed653c3735a017da08ac2545f" and "c55315fa3eaf0701da01639cd213a3bff9ae0192" have entirely different histories.
9e8b7a3e40
...
c55315fa3e
3 changed files with 30 additions and 62 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -199,7 +199,7 @@ cython_debug/
|
||||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||||
# you could uncomment the following to ignore the entire vscode folder
|
# you could uncomment the following to ignore the entire vscode folder
|
||||||
# .vscode/
|
.vscode/
|
||||||
|
|
||||||
# Ruff stuff:
|
# Ruff stuff:
|
||||||
.ruff_cache/
|
.ruff_cache/
|
||||||
|
|
|
||||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"cSpell.words": [
|
|
||||||
"potionchoice"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
55
main.py
55
main.py
|
|
@ -120,31 +120,6 @@ class Game:
|
||||||
log.debug("Fuzz score: %s" % fuzz_score)
|
log.debug("Fuzz score: %s" % fuzz_score)
|
||||||
return fuzz_player
|
return fuzz_player
|
||||||
|
|
||||||
def choose_between(self, options):
|
|
||||||
#Prompt the user to choose between options until a valid one is entered
|
|
||||||
|
|
||||||
options_available = ', '.join(map(str, options))
|
|
||||||
#Make a prompt with a list of options, accepting either a list or a tuple.
|
|
||||||
prompt = f"Choose between {options_available}: "
|
|
||||||
while True:
|
|
||||||
selected = input(prompt)
|
|
||||||
|
|
||||||
if selected in options:
|
|
||||||
return selected
|
|
||||||
|
|
||||||
# fuzzy matching
|
|
||||||
match = process.extract(selected, options, limit=1)
|
|
||||||
log.debug(match)
|
|
||||||
if match:
|
|
||||||
fuzz_option, fuzz_score = match[0][0], match[0][1] #options, score
|
|
||||||
log.debug(fuzz_option)
|
|
||||||
log.debug(fuzz_score)
|
|
||||||
if fuzz_score >= 60:
|
|
||||||
log.info("You meant %s!", fuzz_option)
|
|
||||||
log.debug("Fuzz score: %s" % fuzz_score)
|
|
||||||
return fuzz_option
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# game actions
|
# game actions
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
@ -273,37 +248,35 @@ class Game:
|
||||||
@role
|
@role
|
||||||
def witch(self) -> None:
|
def witch(self) -> None:
|
||||||
"""Interactively choose to kill or revive someone"""
|
"""Interactively choose to kill or revive someone"""
|
||||||
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("Choose if you want to use your revive potion")
|
||||||
if len(self.used_potions) == 2:
|
print(self.players)
|
||||||
log.info("You already used all of your potions. ")
|
|
||||||
else:
|
|
||||||
while True:
|
while True:
|
||||||
options = ("Death", "Revive", "Nothing")
|
potionchoice = input("What do you want to use Revive or Death potion: ")
|
||||||
potionchoice = self.choose_between(options)
|
|
||||||
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:
|
||||||
self.used_potions.append("Revive")
|
self.used_potions.append("Revive")
|
||||||
self.revive(player)
|
self.revive(player)
|
||||||
return
|
return
|
||||||
elif player not in self.dead_this_night and not self.players[player].alive:
|
elif player not in self.dead_this_night:
|
||||||
log.info("You cannot bring this person back to life because they have been buried.")
|
log.info("This player didn't died this night.")
|
||||||
else:
|
elif "Revive" not in self.used_potions:
|
||||||
log.info("This player is not dead.")
|
log.info("This potion is already used.")
|
||||||
elif potionchoice == "Death" and "Death" not in self.used_potions:
|
elif potionchoice == "Death" and "Death" not in self.used_potions:
|
||||||
player = self.select_someone()
|
player = self.select_someone()
|
||||||
if self.players[player].alive:
|
if self.players[player]:
|
||||||
self.used_potions.append("Death")
|
self.used_potions.append("Death")
|
||||||
self.kill(player)
|
self.kill(player)
|
||||||
return
|
return
|
||||||
elif not self.players[player].alive:
|
elif not self.players[player]:
|
||||||
self.used_potions.append("Death")
|
self.used_potions.append("Death")
|
||||||
return
|
return
|
||||||
elif potionchoice == "Nothing":
|
|
||||||
log.info("You are not doing anything tonight.")
|
|
||||||
return
|
|
||||||
elif potionchoice in self.used_potions:
|
elif potionchoice in self.used_potions:
|
||||||
log.info("You already used this potion.")
|
log.info("You already used all of your potions")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
log.info("Please write Revive or Death")
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# game flow
|
# game flow
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue