-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_runner.py
88 lines (83 loc) · 2.61 KB
/
game_runner.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
from time import time
from presentation import (
Menu,
MenuEntry,
StaticActuator,
GameActuator,
GameRunner,
NodeActuator,
)
from game.game import Game
from game.trotter import TrotterState, Player, Account, Transaction
import game_maps
def create_game_runner(node_manager, previous_game):
def new_game_menu(
context=None,
owner=None,
value=None
):
name = value if value else "Dirk Smallwood"
initial_funds = Transaction(1000)
player = Player(
name=name,
account=Account([initial_funds]),
skills=[]
)
games = [
(
entry_point.descriptor.title,
Game.from_node(
node=entry_point,
state=TrotterState(
player=player,
time=time(),
),
)
)
for entry_point in node_manager.entry_points
]
return Menu(
[
MenuEntry(
type="navigate",
title=title,
actuator=GameActuator(
game=game,
actuator=NodeActuator()
)
)
for title, game in games
],
"https://images.unsplash.com/photo-1554123168-b400f9c806ca?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80",
allow_back=True,
title="Select Location",
description="Where in the world would you like to start?"
)
main_menu = Menu(
[
MenuEntry(
type="input",
title="New game",
value="Unknown Player",
actuator=new_game_menu
),
*([
MenuEntry(
type="navigate",
title="Load game",
actuator=GameActuator(
game=previous_game,
actuator=NodeActuator()
)
)
] if previous_game else []),
],
"https://images.unsplash.com/photo-1503221043305-f7498f8b7888?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1935&q=80",
title="Global Explorer",
description="Welcome to Global Explorer. The game where you travel the world and learn about professions by engaging and doing things yourself."
)
api = GameRunner(
actuator=main_menu,
error_views=game_maps.error_views
)
return api