sashite-ggn 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -528
  3. data/VERSION.semver +1 -1
  4. data/lib/sashite/ggn.rb +2 -2
  5. data/lib/sashite/ggn/ability.rb +2 -20
  6. data/lib/sashite/ggn/gameplay.rb +2 -13
  7. data/lib/sashite/ggn/object.rb +2 -21
  8. data/lib/sashite/ggn/pattern.rb +2 -13
  9. data/lib/sashite/ggn/square.rb +2 -24
  10. data/lib/sashite/ggn/state.rb +2 -21
  11. data/lib/sashite/ggn/subject.rb +2 -22
  12. data/lib/sashite/ggn/verb.rb +2 -28
  13. data/sashite-ggn.gemspec +2 -2
  14. data/test/test_ggn.rb +6 -543
  15. data/test/test_ggn_ability.rb +28 -38
  16. data/test/test_ggn_gameplay.rb +8 -548
  17. data/test/test_ggn_object.rb +30 -22
  18. data/test/test_ggn_pattern.rb +8 -75
  19. data/test/test_ggn_square.rb +30 -14
  20. data/test/test_ggn_state.rb +18 -13
  21. data/test/test_ggn_subject.rb +30 -17
  22. data/test/test_ggn_verb.rb +18 -16
  23. metadata +4 -73
  24. data/lib/sashite/ggn/actor.rb +0 -20
  25. data/lib/sashite/ggn/ally.rb +0 -20
  26. data/lib/sashite/ggn/area.rb +0 -17
  27. data/lib/sashite/ggn/attacked.rb +0 -20
  28. data/lib/sashite/ggn/boolean.rb +0 -17
  29. data/lib/sashite/ggn/digit.rb +0 -20
  30. data/lib/sashite/ggn/digit_excluding_zero.rb +0 -17
  31. data/lib/sashite/ggn/direction.rb +0 -19
  32. data/lib/sashite/ggn/gameplay_into_base64.rb +0 -21
  33. data/lib/sashite/ggn/integer.rb +0 -20
  34. data/lib/sashite/ggn/last_moved_actor.rb +0 -20
  35. data/lib/sashite/ggn/maximum_magnitude.rb +0 -20
  36. data/lib/sashite/ggn/name.rb +0 -17
  37. data/lib/sashite/ggn/negative_integer.rb +0 -19
  38. data/lib/sashite/ggn/null.rb +0 -21
  39. data/lib/sashite/ggn/occupied.rb +0 -29
  40. data/lib/sashite/ggn/previous_moves_counter.rb +0 -20
  41. data/lib/sashite/ggn/promotable_into_actors.rb +0 -23
  42. data/lib/sashite/ggn/required.rb +0 -19
  43. data/lib/sashite/ggn/self.rb +0 -21
  44. data/lib/sashite/ggn/unsigned_integer.rb +0 -20
  45. data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +0 -20
  46. data/lib/sashite/ggn/zero.rb +0 -21
  47. data/test/test_ggn_actor.rb +0 -571
  48. data/test/test_ggn_ally.rb +0 -35
  49. data/test/test_ggn_area.rb +0 -21
  50. data/test/test_ggn_attacked.rb +0 -35
  51. data/test/test_ggn_boolean.rb +0 -21
  52. data/test/test_ggn_digit.rb +0 -21
  53. data/test/test_ggn_digit_excluding_zero.rb +0 -21
  54. data/test/test_ggn_direction.rb +0 -21
  55. data/test/test_ggn_gameplay_into_base64.rb +0 -555
  56. data/test/test_ggn_integer.rb +0 -39
  57. data/test/test_ggn_last_moved_actor.rb +0 -35
  58. data/test/test_ggn_maximum_magnitude.rb +0 -39
  59. data/test/test_ggn_name.rb +0 -21
  60. data/test/test_ggn_negative_integer.rb +0 -21
  61. data/test/test_ggn_null.rb +0 -21
  62. data/test/test_ggn_occupied.rb +0 -78
  63. data/test/test_ggn_previous_moves_counter.rb +0 -39
  64. data/test/test_ggn_promotable_into_actors.rb +0 -578
  65. data/test/test_ggn_required.rb +0 -21
  66. data/test/test_ggn_self.rb +0 -21
  67. data/test/test_ggn_unsigned_integer.rb +0 -39
  68. data/test/test_ggn_unsigned_integer_excluding_zero.rb +0 -25
  69. data/test/test_ggn_zero.rb +0 -21
