-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
128 lines (100 loc) · 3.13 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# This file is the main file of the game. It contains the main loop of the game and the game logic.
# [このファイルはゲームのメインファイルです。ゲームのメインループとゲームロジックが含まれています。]
from Agent import Agent
from Game import Game
from Params import *
from Util import log
from datetime import datetime as dt
import threading
import time
from queue import Queue
from HoveringBox import *
from pygame.locals import *
from Game_start import Game_start
try:
with open("Logs/logs.txt", 'w') as file: pass
except:
os.makedirs("Logs", exist_ok=True)
log("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n")
log(dt.now().strftime("%m/%d/%Y, %H:%M:%S"))
'''
====================
Initializing Agents [エージェントの初期化]
====================
'''
log('\n=======Initializing Agents=======\n')
graphics = [{'x':InitialPositions[i][0],'y':InitialPositions[i][1],'width':64, 'height':64, 'folder_name': f'character_0{i+1}', 'initialLocation': "Tavern"} for i in range(len(agentsDetails))]
class getAgents():
def __init__(self):
self.agents = [None]*len(agentsDetails)
# Create the agents [エージェントの作成]
def makeAgent(self,i):
self.agents[i] = Agent(agentsDetails[i]['name'],agentsDetails[i]['description'],graphics[i])
agentMap[agentsDetails[i]['name']] = self.agents[i]
# Create the threads for each agent [各エージェントのスレッドを作成する]
def get(self):
threads = []
for i in range(len(agentsDetails)):
thread = threading.Thread(target=self.makeAgent, args=(i,))
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
return self.agents
agents = getAgents().get()
if(None in agents):
agents = [Agent(agent['name'],agent['description'],graphics[i]) for i,agent in enumerate(agentsDetails)]
'''
====================
Initializing Game [ゲームの初期化]
====================
'''
log('\n=======Initializing Game=======\n')
game = Game(agents)
'''
====================
Game Start Button [試合開始ボタン]
====================
'''
game_start = Game_start(game.win)
game_start.start()
'''
====================
Werewolf Game [LOGIC] [人狼ゲーム[ロジック]]
====================
'''
log('\n=======Werewolf Game=======\n')
def game_logic():
time.sleep(1)
day = 2
while game.run:
if(day<2):
game.switchPhase()
if(day==0):
log('\n======= Night Phase =======\n')
game.nightVote()
if(day==1):
log('\n======= Morning Voting Phase =======\n')
game.dayVote()
if(day==2):
log('\n======= Day Tasks Phase =======\n')
game.afternoon()
day = (day+1)%3
'''
====================
Werewolf Game [GRAPHICS] [人狼ゲーム [GRAPHICS]]
====================
'''
def render():
while game.run :
game.clock.tick(FPS)
game.step()
'''
====================
Running Game using Multi-Threading [マルチスレッドによるゲームの実行]
====================
'''
logic_thread = threading.Thread(target=game_logic)
logic_thread.start()
if __name__ == '__main__':
render()