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 'gameplay_into_base64'
2
- require_relative 'self'
3
-
4
- module Sashite
5
- module GGN
6
- class Actor
7
- PATTERN = /(#{Self::PATTERN}|#{GameplayIntoBase64::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
- Self.valid?(io) ? Self.load : GameplayIntoBase64.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require_relative 'boolean'
2
- require_relative 'null'
3
-
4
- module Sashite
5
- module GGN
6
- module Ally
7
- PATTERN = /(#{Boolean::PATTERN}|#{Null::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
- Null.valid?(io) ? Null.load : Boolean.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Area
4
- PATTERN = /(all|furthest_rank|palace|furthest_one-third|nearest_two-thirds)/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io
11
- raise ArgumentError unless valid? io
12
-
13
- io.to_sym
14
- end
15
- end
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- require_relative 'boolean'
2
- require_relative 'null'
3
-
4
- module Sashite
5
- module GGN
6
- module Attacked
7
- PATTERN = /(#{Boolean::PATTERN}|#{Null::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
- Null.valid?(io) ? Null.load : Boolean.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Boolean
4
- PATTERN = /[ft]/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io
11
- raise ArgumentError unless valid? io
12
-
13
- io.to_sym == :t
14
- end
15
- end
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- require_relative 'digit_excluding_zero'
2
- require_relative 'zero'
3
-
4
- module Sashite
5
- module GGN
6
- module Digit
7
- PATTERN = /(#{Zero::PATTERN}|#{DigitExcludingZero::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
- Zero.valid?(io) ? Zero.load : DigitExcludingZero.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module DigitExcludingZero
4
- PATTERN = /[1-9]/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io
11
- raise ArgumentError unless valid? io
12
-
13
- io.to_i
14
- end
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- require_relative 'integer'
2
-
3
- module Sashite
4
- module GGN
5
- module Direction
6
- PATTERN = /(#{Integer::PATTERN},)*#{Integer::PATTERN}/
7
-
8
- def self.valid? io
9
- !!io.match("^#{PATTERN}$")
10
- end
11
-
12
- def self.load io
13
- raise ArgumentError unless valid? io
14
-
15
- io.split(',').map { |s| Integer.load s }
16
- end
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- require 'base64'
2
- require_relative 'gameplay'
3
-
4
- module Sashite
5
- module GGN
6
- module GameplayIntoBase64
7
- PATTERN = /(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?/
8
-
9
- def self.valid? io
10
- io.match("^#{PATTERN}$") &&
11
- Gameplay.valid?(Base64.strict_decode64(io))
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- Gameplay.load Base64.strict_decode64(io)
18
- end
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- require_relative 'negative_integer'
2
- require_relative 'unsigned_integer'
3
-
4
- module Sashite
5
- module GGN
6
- module Integer
7
- PATTERN = /(#{NegativeInteger::PATTERN}|#{UnsignedInteger::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
- NegativeInteger.valid?(io) ? NegativeInteger.load(io) : UnsignedInteger.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require_relative 'boolean'
2
- require_relative 'null'
3
-
4
- module Sashite
5
- module GGN
6
- module LastMovedActor
7
- PATTERN = /(#{Boolean::PATTERN}|#{Null::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
- Null.valid?(io) ? Null.load : Boolean.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require_relative 'null'
2
- require_relative 'unsigned_integer_excluding_zero'
3
-
4
- module Sashite
5
- module GGN
6
- module MaximumMagnitude
7
- PATTERN = /(#{Null::PATTERN}|#{UnsignedIntegerExcludingZero::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
- Null.valid?(io) ? Null.load : UnsignedIntegerExcludingZero.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Name
4
- PATTERN = /(capture|remove|shift)/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io
11
- raise ArgumentError unless valid? io
12
-
13
- io.to_sym
14
- end
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- require_relative 'unsigned_integer_excluding_zero'
2
-
3
- module Sashite
4
- module GGN
5
- module NegativeInteger
6
- PATTERN = /-#{UnsignedIntegerExcludingZero::PATTERN}/
7
-
8
- def self.valid? io
9
- !!io.match("^#{PATTERN}$")
10
- end
11
-
12
- def self.load io
13
- raise ArgumentError unless valid? io
14
-
15
- io.to_i
16
- end
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Null
4
- PATTERN = /_/
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
- nil
14
- end
15
-
16
- def self.dump
17
- '_'
18
- end
19
- end
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- require_relative 'boolean'
2
- require_relative 'null'
3
- require_relative 'subject'
4
-
5
- module Sashite
6
- module GGN
7
- module Occupied
8
- PATTERN = /(#{Null::PATTERN}|#{Boolean::PATTERN}|#{Subject::PATTERN}|an_ally_actor|an_enemy_actor)/
9
-
10
- def self.valid? io
11
- !!io.match("^#{PATTERN}$")
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- if Null.valid? io
18
- Null.load
19
- elsif Boolean.valid? io
20
- Boolean.load io
21
- elsif Subject.valid? io
22
- Subject.load io
23
- else
24
- io.to_sym
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,20 +0,0 @@
1
- require_relative 'null'
2
- require_relative 'unsigned_integer'
3
-
4
- module Sashite
5
- module GGN
6
- module PreviousMovesCounter
7
- PATTERN = /(#{Null::PATTERN}|#{UnsignedInteger::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
- Null.valid?(io) ? Null.load : UnsignedInteger.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- require_relative 'actor'
2
- require_relative 'gameplay_into_base64'
3
-
4
- module Sashite
5
- module GGN
6
- module PromotableIntoActors
7
- PATTERN = /(#{GameplayIntoBase64::PATTERN},)*#{Actor::PATTERN}/
8
-
9
- def self.valid? io
10
- io.match("^#{PATTERN}$") &&
11
- io.split(',').uniq.join(',') == io
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- io.split(',').map do |value|
18
- Actor.valid?(value) ? Actor.load(value) : GameplayIntoBase64.load(value)
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,19 +0,0 @@
1
- require_relative 'boolean'
2
-
3
- module Sashite
4
- module GGN
5
- module Required
6
- PATTERN = /#{Boolean::PATTERN}/
7
-
8
- def self.valid? io
9
- !!io.match("^#{PATTERN}$")
10
- end
11
-
12
- def self.load io
13
- raise ArgumentError unless valid? io
14
-
15
- Boolean.load io
16
- end
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Self
4
- PATTERN = /self/
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
- :self
14
- end
15
-
16
- def self.dump
17
- 'self'
18
- end
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- require_relative 'unsigned_integer_excluding_zero'
2
- require_relative 'zero'
3
-
4
- module Sashite
5
- module GGN
6
- module UnsignedInteger
7
- PATTERN = /(#{Zero::PATTERN}|#{UnsignedIntegerExcludingZero::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
- Zero.valid?(io) ? Zero.load : UnsignedIntegerExcludingZero.load(io)
17
- end
18
- end
19
- end
20
- end