@@ -1,51 +1,41 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Ability do
4
- subject { Sashite::GGN::Ability }
4
+ subject { Sashite::GGN::Ability.new }
5
5
 
6
- describe '.load' do
7
- before do
8
- @ggn_obj = 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self'
6
+ describe '#subject' do
7
+ it 'responds to subject' do
8
+ subject.must_respond_to :subject
9
9
  end
10
+ end
10
11
 
11
- it 'loads a document from the current io stream' do
12
- subject.load(@ggn_obj).hash.must_equal(
13
- {
14
- subject: {
15
- :"...ally?" => true,
16
- :"actor" => :self,
17
- :"state" => {
18
- :"...last_moved_actor?" => nil,
19
- :"...previous_moves_counter" => nil
20
- }
21
- },
12
+ describe '#subject=' do
13
+ it 'responds to subject=' do
14
+ subject.must_respond_to :subject=
15
+ end
16
+ end
22
17
 
23
- verb: {
24
- name: :shift,
25
- vector: {direction: [-1,0], :"...maximum_magnitude" => nil}
26
- },
18
+ describe '#verb' do
19
+ it 'responds to verb' do
20
+ subject.must_respond_to :verb
21
+ end
22
+ end
27
23
 
28
- object: {
29
- src_square: {
30
- :"...attacked?" => nil,
31
- :"...occupied!" => false,
32
- area: :all
33
- },
34
- dst_square: {
35
- :"...attacked?" => nil,
36
- :"...occupied!" => false,
37
- area: :all
38
- },
39
- promotable_into_actors: [:self]
40
- }
41
- }.hash
42
- )
24
+ describe '#verb=' do
25
+ it 'responds to verb=' do
26
+ subject.must_respond_to :verb=
43
27
  end
28
+ end
29
+
30
+ describe '#object' do
31
+ it 'responds to object' do
32
+ subject.must_respond_to :object
33
+ end
34
+ end
44
35
 
45
- describe 'errors' do
46
- it 'raises without an ability' do
47
- -> { subject.load 'foobar' }.must_raise ArgumentError
48
- end
36
+ describe '#object=' do
37
+ it 'responds to object=' do
38
+ subject.must_respond_to :object=
49
39
  end
50
40
  end
51
41
  end
@@ -1,557 +1,17 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Gameplay do
4
- subject { Sashite::GGN::Gameplay }
4
+ subject { Sashite::GGN::Gameplay.new }
5
5
 
