-
Notifications
You must be signed in to change notification settings - Fork 0
/
creator.py
126 lines (104 loc) · 3 KB
/
creator.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
# By Zhufyak V.V
# zhufyakvv@gmail.com
# github.com/zhufyakvv
# 19.01.2017
import level
from engine import Engine
def change_voice():
global current
voice = level.Voice(current.name)
command = input("Set language...")
voice.lang = command
try:
voice.load()
except FileNotFoundError:
voice.save()
voice.load()
while True:
command = int(input("(1) Add start phrase \n"
"(2) Add end phrase \n"
"(0) Exit\n>"))
if command == 1:
phrase = input("Set phrase for start...")
voice.add_start(phrase)
elif command == 2:
phrase = input("Set phrase for end...")
voice.add_end(phrase)
else:
break
voice.save()
def delete_tile():
global current
print(">Delete...")
x = input(">Set x...")
y = input(">Set y...")
current.delete_tile((int(x), int(y)))
def add_tile():
# TODO Output field
x = int(input(">Set x location\n>"))
y = int(input(">Set y location\n>"))
tile_name = input(">Set type of tile: ('0' - default, '-1' - finish, 'custom_name' - custom) \n>")
global current
if int(tile_name) == 0:
current.add_tile((x, y))
elif int(tile_name) == -1:
current.add_tile((x, y), "finish")
else:
current.add_tile((x, y), tile_name)
def command_cfg():
global current
full = {
"f": "forward",
"b": "back",
"rg": "right",
"lf": "left",
"lo": "lo",
"op": "op"
}
command_name = ""
while command_name not in full:
command_name = input(">Set name of command: "
"\n( f - forward, b - back, lf - left, rg - right, lo - start loop, op - end of loop )\n>")
amount = input(">Set amount\n")
print(">Prev amount was " + str(current.moves[full[command_name]]) + "\n>")
current.change_command(full[command_name], amount)
def robot_place():
global current
x = int(input(">Set x location\n>"))
y = int(input(">Set y location\n>"))
direction = int(input(">Set direction\n>"))
current.robot_direct(direction)
current.robot_place((x, y))
say = input(">Welcome to level creator!\n Create new (1) or Edit existing (2)?\n>")
name = input(">Name?\n>")
current = level.Level(name)
if int(say) == 2:
current.load()
run = True
while run:
say = input(">(1) Add tile\n"
">(2) Delete tile\n"
">(3) Change command\n"
">(4) Polo placement\n"
">(5) Add Voice\n"
">(0) Exit\n>")
if int(say) == 1:
add_tile()
elif int(say) == 2:
delete_tile()
elif int(say) == 3:
command_cfg()
elif int(say) == 4:
robot_place()
elif int(say) == 5:
change_voice()
else:
run = False
q = input(">Save?(1-0)\n>")
if int(q) == 1:
current.save()
r = input(">Run?(1-0)\n>")
if int(r) == 1:
e = Engine()
e.load(current.name)
e.run()