sashite-ggn 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/LICENSE.md +22 -0
- data/README.md +566 -0
- data/Rakefile +7 -0
- data/VERSION.semver +1 -0
- data/lib/sashite-ggn.rb +1 -0
- data/lib/sashite/ggn.rb +9 -0
- data/lib/sashite/ggn/ability.rb +37 -0
- data/lib/sashite/ggn/actor.rb +28 -0
- data/lib/sashite/ggn/ally.rb +28 -0
- data/lib/sashite/ggn/area.rb +25 -0
- data/lib/sashite/ggn/attacked.rb +28 -0
- data/lib/sashite/ggn/boolean.rb +25 -0
- data/lib/sashite/ggn/digit.rb +28 -0
- data/lib/sashite/ggn/digit_excluding_zero.rb +25 -0
- data/lib/sashite/ggn/direction.rb +27 -0
- data/lib/sashite/ggn/gameplay.rb +40 -0
- data/lib/sashite/ggn/gameplay_into_base64.rb +28 -0
- data/lib/sashite/ggn/integer.rb +28 -0
- data/lib/sashite/ggn/last_moved_actor.rb +28 -0
- data/lib/sashite/ggn/maximum_magnitude.rb +28 -0
- data/lib/sashite/ggn/name.rb +25 -0
- data/lib/sashite/ggn/negative_integer.rb +27 -0
- data/lib/sashite/ggn/null.rb +23 -0
- data/lib/sashite/ggn/object.rb +36 -0
- data/lib/sashite/ggn/occupied.rb +37 -0
- data/lib/sashite/ggn/pattern.rb +29 -0
- data/lib/sashite/ggn/previous_moves_counter.rb +28 -0
- data/lib/sashite/ggn/promotable_into_actors.rb +32 -0
- data/lib/sashite/ggn/required.rb +27 -0
- data/lib/sashite/ggn/self.rb +23 -0
- data/lib/sashite/ggn/square.rb +37 -0
- data/lib/sashite/ggn/state.rb +34 -0
- data/lib/sashite/ggn/subject.rb +37 -0
- data/lib/sashite/ggn/unsigned_integer.rb +28 -0
- data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +28 -0
- data/lib/sashite/ggn/verb.rb +42 -0
- data/lib/sashite/ggn/zero.rb +23 -0
- data/sashite-ggn.gemspec +21 -0
- data/test/_test_helper.rb +2 -0
- data/test/test_ggn.rb +546 -0
- data/test/test_ggn_ability.rb +51 -0
- data/test/test_ggn_actor.rb +591 -0
- data/test/test_ggn_ally.rb +51 -0
- data/test/test_ggn_area.rb +79 -0
- data/test/test_ggn_attacked.rb +51 -0
- data/test/test_ggn_boolean.rb +37 -0
- data/test/test_ggn_digit.rb +21 -0
- data/test/test_ggn_digit_excluding_zero.rb +22 -0
- data/test/test_ggn_direction.rb +21 -0
- data/test/test_ggn_gameplay.rb +573 -0
- data/test/test_ggn_gameplay_into_base64.rb +545 -0
- data/test/test_ggn_integer.rb +41 -0
- data/test/test_ggn_last_moved_actor.rb +51 -0
- data/test/test_ggn_maximum_magnitude.rb +37 -0
- data/test/test_ggn_name.rb +51 -0
- data/test/test_ggn_negative_integer.rb +21 -0
- data/test/test_ggn_null.rb +21 -0
- data/test/test_ggn_object.rb +35 -0
- data/test/test_ggn_occupied.rb +102 -0
- data/test/test_ggn_pattern.rb +82 -0
- data/test/test_ggn_previous_moves_counter.rb +41 -0
- data/test/test_ggn_promotable_into_actors.rb +598 -0
- data/test/test_ggn_required.rb +37 -0
- data/test/test_ggn_self.rb +21 -0
- data/test/test_ggn_square.rb +27 -0
- data/test/test_ggn_state.rb +28 -0
- data/test/test_ggn_subject.rb +30 -0
- data/test/test_ggn_unsigned_integer.rb +21 -0
- data/test/test_ggn_unsigned_integer_excluding_zero.rb +21 -0
- data/test/test_ggn_verb.rb +26 -0
- data/test/test_ggn_zero.rb +21 -0
- metadata +208 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Integer do
|
4
|
+
describe '.new' do
|
5
|
+
describe 'negative' do
|
6
|
+
before do
|
7
|
+
@integer = Sashite::GGN::Integer.new('-42')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the GGN as a JSON' do
|
11
|
+
@integer.as_json.must_equal -42
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the GGN as a string' do
|
15
|
+
@integer.to_s.must_equal '-42'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'raises an error' do
|
19
|
+
-> { Sashite::GGN::Integer.new('-01') }.must_raise ArgumentError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'unsigned' do
|
24
|
+
before do
|
25
|
+
@integer = Sashite::GGN::Integer.new('42')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the GGN as a JSON' do
|
29
|
+
@integer.as_json.must_equal 42
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns the GGN as a string' do
|
33
|
+
@integer.to_s.must_equal '42'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises an error' do
|
37
|
+
-> { Sashite::GGN::Integer.new('01') }.must_raise ArgumentError
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::LastMovedActor do
|
4
|
+
describe '.new' do
|
5
|
+
describe 'false' do
|
6
|
+
before do
|
7
|
+
@last_moved_actor = Sashite::GGN::LastMovedActor.new('f')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the GGN as a JSON' do
|
11
|
+
@last_moved_actor.as_json.must_equal false
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the GGN as a string' do
|
15
|
+
@last_moved_actor.to_s.must_equal 'f'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'true' do
|
20
|
+
before do
|
21
|
+
@last_moved_actor = Sashite::GGN::LastMovedActor.new('t')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the GGN as a JSON' do
|
25
|
+
@last_moved_actor.as_json.must_equal true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the GGN as a string' do
|
29
|
+
@last_moved_actor.to_s.must_equal 't'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'null' do
|
34
|
+
before do
|
35
|
+
@last_moved_actor = Sashite::GGN::LastMovedActor.new('_')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns the GGN as a JSON' do
|
39
|
+
@last_moved_actor.as_json.must_equal nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the GGN as a string' do
|
43
|
+
@last_moved_actor.to_s.must_equal '_'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'raises an error' do
|
49
|
+
-> { Sashite::GGN::LastMovedActor.new('foobar') }.must_raise ArgumentError
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::MaximumMagnitude do
|
4
|
+
describe '.new' do
|
5
|
+
describe 'null' do
|
6
|
+
before do
|
7
|
+
@maximum_magnitude = Sashite::GGN::MaximumMagnitude.new('_')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the GGN as a JSON' do
|
11
|
+
@maximum_magnitude.as_json.must_equal nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the GGN as a string' do
|
15
|
+
@maximum_magnitude.to_s.must_equal '_'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'unsigned integer' do
|
20
|
+
before do
|
21
|
+
@maximum_magnitude = Sashite::GGN::MaximumMagnitude.new('42')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the GGN as a JSON' do
|
25
|
+
@maximum_magnitude.as_json.must_equal 42
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the GGN as a string' do
|
29
|
+
@maximum_magnitude.to_s.must_equal '42'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'raises an error' do
|
35
|
+
-> { Sashite::GGN::MaximumMagnitude.new('0') }.must_raise ArgumentError
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Name do
|
4
|
+
describe '.new' do
|
5
|
+
describe 'capture' do
|
6
|
+
before do
|
7
|
+
@name = Sashite::GGN::Name.new('capture')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the GGN as a JSON' do
|
11
|
+
@name.as_json.must_equal :capture
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the GGN as a string' do
|
15
|
+
@name.to_s.must_equal 'capture'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'remove' do
|
20
|
+
before do
|
21
|
+
@name = Sashite::GGN::Name.new('remove')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the GGN as a JSON' do
|
25
|
+
@name.as_json.must_equal :remove
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the GGN as a string' do
|
29
|
+
@name.to_s.must_equal 'remove'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'shift' do
|
34
|
+
before do
|
35
|
+
@name = Sashite::GGN::Name.new('shift')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns the GGN as a JSON' do
|
39
|
+
@name.as_json.must_equal :shift
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the GGN as a string' do
|
43
|
+
@name.to_s.must_equal 'shift'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'raises an error' do
|
49
|
+
-> { Sashite::GGN::Name.new('foobar') }.must_raise ArgumentError
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::NegativeInteger do
|
4
|
+
describe '.new' do
|
5
|
+
before do
|
6
|
+
@negative_integer = Sashite::GGN::NegativeInteger.new('-42')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns the GGN as a JSON' do
|
10
|
+
@negative_integer.as_json.must_equal -42
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns the GGN as a string' do
|
14
|
+
@negative_integer.to_s.must_equal '-42'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'raises an error' do
|
19
|
+
-> { Sashite::GGN::NegativeInteger.new('42') }.must_raise ArgumentError
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Null do
|
4
|
+
describe '.instance' do
|
5
|
+
before do
|
6
|
+
@null = Sashite::GGN::Null.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns the GGN as a JSON' do
|
10
|
+
@null.as_json.must_be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns the GGN as a string' do
|
14
|
+
@null.to_s.must_equal '_'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is false' do
|
19
|
+
Sashite::GGN::Null.valid?('foobar').must_equal false
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Object do
|
4
|
+
describe '.new' do
|
5
|
+
before do
|
6
|
+
@object = Sashite::GGN::Object.new('_@f+all~_@f+all%self')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns the GGN as a JSON' do
|
10
|
+
@object.as_json.hash.must_equal(
|
11
|
+
{
|
12
|
+
src_square: {
|
13
|
+
:"...attacked?" => nil,
|
14
|
+
:"...occupied!" => false,
|
15
|
+
area: :all
|
16
|
+
},
|
17
|
+
dst_square: {
|
18
|
+
:"...attacked?" => nil,
|
19
|
+
:"...occupied!" => false,
|
20
|
+
area: :all
|
21
|
+
},
|
22
|
+
promotable_into_actors: [:self]
|
23
|
+
}.hash
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns the GGN as a string' do
|
28
|
+
@object.to_s.must_equal '_@f+all~_@f+all%self'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises an error' do
|
33
|
+
-> { Sashite::GGN::Object.new('foo') }.must_raise ArgumentError
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Occupied do
|
4
|
+
describe '.new' do
|
5
|
+
describe 'an ally actor' do
|
6
|
+
before do
|
7
|
+
@occupied = Sashite::GGN::Occupied.new('an_ally_actor')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the GGN as a JSON' do
|
11
|
+
@occupied.as_json.must_equal :an_ally_actor
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the GGN as a string' do
|
15
|
+
@occupied.to_s.must_equal 'an_ally_actor'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'an enemy actor' do
|
20
|
+
before do
|
21
|
+
@occupied = Sashite::GGN::Occupied.new('an_enemy_actor')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the GGN as a JSON' do
|
25
|
+
@occupied.as_json.must_equal :an_enemy_actor
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the GGN as a string' do
|
29
|
+
@occupied.to_s.must_equal 'an_enemy_actor'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'null' do
|
34
|
+
before do
|
35
|
+
@occupied = Sashite::GGN::Occupied.new('_')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns the GGN as a JSON' do
|
39
|
+
@occupied.as_json.must_equal nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the GGN as a string' do
|
43
|
+
@occupied.to_s.must_equal '_'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'true' do
|
48
|
+
before do
|
49
|
+
@occupied = Sashite::GGN::Occupied.new('t')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns the GGN as a JSON' do
|
53
|
+
@occupied.as_json.must_equal true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'returns the GGN as a string' do
|
57
|
+
@occupied.to_s.must_equal 't'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'false' do
|
62
|
+
before do
|
63
|
+
@occupied = Sashite::GGN::Occupied.new('f')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns the GGN as a JSON' do
|
67
|
+
@occupied.as_json.must_equal false
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns the GGN as a string' do
|
71
|
+
@occupied.to_s.must_equal 'f'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'a subject' do
|
76
|
+
before do
|
77
|
+
@occupied = Sashite::GGN::Occupied.new('f<self>_&_')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'returns the GGN as a JSON' do
|
81
|
+
@occupied.as_json.hash.must_equal(
|
82
|
+
{
|
83
|
+
:"...ally?" => false,
|
84
|
+
actor: :self,
|
85
|
+
state: {
|
86
|
+
:"...last_moved_actor?" => nil,
|
87
|
+
:"...previous_moves_counter" => nil
|
88
|
+
}
|
89
|
+
}.hash
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns the GGN as a string' do
|
94
|
+
@occupied.to_s.must_equal 'f<self>_&_'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'raises an error' do
|
100
|
+
-> { Sashite::GGN::Occupied.new('foobar') }.must_raise ArgumentError
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_relative '_test_helper'
|
2
|
+
|
3
|
+
describe Sashite::GGN::Pattern do
|
4
|
+
describe '.new' do
|
5
|
+
before do
|
6
|
+
@pattern = Sashite::GGN::Pattern.new('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')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns the GGN as a JSON' do
|
10
|
+
@pattern.as_json.hash.must_equal(
|
11
|
+
[
|
12
|
+
{
|
13
|
+
:"subject" => {
|
14
|
+
:"...ally?" => true,
|
15
|
+
:"actor" => :self,
|
16
|
+
:"state" => {
|
17
|
+
:"...last_moved_actor?" => nil,
|
18
|
+
:"...previous_moves_counter" => nil
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
:"verb" => {
|
23
|
+
:"name" => :shift,
|
24
|
+
:"vector" => {:"...maximum_magnitude" => nil, :direction => [-1,0]}
|
25
|
+
},
|
26
|
+
|
27
|
+
:"object" => {
|
28
|
+
:"src_square" => {
|
29
|
+
:"...attacked?" => nil,
|
30
|
+
:"...occupied!" => false,
|
31
|
+
:"area" => :all
|
32
|
+
},
|
33
|
+
:"dst_square" => {
|
34
|
+
:"...attacked?" => nil,
|
35
|
+
:"...occupied!" => false,
|
36
|
+
:"area" => :all
|
37
|
+
},
|
38
|
+
:"promotable_into_actors" => [:self]
|
39
|
+
}
|
40
|
+
},
|
41
|
+
{
|
42
|
+
:"subject" => {
|
43
|
+
:"...ally?" => true,
|
44
|
+
:"actor" => :self,
|
45
|
+
:"state" => {
|
46
|
+
:"...last_moved_actor?" => nil,
|
47
|
+
:"...previous_moves_counter" => nil
|
48
|
+
}
|
49
|
+
},
|
50
|
+
|
51
|
+
:"verb" => {
|
52
|
+
:"name" => :remove,
|
53
|
+
:"vector" => {:"...maximum_magnitude" => 1, :direction => [-1,0]}
|
54
|
+
},
|
55
|
+
|
56
|
+
:"object" => {
|
57
|
+
:"src_square" => {
|
58
|
+
:"...attacked?" => nil,
|
59
|
+
:"...occupied!" => false,
|
60
|
+
:"area" => :all
|
61
|
+
},
|
62
|
+
:"dst_square" => {
|
63
|
+
:"...attacked?" => nil,
|
64
|
+
:"...occupied!" => :an_enemy_actor,
|
65
|
+
:"area" => :all
|
66
|
+
},
|
67
|
+
:"promotable_into_actors" => [:self]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
].hash
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns the GGN as a string' do
|
75
|
+
@pattern.to_s.must_equal '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'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'raises an error' do
|
80
|
+
-> { Sashite::GGN::Pattern.new('foobar') }.must_raise ArgumentError
|
81
|
+
end
|
82
|
+
end
|