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.
- checksums.yaml +4 -4
- data/README.md +8 -528
- data/VERSION.semver +1 -1
- data/lib/sashite/ggn.rb +2 -2
- data/lib/sashite/ggn/ability.rb +2 -20
- data/lib/sashite/ggn/gameplay.rb +2 -13
- data/lib/sashite/ggn/object.rb +2 -21
- data/lib/sashite/ggn/pattern.rb +2 -13
- data/lib/sashite/ggn/square.rb +2 -24
- data/lib/sashite/ggn/state.rb +2 -21
- data/lib/sashite/ggn/subject.rb +2 -22
- data/lib/sashite/ggn/verb.rb +2 -28
- data/sashite-ggn.gemspec +2 -2
- data/test/test_ggn.rb +6 -543
- data/test/test_ggn_ability.rb +28 -38
- data/test/test_ggn_gameplay.rb +8 -548
- data/test/test_ggn_object.rb +30 -22
- data/test/test_ggn_pattern.rb +8 -75
- data/test/test_ggn_square.rb +30 -14
- data/test/test_ggn_state.rb +18 -13
- data/test/test_ggn_subject.rb +30 -17
- data/test/test_ggn_verb.rb +18 -16
- metadata +4 -73
- data/lib/sashite/ggn/actor.rb +0 -20
- data/lib/sashite/ggn/ally.rb +0 -20
- data/lib/sashite/ggn/area.rb +0 -17
- data/lib/sashite/ggn/attacked.rb +0 -20
- data/lib/sashite/ggn/boolean.rb +0 -17
- data/lib/sashite/ggn/digit.rb +0 -20
- data/lib/sashite/ggn/digit_excluding_zero.rb +0 -17
- data/lib/sashite/ggn/direction.rb +0 -19
- data/lib/sashite/ggn/gameplay_into_base64.rb +0 -21
- data/lib/sashite/ggn/integer.rb +0 -20
- data/lib/sashite/ggn/last_moved_actor.rb +0 -20
- data/lib/sashite/ggn/maximum_magnitude.rb +0 -20
- data/lib/sashite/ggn/name.rb +0 -17
- data/lib/sashite/ggn/negative_integer.rb +0 -19
- data/lib/sashite/ggn/null.rb +0 -21
- data/lib/sashite/ggn/occupied.rb +0 -29
- data/lib/sashite/ggn/previous_moves_counter.rb +0 -20
- data/lib/sashite/ggn/promotable_into_actors.rb +0 -23
- data/lib/sashite/ggn/required.rb +0 -19
- data/lib/sashite/ggn/self.rb +0 -21
- data/lib/sashite/ggn/unsigned_integer.rb +0 -20
- data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +0 -20
- data/lib/sashite/ggn/zero.rb +0 -21
- data/test/test_ggn_actor.rb +0 -571
- data/test/test_ggn_ally.rb +0 -35
- data/test/test_ggn_area.rb +0 -21
- data/test/test_ggn_attacked.rb +0 -35
- data/test/test_ggn_boolean.rb +0 -21
- data/test/test_ggn_digit.rb +0 -21
- data/test/test_ggn_digit_excluding_zero.rb +0 -21
- data/test/test_ggn_direction.rb +0 -21
- data/test/test_ggn_gameplay_into_base64.rb +0 -555
- data/test/test_ggn_integer.rb +0 -39
- data/test/test_ggn_last_moved_actor.rb +0 -35
- data/test/test_ggn_maximum_magnitude.rb +0 -39
- data/test/test_ggn_name.rb +0 -21
- data/test/test_ggn_negative_integer.rb +0 -21
- data/test/test_ggn_null.rb +0 -21
- data/test/test_ggn_occupied.rb +0 -78
- data/test/test_ggn_previous_moves_counter.rb +0 -39
- data/test/test_ggn_promotable_into_actors.rb +0 -578
- data/test/test_ggn_required.rb +0 -21
- data/test/test_ggn_self.rb +0 -21
- data/test/test_ggn_unsigned_integer.rb +0 -39
- data/test/test_ggn_unsigned_integer_excluding_zero.rb +0 -25
- data/test/test_ggn_zero.rb +0 -21
data/lib/sashite/ggn/actor.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/ally.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/area.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/attacked.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/boolean.rb
DELETED
data/lib/sashite/ggn/digit.rb
DELETED
@@ -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,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
|
data/lib/sashite/ggn/integer.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/name.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/null.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/occupied.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/required.rb
DELETED
@@ -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
|
data/lib/sashite/ggn/self.rb
DELETED
@@ -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
|