-
Notifications
You must be signed in to change notification settings - Fork 482
/
artist.rb
283 lines (276 loc) · 8.82 KB
/
artist.rb
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# == Schema Information
#
# Table name: levels
#
# id :integer not null, primary key
# game_id :integer
# name :string(255) not null
# created_at :datetime
# updated_at :datetime
# level_num :string(255)
# ideal_level_source_id :integer
# solution_level_source_id :integer
# user_id :integer
# properties :text(65535)
# type :string(255)
# md5 :string(255)
# published :boolean default(FALSE), not null
# notes :text(65535)
#
# Indexes
#
# index_levels_on_game_id (game_id)
# index_levels_on_name (name)
#
class Artist < Blockly
serialized_attrs %w(
start_direction
x y
predraw_blocks
images
free_play
permitted_errors
impressive
discard_background
shapeways_url
disable_sharing
)
def xml_blocks
super + %w(predraw_blocks)
end
# List of possible skins, the first is used as a default.
def self.skins
%w(artist artist_zombie elsa anna)
end
def self.create_from_level_builder(params, level_params)
create!(
level_params.merge(
user: params[:user],
game: Game.custom_artist,
level_num: 'custom',
)
)
end
def toolbox(type)
<<-XML.strip_heredoc.chomp
#{k1_blocks_category}
<category id="actions" name="Actions">
<block type="draw_move_by_constant">
<title name="VALUE">100</title>
</block>
<block type="draw_move_by_constant_dropdown">
<title name="VALUE" config="50,100,150,200,300">???</title>
</block>
<block type="draw_move">
<value name="VALUE">
<block type="math_number">
<title name="NUM">100</title>
</block>
</value>
</block>
<block type="draw_turn_by_constant">
<title name="VALUE">90</title>
</block>
<block type="draw_turn_by_constant_dropdown">
<title name="VALUE" config="45,60,90,120,180">???</title>
</block>
<block type="draw_turn">
<value name="VALUE">
<block type="math_number">
<title name="NUM">90</title>
</block>
</value>
</block>
<block type="jump_to" />
<block type="jump_to_xy" />
<block type="jump_by_constant">
<title name="VALUE">100</title>
</block>
<block type="jump_by_constant_dropdown">
<title name="VALUE" config="50,100,150,200,300">???</title>
</block>
<block type="jump">
<value name="VALUE">
<block type="math_number">
<title name="NUM">100</title>
</block>
</value>
</block>
<block type="draw_width_inline">
<title name="WIDTH">1</title>
</block>
<block type="draw_width">
<value name="WIDTH">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
</block>
<block type="draw_pen"></block>
<block type="draw_line_style_pattern"></block>
<block type="sticker"/>/block>
</category>
<category name="Color">
<block id="draw-color" type="draw_colour">
<value name="COLOUR">
<block type="colour_picker"></block>
</value>
</block>
<block id="draw-color" type="draw_colour">
<value name="COLOUR">
<block type="colour_random"></block>
</value>
</block>
<block id="draw-color" type="draw_colour">
<value name="COLOUR">
<block type="colour_rgb">
<value name="RED"><block type="math_number"><title name="NUM">255</title></block></value>
<value name="GREEN"><block type="math_number"><title name="NUM">255</title></block></value>
<value name="BLUE"><block type="math_number"><title name="NUM">255</title></block></value>
</block>
</value>
</block>
<block id="alpha" type="alpha">
<value name="VALUE">
<block type="math_number_dropdown">
<title name="NUM" config="100,90,80,70,60,50,40,30,20,10,0">100</title>
</block>
</value>
</block>
</category>
<category name="Category">
<block type="category"></block>
</category>
<category name="Functions" custom="PROCEDURE">
</category>
<category name="Prebuilt">
<block type="draw_a_triangle"></block>
<block type="create_a_circle"></block>
<block type="create_a_circle_size"></block>
<block type="create_a_snowflake_branch"></block>
<block type="draw_a_square_custom"></block>
<block type="draw_a_house"></block>
<block type="draw_a_flower"></block>
<block type="draw_a_snowflake"></block>
<block type="draw_a_snowman"></block>
<block type="draw_a_hexagon"></block>
<block type="draw_a_star"></block>
<block type="draw_a_robot"></block>
<block type="draw_a_rocket"></block>
<block type="draw_a_planet"></block>
<block type="draw_a_rhombus"></block>
<block type="draw_upper_wave"></block>
<block type="draw_lower_wave"></block>
<block type="create_snowflake_dropdown"></block>
</category>
<category name="Loops">
<block type="controls_for_counter">
<value name="FROM">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<value name="TO">
<block type="math_number">
<title name="NUM">100</title>
</block>
</value>
<value name="BY">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
<block type="controls_repeat">
<title name="TIMES">4</title>
</block>
<block type="controls_repeat_dropdown">
<title name="TIMES" config="3-10">???</title>
</block>
<block type="controls_repeat_ext">
<value name="TIMES"></value>
<statement name="DO"></statement>
</block>
</category>
<category name="Logic">
<block type="controls_if" inline="false">
<value name="IF0">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
</block>
</value>
</block>
</category>
<category name="Math">
<block type="math_number"></block>
<block type="math_number_dropdown">
<title name="NUM" config="1-10">5</title>
</block>
<block type="math_arithmetic" inline="true"></block>
<block type="math_random_int">
<value name="FROM">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<value name="TO">
<block type="math_number">
<title name="NUM">100</title>
</block>
</value>
</block>
<block type="math_random_float"></block>
</category>
<category name="Text">
<block type="text"></block>
</category>
<category name="Variables" custom="VARIABLE"></category>
<category name="Picker">
<block type="pick_one"></block>
</category>
XML
end
def k1_blocks_category
<<-XML.chomp
<category name="K1 Simplified">
#{k1_blocks}
</category>
XML
end
def k1_blocks
<<-XML.chomp
<block type="controls_repeat_simplified">
<title name="TIMES">5</title>
</block>
<block type="controls_repeat_simplified_dropdown">
<title name="TIMES" config="3-10">3</title>
</block>
<block type="draw_colour_simple"></block>
<block type="draw_line_style_pattern"></block>
<block type="simple_move_up"></block>
<block type="simple_move_down"></block>
<block type="simple_move_right"></block>
<block type="simple_move_left"></block>
<block type="simple_move_up_left"></block>
<block type="simple_move_up_right"></block>
<block type="simple_move_down_left"></block>
<block type="simple_move_down_right"></block>
<block type="simple_move_up_length"></block>
<block type="simple_move_down_length"></block>
<block type="simple_move_right_length"></block>
<block type="simple_move_left_length"></block>
<block type="simple_move_up_left_length"></block>
<block type="simple_move_up_right_length"></block>
<block type="simple_move_down_left_length"></block>
<block type="simple_move_down_right_length"></block>
<block type="simple_jump_up"></block>
<block type="simple_jump_down"></block>
<block type="simple_jump_right"></block>
<block type="simple_jump_left"></block>
<block type="simple_jump_up_left"></block>
<block type="simple_jump_up_right"></block>
<block type="simple_jump_down_left"></block>
<block type="simple_jump_down_right"></block>
XML
end
end