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