6
- describe '.load' do
7
- before do
8
- @ggn_obj = 't<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
9
- 't<self>_&_^remove[0,-1]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
10
- 't<self>_&_^remove[0,1]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
11
- 't<self>_&_^remove[1,0]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
12
- 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self. ' +
13
- 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
14
- 't<self>_&_^shift[0,-1]_/t=_@f+all~_@f+all%self. ' +
15
- 't<self>_&_^shift[0,-1]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[0,-1]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
16
- 't<self>_&_^shift[0,1]_/t=_@f+all~_@f+all%self. ' +
17
- 't<self>_&_^shift[0,1]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[0,1]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
18
- 't<self>_&_^shift[1,0]_/t=_@f+all~_@f+all%self. ' +
19
- 't<self>_&_^shift[1,0]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[1,0]1/t=_@f+all~_@an_enemy_actor+all%self.'
20
- end
21
-
22
- it 'loads a document from the current io stream' do
23
- subject.load(@ggn_obj).hash.must_equal(
24
- [
25
- [
26
- {
27
- :"subject" => {
28
- :"...ally?" => true,
29
- :"actor" => :self,
30
- :"state" => {
31
- :"...last_moved_actor?" => nil,
32
- :"...previous_moves_counter" => nil
33
- }
34
- },
35
-
36
- :"verb" => {
37
- :"name" => :remove,
38
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
39
- },
40
-
41
- :"object" => {
42
- :"src_square" => {
43
- :"...attacked?" => nil,
44
- :"...occupied!" => false,
45
- :"area" => :all
46
- },
47
- :"dst_square" => {
48
- :"...attacked?" => nil,
49
- :"...occupied!" => :an_enemy_actor,
50
- :"area" => :all
51
- },
52
- :"promotable_into_actors" => [:self]
53
- }
54
- }
55
- ],
56
-
57
-
58
-
59
- [
60
- {
61
- :"subject" => {
62
- :"...ally?" => true,
63
- :"actor" => :self,
64
- :"state" => {
65
- :"...last_moved_actor?" => nil,
66
- :"...previous_moves_counter" => nil
67
- }
68
- },
69
-
70
- :"verb" => {
71
- :"name" => :remove,
72
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
73
- },
74
-
75
- :"object" => {
76
- :"src_square" => {
77
- :"...attacked?" => nil,
78
- :"...occupied!" => false,
79
- :"area" => :all
80
- },
81
- :"dst_square" => {
82
- :"...attacked?" => nil,
83
- :"...occupied!" => :an_enemy_actor,
84
- :"area" => :all
85
- },
86
- :"promotable_into_actors" => [:self]
87
- }
88
- }
89
- ],
90
-
91
-
92
-
93
- [
94
- {
95
- :"subject" => {
96
- :"...ally?" => true,
97
- :"actor" => :self,
98
- :"state" => {
99
- :"...last_moved_actor?" => nil,
100
- :"...previous_moves_counter" => nil
101
- }
102
- },
103
-
104
- :"verb" => {
105
- :"name" => :remove,
106
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
107
- },
108
-
109
- :"object" => {
110
- :"src_square" => {
111
- :"...attacked?" => nil,
112
- :"...occupied!" => false,
113
- :"area" => :all
114
- },
115
- :"dst_square" => {
116
- :"...attacked?" => nil,
117
- :"...occupied!" => :an_enemy_actor,
118
- :"area" => :all
119
- },
120
- :"promotable_into_actors" => [:self]
121
- }
122
- }
123
- ],
124
-
125
-
126
-
127
- [
128
- {
129
- :"subject" => {
130
- :"...ally?" => true,
131
- :"actor" => :self,
132
- :"state" => {
133
- :"...last_moved_actor?" => nil,
134
- :"...previous_moves_counter" => nil
135
- }
136
- },
137
-
138
- :"verb" => {
139
- :"name" => :remove,
140
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
141
- },
142
-
143
- :"object" => {
144
- :"src_square" => {
145
- :"...attacked?" => nil,
146
- :"...occupied!" => false,
147
- :"area" => :all
148
- },
149
- :"dst_square" => {
150
- :"...attacked?" => nil,
151
- :"...occupied!" => :an_enemy_actor,
152
- :"area" => :all
153
- },
154
- :"promotable_into_actors" => [:self]
155
- }
156
- }
157
- ],
158
-
159
-
160
-
161
- [
162
- {
163
- :"subject" => {
164
- :"...ally?" => true,
165
- :"actor" => :self,
166
- :"state" => {
167
- :"...last_moved_actor?" => nil,
168
- :"...previous_moves_counter" => nil
169
- }
170
- },
171
-
172
- :"verb" => {
173
- :"name" => :shift,
174
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
175
- },
176
-
177
- :"object" => {
178
- :"src_square" => {
179
- :"...attacked?" => nil,
180
- :"...occupied!" => false,
181
- :"area" => :all
182
- },
183
- :"dst_square" => {
184
- :"...attacked?" => nil,
185
- :"...occupied!" => false,
186
- :"area" => :all
187
- },
188
- :"promotable_into_actors" => [:self]
189
- }
190
- }
191
- ],
192
-
193
-
194
-
195
- [
196
- {
197
- :"subject" => {
198
- :"...ally?" => true,
199
- :"actor" => :self,
200
- :"state" => {
201
- :"...last_moved_actor?" => nil,
202
- :"...previous_moves_counter" => nil
203
- }
204
- },
205
-
206
- :"verb" => {
207
- :"name" => :shift,
208
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
209
- },
210
-
211
- :"object" => {
212
- :"src_square" => {
213
- :"...attacked?" => nil,
214
- :"...occupied!" => false,
215
- :"area" => :all
216
- },
217
- :"dst_square" => {
218
- :"...attacked?" => nil,
219
- :"...occupied!" => false,
220
- :"area" => :all
221
- },
222
- :"promotable_into_actors" => [:self]
223
- }
224
- },
225
- {
226
- :"subject" => {
227
- :"...ally?" => true,
228
- :"actor" => :self,
229
- :"state" => {
230
- :"...last_moved_actor?" => nil,
231
- :"...previous_moves_counter" => nil
232
- }
233
- },
234
-
235
- :"verb" => {
236
- :"name" => :remove,
237
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
238
- },
239
-
240
- :"object" => {
241
- :"src_square" => {
242
- :"...attacked?" => nil,
243
- :"...occupied!" => false,
244
- :"area" => :all
245
- },
246
- :"dst_square" => {
247
- :"...attacked?" => nil,
248
- :"...occupied!" => :an_enemy_actor,
249
- :"area" => :all
250
- },
251
- :"promotable_into_actors" => [:self]
252
- }
253
- }
254
- ],
255
-
256
-
257
-
258
- [
259
- {
260
- :"subject" => {
261
- :"...ally?" => true,
262
- :"actor" => :self,
263
- :"state" => {
264
- :"...last_moved_actor?" => nil,
265
- :"...previous_moves_counter" => nil
266
- }
267
- },
268
-
269
- :"verb" => {
270
- :"name" => :shift,
271
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
272
- },
273
-
274
- :"object" => {
275
- :"src_square" => {
276
- :"...attacked?" => nil,
277
- :"...occupied!" => false,
278
- :"area" => :all
279
- },
280
- :"dst_square" => {
281
- :"...attacked?" => nil,
282
- :"...occupied!" => false,
283
- :"area" => :all
284
- },
285
- :"promotable_into_actors" => [:self]
286
- }
287
- }
288
- ],
289
-
290
-
291
-
292
- [
293
- {
294
- :"subject" => {
295
- :"...ally?" => true,
296
- :"actor" => :self,
297
- :"state" => {
298
- :"...last_moved_actor?" => nil,
299
- :"...previous_moves_counter" => nil
300
- }
301
- },
302
-
303
- :"verb" => {
304
- :"name" => :shift,
305
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
306
- },
307
-
308
- :"object" => {
309
- :"src_square" => {
310
- :"...attacked?" => nil,
311
- :"...occupied!" => false,
312
- :"area" => :all
313
- },
314
- :"dst_square" => {
315
- :"...attacked?" => nil,
316
- :"...occupied!" => false,
317
- :"area" => :all
318
- },
319
- :"promotable_into_actors" => [:self]
320
- }
321
- },
322
- {
323
- :"subject" => {
324
- :"...ally?" => true,
325
- :"actor" => :self,
326
- :"state" => {
327
- :"...last_moved_actor?" => nil,
328
- :"...previous_moves_counter" => nil
329
- }
330
- },
331
-
332
- :"verb" => {
333
- :"name" => :remove,
334
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
335
- },
336
-
337
- :"object" => {
338
- :"src_square" => {
339
- :"...attacked?" => nil,
340
- :"...occupied!" => false,
341
- :"area" => :all
342
- },
343
- :"dst_square" => {
344
- :"...attacked?" => nil,
345
- :"...occupied!" => :an_enemy_actor,
346
- :"area" => :all
347
- },
348
- :"promotable_into_actors" => [:self]
349
- }
350
- }
351
- ],
352
-
353
-
354
-
355
- [
356
- {
357
- :"subject" => {
358
- :"...ally?" => true,
359
- :"actor" => :self,
360
- :"state" => {
361
- :"...last_moved_actor?" => nil,
362
- :"...previous_moves_counter" => nil
363
- }
364
- },
365
-
366
- :"verb" => {
367
- :"name" => :shift,
368
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
369
- },
370
-
371
- :"object" => {
372
- :"src_square" => {
373
- :"...attacked?" => nil,
374
- :"...occupied!" => false,
375
- :"area" => :all
376
- },
377
- :"dst_square" => {
378
- :"...attacked?" => nil,
379
- :"...occupied!" => false,
380
- :"area" => :all
381
- },
382
- :"promotable_into_actors" => [:self]
383
- }
384
- }
385
- ],
386
-
387
-
388
-
389
- [
390
- {
391
- :"subject" => {
392
- :"...ally?" => true,
393
- :"actor" => :self,
394
- :"state" => {
395
- :"...last_moved_actor?" => nil,
396
- :"...previous_moves_counter" => nil
397
- }
398
- },
399
-
400
- :"verb" => {
401
- :"name" => :shift,
402
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
403
- },
404
-
405
- :"object" => {
406
- :"src_square" => {
407
- :"...attacked?" => nil,
408
- :"...occupied!" => false,
409
- :"area" => :all
410
- },
411
- :"dst_square" => {
412
- :"...attacked?" => nil,
413
- :"...occupied!" => false,
414
- :"area" => :all
415
- },
416
- :"promotable_into_actors" => [:self]
417
- }
418
- },
419
- {
420
- :"subject" => {
421
- :"...ally?" => true,
422
- :"actor" => :self,
423
- :"state" => {
424
- :"...last_moved_actor?" => nil,
425
- :"...previous_moves_counter" => nil
426
- }
427
- },
428
-
429
- :"verb" => {
430
- :"name" => :remove,
431
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
432
- },
433
-
434
- :"object" => {
435
- :"src_square" => {
436
- :"...attacked?" => nil,
437
- :"...occupied!" => false,
438
- :"area" => :all
439
- },
440
- :"dst_square" => {
441
- :"...attacked?" => nil,
442
- :"...occupied!" => :an_enemy_actor,
443
- :"area" => :all
444
- },
445
- :"promotable_into_actors" => [:self]
446
- }
447
- }
448
- ],
449
-
450
-
451
-
452
- [
453
- {
454
- :"subject" => {
455
- :"...ally?" => true,
456
- :"actor" => :self,
457
- :"state" => {
458
- :"...last_moved_actor?" => nil,
459
- :"...previous_moves_counter" => nil
460
- }
461
- },
462
-
463
- :"verb" => {
464
- :"name" => :shift,
465
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
466
- },
467
-
468
- :"object" => {
469
- :"src_square" => {
470
- :"...attacked?" => nil,
471
- :"...occupied!" => false,
472
- :"area" => :all
473
- },
474
- :"dst_square" => {
475
- :"...attacked?" => nil,
476
- :"...occupied!" => false,
477
- :"area" => :all
478
- },
479
- :"promotable_into_actors" => [:self]
480
- }
481
- }
482
- ],
483
-
484
-
485
-
486
- [
487
- {
488
- :"subject" => {
489
- :"...ally?" => true,
490
- :"actor" => :self,
491
- :"state" => {
492
- :"...last_moved_actor?" => nil,
493
- :"...previous_moves_counter" => nil
494
- }
495
- },
496
-
497
- :"verb" => {
498
- :"name" => :shift,
499
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
500
- },
501
-
502
- :"object" => {
503
- :"src_square" => {
504
- :"...attacked?" => nil,
505
- :"...occupied!" => false,
506
- :"area" => :all
507
- },
508
- :"dst_square" => {
509
- :"...attacked?" => nil,
510
- :"...occupied!" => false,
511
- :"area" => :all
512
- },
513
- :"promotable_into_actors" => [:self]
514
- }
515
- },
516
- {
517
- :"subject" => {
518
- :"...ally?" => true,
519
- :"actor" => :self,
520
- :"state" => {
521
- :"...last_moved_actor?" => nil,
522
- :"...previous_moves_counter" => nil
523
- }
524
- },
525
-
526
- :"verb" => {
527
- :"name" => :remove,
528
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
529
- },
530
-
531
- :"object" => {
532
- :"src_square" => {
533
- :"...attacked?" => nil,
534
- :"...occupied!" => false,
535
- :"area" => :all
536
- },
537
- :"dst_square" => {
538
- :"...attacked?" => nil,
539
- :"...occupied!" => :an_enemy_actor,
540
- :"area" => :all
541
- },
542
- :"promotable_into_actors" => [:self]
543
- }
544
- }
545
- ]
546
- ].hash
547
- )
6
+ describe '#patterns' do
7
+ it 'responds to patterns' do
8
+ subject.must_respond_to :patterns
548
9
  end
10
+ end
549
11
 
550
- describe 'errors' do
551
- it 'raises with several identical gameplays' do
552
- -> { subject.load 't<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self. ' +
553
- 't<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self.' }.must_raise ArgumentError
554
- end
12
+ describe '#patterns=' do
13
+ it 'responds to patterns=' do
14
+ subject.must_respond_to :patterns=
555
15
  end
556
16
  end
557
17
  end