-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
53 lines (39 loc) · 1.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
from copy import deepcopy
from game import Game, Project
from exceptions import *
import ui
SPEED = 10
def start_game():
Game.init_game()
over = False
win = False
while not (over or win):
action = ui.cli(Game.objects, Game.entities, Game.used_resources, Game.project.turn_events, Game.last_state)
Game.last_state = deepcopy(Game.project)
if action:
o = action(Game.project)
Game.objects.append(o)
for o in Game.objects:
if isinstance(o, Project):
continue
try:
o.turn()
except NotEnoughFundsException:
over = True
except WinException:
win = True
try:
Game.project.turn()
except NotEnoughFundsException:
over = True
except WinException:
win = True
Game.used_resources.turn_count += 1
ui.wait_anim(int(10/SPEED))
player = Game.objects[0]
if over:
ui.over(Game.project, player)
if win:
ui.win(Game.project, player)
if __name__ == "__main__":
start_game()