Initial Commit
This commit is contained in:
commit
15b0b7d285
4 changed files with 118 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.venv
|
||||
10
Players.txt
Normal file
10
Players.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Marie
|
||||
Jeanne
|
||||
Paul
|
||||
Jean
|
||||
Michel
|
||||
Christophe
|
||||
Anne
|
||||
Julien
|
||||
Aurélie
|
||||
Yoxu
|
||||
10
Roles.txt
Normal file
10
Roles.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Wolf
|
||||
Wolf
|
||||
WhiteWolf
|
||||
Cupidon
|
||||
Witch
|
||||
Hunter
|
||||
Corbeau
|
||||
Stealer
|
||||
Sorcier
|
||||
Savior
|
||||
97
main.py
Normal file
97
main.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue