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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc3e41d95a692971ccd464ef45040baa3766c3e1
4
- data.tar.gz: c8511f5a3bfb0cba38e55abc1c1bafee472413f3
3
+ metadata.gz: 8fc9192ea7b3a42e4f8a039bec43da970ee3e4aa
4
+ data.tar.gz: 7edd6351985e71da38ab7b8dd0d057bae17aa2ec
5
5
  SHA512:
6
- metadata.gz: 7e3014d5a5675cab389d9bacd3d49cccacbd06bf98e08740fa0f7f26449409d04ab865791e119399313752ebeed730a99d93a3b42cec464d7a4922d4e52b2b2c
7
- data.tar.gz: 417a0c0899ee74e1182cf15cb18f441608bbddfebcc3b23aa556a170932b864d6834ccaf6023b04c87887d60196bb7cbb3e6e4be8d4b2b0e6430562d858d7a9b
6
+ metadata.gz: fe4aa42eac809ad5a93154b3a686c812adb98491c3d8a86ec91ed63403e0bea3b0463017f431cf9bb7942071b88e7244c991648c22928e18096ad15c430d2683
7
+ data.tar.gz: a251832c03b303ea0011e87088945f64453b64a1cc19900666beddde7d5cd9043f90dcafe175499f6f983925835a649b6085de9ef8f428e42e28404a2714ea4e
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sashite::GGN
2
2
 
