commit 15b0b7d285245f6f26e4f6d9b4fe91f12f2fe326 Author: yoxu Date: Tue Sep 2 21:14:55 2025 +0200 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b694934 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/Players.txt b/Players.txt new file mode 100644 index 0000000..e0f4762 --- /dev/null +++ b/Players.txt @@ -0,0 +1,10 @@ +Marie +Jeanne +Paul +Jean +Michel +Christophe +Anne +Julien +Aurélie +Yoxu \ No newline at end of file diff --git a/Roles.txt b/Roles.txt new file mode 100644 index 0000000..aae537c --- /dev/null +++ b/Roles.txt @@ -0,0 +1,10 @@ +Wolf +Wolf +WhiteWolf +Cupidon +Witch +Hunter +Corbeau +Stealer +Sorcier +Savior \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..aee98f3 --- /dev/null +++ b/main.py @@ -0,0 +1,97 @@ + +import random +import time + +playerFile = open("Players.txt") +rolesFile = open ("Roles.txt") + +PlayersName = [] +RolesList = [] +KilledDuringNight = [] +PlayersInLove = [] +players_dict = {} + + + +def GiveRoleToPlayers(): + if PlayersName and RolesList: + for player in PlayersName: + ChoseRole = random.choice(RolesList) + players_dict[player] = {'name': player, 'role': ChoseRole, 'alive': True, 'InLove': False, 'Protected': False} + RolesList.remove(ChoseRole) + else: + print("Players are not initialized") + + +def CreateLists(): + for line in playerFile: + PlayersName.append(line.strip()) + for line in rolesFile: + RolesList.append(line.strip()) + playerFile.close() + rolesFile.close() + + +def Kill(player): + if players_dict[player]['InLove'] == False: + players_dict[player]['alive'] = False + KilledDuringNight.append(player) + elif players_dict[player]['InLove'] == True: + print("in love check") + for player in players_dict: + if players_dict[player]['InLove'] == True: + print("found one") + players_dict[player]['alive'] = False + KilledDuringNight.append(player) + elif players_dict[player]['Protected'] == True: + return + + + +def Revive(player): + players_dict[player]["alive"] = True + KilledDuringNight.remove(player) +def PutInLove(player1, player2): + players_dict[player1]['InLove'] = True + players_dict[player2]['InLove'] = True + time.sleep(1) + print("The people selected wake up and show their role") + time.sleep(1) + print("They go back to sleep") + +def Cupidon(): + print("You choose two people to be linked to the death") + player1 = SelectSomeone() + player2 = SelectSomeone() + PutInLove(player1, player2) + +def Savior(): + print("You choose someone to protect") + ProtectedPlayer = SelectSomeone() + players_dict[ProtectedPlayer]['Protected'] = False + + + +def SelectSomeone(): + while True: + SelectedPlayer = input("Enter the name of the player:") + if SelectedPlayer in PlayersName: + return SelectedPlayer + else: + print("This player don't exist") + +def FirstDayCycle(): + print("The villagers fall asleep") + time.sleep(1) + print("Cupidon get up") + Cupidon() + print("Cupidon go back to sleep") + time.sleep(1) + print("The savior get up") + Savior() + + + +CreateLists() +GiveRoleToPlayers() +FirstDayCycle() \ No newline at end of file