3
- This module provides a Ruby interface for data serialization in [GGN](http://sashite.wiki/General_Gameplay_Notation) format.
3
+ A collection of mappers for [GGN](http://sashite.wiki/General_Gameplay_Notation) objects.
4
4
 
5
5
  ## Status
6
6
 
@@ -29,534 +29,14 @@ Working with GGN can be very simple, for example:
29
29
  ```ruby
30
30
  require 'sashite-ggn'
31
31
 
32
- # Parse a GGN string
32
+ state = Sashite::GGN::State.new
33
+ state.last_moved_actor = nil
34
+ state.previous_moves_counter = nil
33
35
 
34
- ggn_obj = [
35
- [
36
- {
37
- :"subject" => {
38
- :"...ally?" => true,
39
- :"actor" => :self,
40
- :"state" => {
41
- :"...last_moved_actor?" => nil,
42
- :"...previous_moves_counter" => nil
43
- }
44
- },
45
-
46
- :"verb" => {
47
- :"name" => :remove,
48
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
49
- },
50
-
51
- :"object" => {
52
- :"src_square" => {
53
- :"...attacked?" => nil,
54
- :"...occupied!" => false,
55
- :"area" => :all
56
- },
57
- :"dst_square" => {
58
- :"...attacked?" => nil,
59
- :"...occupied!" => :an_enemy_actor,
60
- :"area" => :all
61
- },
62
- :"promotable_into_actors" => [:self]
63
- }
64
- }
65
- ],
66
-
67
-
68
-
69
- [
70
- {
71
- :"subject" => {
72
- :"...ally?" => true,
73
- :"actor" => :self,
74
- :"state" => {
75
- :"...last_moved_actor?" => nil,
76
- :"...previous_moves_counter" => nil
77
- }
78
- },
79
-
80
- :"verb" => {
81
- :"name" => :remove,
82
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
83
- },
84
-
85
- :"object" => {
86
- :"src_square" => {
87
- :"...attacked?" => nil,
88
- :"...occupied!" => false,
89
- :"area" => :all
90
- },
91
- :"dst_square" => {
92
- :"...attacked?" => nil,
93
- :"...occupied!" => :an_enemy_actor,
94
- :"area" => :all
95
- },
96
- :"promotable_into_actors" => [:self]
97
- }
98
- }
99
- ],
100
-
101
-
102
-
103
- [
104
- {
105
- :"subject" => {
106
- :"...ally?" => true,
107
- :"actor" => :self,
108
- :"state" => {
109
- :"...last_moved_actor?" => nil,
110
- :"...previous_moves_counter" => nil
111
- }
112
- },
113
-
114
- :"verb" => {
115
- :"name" => :remove,
116
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
117
- },
118
-
119
- :"object" => {
120
- :"src_square" => {
121
- :"...attacked?" => nil,
122
- :"...occupied!" => false,
123
- :"area" => :all
124
- },
125
- :"dst_square" => {
126
- :"...attacked?" => nil,
127
- :"...occupied!" => :an_enemy_actor,
128
- :"area" => :all
129
- },
130
- :"promotable_into_actors" => [:self]
131
- }
132
- }
133
- ],
134
-
135
-
136
-
137
- [
138
- {
139
- :"subject" => {
140
- :"...ally?" => true,
141
- :"actor" => :self,
142
- :"state" => {
143
- :"...last_moved_actor?" => nil,
144
- :"...previous_moves_counter" => nil
145
- }
146
- },
147
-
148
- :"verb" => {
149
- :"name" => :remove,
150
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
151
- },
152
-
153
- :"object" => {
154
- :"src_square" => {
155
- :"...attacked?" => nil,
156
- :"...occupied!" => false,
157
- :"area" => :all
158
- },
159
- :"dst_square" => {
160
- :"...attacked?" => nil,
161
- :"...occupied!" => :an_enemy_actor,
162
- :"area" => :all
163
- },
164
- :"promotable_into_actors" => [:self]
165
- }
166
- }
167
- ],
168
-
169
-
170
-
171
- [
172
- {
173
- :"subject" => {
174
- :"...ally?" => true,
175
- :"actor" => :self,
176
- :"state" => {
177
- :"...last_moved_actor?" => nil,
178
- :"...previous_moves_counter" => nil
179
- }
180
- },
181
-
182
- :"verb" => {
183
- :"name" => :shift,
184
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
185
- },
186
-
187
- :"object" => {
188
- :"src_square" => {
189
- :"...attacked?" => nil,
190
- :"...occupied!" => false,
191
- :"area" => :all
192
- },
193
- :"dst_square" => {
194
- :"...attacked?" => nil,
195
- :"...occupied!" => false,
196
- :"area" => :all
197
- },
198
- :"promotable_into_actors" => [:self]
199
- }
200
- }
201
- ],
202
-
203
-
204
-
205
- [
206
- {
207
- :"subject" => {
208
- :"...ally?" => true,
209
- :"actor" => :self,
210
- :"state" => {
211
- :"...last_moved_actor?" => nil,
212
- :"...previous_moves_counter" => nil
213
- }
214
- },
215
-
216
- :"verb" => {
217
- :"name" => :shift,
218
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
219
- },
220
-
221
- :"object" => {
222
- :"src_square" => {
223
- :"...attacked?" => nil,
224
- :"...occupied!" => false,
225
- :"area" => :all
226
- },
227
- :"dst_square" => {
228
- :"...attacked?" => nil,
229
- :"...occupied!" => false,
230
- :"area" => :all
231
- },
232
- :"promotable_into_actors" => [:self]
233
- }
234
- },
235
- {
236
- :"subject" => {
237
- :"...ally?" => true,
238
- :"actor" => :self,
239
- :"state" => {
240
- :"...last_moved_actor?" => nil,
241
- :"...previous_moves_counter" => nil
242
- }
243
- },
244
-
245
- :"verb" => {
246
- :"name" => :remove,
247
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
248
- },
249
-
250
- :"object" => {
251
- :"src_square" => {
252
- :"...attacked?" => nil,
253
- :"...occupied!" => false,
254
- :"area" => :all
255
- },
256
- :"dst_square" => {
257
- :"...attacked?" => nil,
258
- :"...occupied!" => :an_enemy_actor,
259
- :"area" => :all
260
- },
261
- :"promotable_into_actors" => [:self]
262
- }
263
- }
264
- ],
265
-
266
-
267
-
268
- [
269
- {
270
- :"subject" => {
271
- :"...ally?" => true,
272
- :"actor" => :self,
273
- :"state" => {
274
- :"...last_moved_actor?" => nil,
275
- :"...previous_moves_counter" => nil
276
- }
277
- },
278
-
279
- :"verb" => {
280
- :"name" => :shift,
281
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
282
- },
283
-
284
- :"object" => {
285
- :"src_square" => {
286
- :"...attacked?" => nil,
287
- :"...occupied!" => false,
288
- :"area" => :all
289
- },
290
- :"dst_square" => {
291
- :"...attacked?" => nil,
292
- :"...occupied!" => false,
293
- :"area" => :all
294
- },
295
- :"promotable_into_actors" => [:self]
296
- }
297
- }
298
- ],
299
-
300
-
301
-
302
- [
303
- {
304
- :"subject" => {
305
- :"...ally?" => true,
306
- :"actor" => :self,
307
- :"state" => {
308
- :"...last_moved_actor?" => nil,
309
- :"...previous_moves_counter" => nil
310
- }
311
- },
312
-
313
- :"verb" => {
314
- :"name" => :shift,
315
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
316
- },
317
-
318
- :"object" => {
319
- :"src_square" => {
320
- :"...attacked?" => nil,
321
- :"...occupied!" => false,
322
- :"area" => :all
323
- },
324
- :"dst_square" => {
325
- :"...attacked?" => nil,
326
- :"...occupied!" => false,
327
- :"area" => :all
328
- },
329
- :"promotable_into_actors" => [:self]
330
- }
331
- },
332
- {
333
- :"subject" => {
334
- :"...ally?" => true,
335
- :"actor" => :self,
336
- :"state" => {
337
- :"...last_moved_actor?" => nil,
338
- :"...previous_moves_counter" => nil
339
- }
340
- },
341
-
342
- :"verb" => {
343
- :"name" => :remove,
344
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
345
- },
346
-
347
- :"object" => {
348
- :"src_square" => {
349
- :"...attacked?" => nil,
350
- :"...occupied!" => false,
351
- :"area" => :all
352
- },
353
- :"dst_square" => {
354
- :"...attacked?" => nil,
355
- :"...occupied!" => :an_enemy_actor,
356
- :"area" => :all
357
- },
358
- :"promotable_into_actors" => [:self]
359
- }
360
- }
361
- ],
362
-
363
-
364
-
365
- [
366
- {
367
- :"subject" => {
368
- :"...ally?" => true,
369
- :"actor" => :self,
370
- :"state" => {
371
- :"...last_moved_actor?" => nil,
372
- :"...previous_moves_counter" => nil
373
- }
374
- },
375
-
376
- :"verb" => {
377
- :"name" => :shift,
378
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
379
- },
380
-
381
- :"object" => {
382
- :"src_square" => {
383
- :"...attacked?" => nil,
384
- :"...occupied!" => false,
385
- :"area" => :all
386
- },
387
- :"dst_square" => {
388
- :"...attacked?" => nil,
389
- :"...occupied!" => false,
390
- :"area" => :all
391
- },
392
- :"promotable_into_actors" => [:self]
393
- }
394
- }
395
- ],
396
-
397
-
398
-
399
- [
400
- {
401
- :"subject" => {
402
- :"...ally?" => true,
403
- :"actor" => :self,
404
- :"state" => {
405
- :"...last_moved_actor?" => nil,
406
- :"...previous_moves_counter" => nil
407
- }
408
- },
409
-
410
- :"verb" => {
411
- :"name" => :shift,
412
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
413
- },
414
-
415
- :"object" => {
416
- :"src_square" => {
417
- :"...attacked?" => nil,
418
- :"...occupied!" => false,
419
- :"area" => :all
420
- },
421
- :"dst_square" => {
422
- :"...attacked?" => nil,
423
- :"...occupied!" => false,
424
- :"area" => :all
425
- },
426
- :"promotable_into_actors" => [:self]
427
- }
428
- },
429
- {
430
- :"subject" => {
431
- :"...ally?" => true,
432
- :"actor" => :self,
433
- :"state" => {
434
- :"...last_moved_actor?" => nil,
435
- :"...previous_moves_counter" => nil
436
- }
437
- },
438
-
439
- :"verb" => {
440
- :"name" => :remove,
441
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
442
- },
443
-
444
- :"object" => {
445
- :"src_square" => {
446
- :"...attacked?" => nil,
447
- :"...occupied!" => false,
448
- :"area" => :all
449
- },
450
- :"dst_square" => {
451
- :"...attacked?" => nil,
452
- :"...occupied!" => :an_enemy_actor,
453
- :"area" => :all
454
- },
455
- :"promotable_into_actors" => [:self]
456
- }
457
- }
458
- ],
459
-
460
-
461
-
462
- [
463
- {
464
- :"subject" => {
465
- :"...ally?" => true,
466
- :"actor" => :self,
467
- :"state" => {
468
- :"...last_moved_actor?" => nil,
469
- :"...previous_moves_counter" => nil
470
- }
471
- },
472
-
473
- :"verb" => {
474
- :"name" => :shift,
475
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
476
- },
477
-
478
- :"object" => {
479
- :"src_square" => {
480
- :"...attacked?" => nil,
481
- :"...occupied!" => false,
482
- :"area" => :all
483
- },
484
- :"dst_square" => {
485
- :"...attacked?" => nil,
486
- :"...occupied!" => false,
487
- :"area" => :all
488
- },
489
- :"promotable_into_actors" => [:self]
490
- }
491
- }
492
- ],
493
-
494
-
495
-
496
- [
497
- {
498
- :"subject" => {
499
- :"...ally?" => true,
500
- :"actor" => :self,
501
- :"state" => {
502
- :"...last_moved_actor?" => nil,
503
- :"...previous_moves_counter" => nil
504
- }
505
- },
506
-
507
- :"verb" => {
508
- :"name" => :shift,
509
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
510
- },
511
-
512
- :"object" => {
513
- :"src_square" => {
514
- :"...attacked?" => nil,
515
- :"...occupied!" => false,
516
- :"area" => :all
517
- },
518
- :"dst_square" => {
519
- :"...attacked?" => nil,
520
- :"...occupied!" => false,
521
- :"area" => :all
522
- },
523
- :"promotable_into_actors" => [:self]
524
- }
525
- },
526
- {
527
- :"subject" => {
528
- :"...ally?" => true,
529
- :"actor" => :self,
530
- :"state" => {
531
- :"...last_moved_actor?" => nil,
532
- :"...previous_moves_counter" => nil
533
- }
534
- },
535
-
536
- :"verb" => {
537
- :"name" => :remove,
538
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
539
- },
540
-
541
- :"object" => {
542
- :"src_square" => {
543
- :"...attacked?" => nil,
544
- :"...occupied!" => false,
545
- :"area" => :all
546
- },
547
- :"dst_square" => {
548
- :"...attacked?" => nil,
549
- :"...occupied!" => :an_enemy_actor,
550
- :"area" => :all
551
- },
552
- :"promotable_into_actors" => [:self]
553
- }
554
- }
555
- ]
556
- ]
557
-
558
- Sashite::GGN.load(ggn_obj)
559
- # => "t<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self. t<self>_&_^remove[0,-1]1/t=_@f+all~_@an_enemy_actor+all%self. t<self>_&_^remove[0,1]1/t=_@f+all~_@an_enemy_actor+all%self. t<self>_&_^remove[1,0]1/t=_@f+all~_@an_enemy_actor+all%self. t<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self. 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. t<self>_&_^shift[0,-1]_/t=_@f+all~_@f+all%self. 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. t<self>_&_^shift[0,1]_/t=_@f+all~_@f+all%self. 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. t<self>_&_^shift[1,0]_/t=_@f+all~_@f+all%self. 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."
36
+ subject = Sashite::GGN::Subject.new
37
+ subject.ally = true
38
+ subject.actor = :self
39
+ subject.state = state
560
40
  ```
561
41
 
562
42
  ## Contributing