sashite-ggn 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/LICENSE.md +17 -18
- data/README.md +356 -506
- data/lib/sashite/ggn/piece/source/destination/engine/transition.rb +90 -0
- data/lib/sashite/ggn/piece/source/destination/engine.rb +407 -0
- data/lib/sashite/ggn/piece/source/destination.rb +65 -0
- data/lib/sashite/ggn/piece/source.rb +71 -0
- data/lib/sashite/ggn/piece.rb +77 -0
- data/lib/sashite/ggn/schema.rb +152 -0
- data/lib/sashite/ggn/validation_error.rb +31 -0
- data/lib/sashite/ggn.rb +317 -5
- data/lib/sashite-ggn.rb +112 -1
- metadata +31 -151
- data/.gitignore +0 -22
- data/.ruby-version +0 -1
- data/.travis.yml +0 -3
- data/Gemfile +0 -2
- data/Rakefile +0 -7
- data/VERSION.semver +0 -1
- data/lib/sashite/ggn/ability.rb +0 -29
- 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.rb +0 -20
- 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/object.rb +0 -28
- data/lib/sashite/ggn/occupied.rb +0 -29
- data/lib/sashite/ggn/pattern.rb +0 -20
- 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/square.rb +0 -29
- data/lib/sashite/ggn/state.rb +0 -26
- data/lib/sashite/ggn/subject.rb +0 -29
- data/lib/sashite/ggn/unsigned_integer.rb +0 -20
- data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +0 -20
- data/lib/sashite/ggn/verb.rb +0 -33
- data/lib/sashite/ggn/zero.rb +0 -21
- data/sashite-ggn.gemspec +0 -19
- data/test/_test_helper.rb +0 -2
- data/test/test_ggn.rb +0 -552
- data/test/test_ggn_ability.rb +0 -51
- 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.rb +0 -557
- 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_object.rb +0 -33
- data/test/test_ggn_occupied.rb +0 -78
- data/test/test_ggn_pattern.rb +0 -84
- 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_square.rb +0 -25
- data/test/test_ggn_state.rb +0 -24
- data/test/test_ggn_subject.rb +0 -28
- data/test/test_ggn_unsigned_integer.rb +0 -39
- data/test/test_ggn_unsigned_integer_excluding_zero.rb +0 -25
- data/test/test_ggn_verb.rb +0 -27
- data/test/test_ggn_zero.rb +0 -21
data/lib/sashite-ggn.rb
CHANGED
@@ -1 +1,112 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Sashité - Abstract Strategy Board Games Notation Library
|
4
|
+
#
|
5
|
+
# This library provides a comprehensive implementation of the General Gameplay Notation (GGN)
|
6
|
+
# specification, which is a rule-agnostic, JSON-based format for describing pseudo-legal
|
7
|
+
# moves in abstract strategy board games.
|
8
|
+
#
|
9
|
+
# GGN works alongside other Sashité specifications:
|
10
|
+
# - GAN (General Actor Notation): Unique piece identifiers
|
11
|
+
# - FEEN (Forsyth-Edwards Enhanced Notation): Board position representation
|
12
|
+
# - PMN (Portable Move Notation): Move sequence representation
|
13
|
+
#
|
14
|
+
# @author Sashité <https://sashite.com/>
|
15
|
+
# @version 1.0.0
|
16
|
+
# @see https://sashite.dev/documents/ggn/1.0.0/ GGN Specification
|
17
|
+
# @see https://github.com/sashite/ggn.rb Official Ruby implementation
|
18
|
+
#
|
19
|
+
# @example Basic usage with a chess pawn double move
|
20
|
+
# # Load GGN data from file
|
21
|
+
# require "sashite/ggn"
|
22
|
+
#
|
23
|
+
# piece_data = Sashite::Ggn.load_file("chess_moves.json")
|
24
|
+
# engine = piece_data.fetch("CHESS:P").fetch("e2").fetch("e4")
|
25
|
+
#
|
26
|
+
# # Check if the move is valid given current board state
|
27
|
+
# board_state = {
|
28
|
+
# "e2" => "CHESS:P", # White pawn on e2
|
29
|
+
# "e3" => nil, # Empty square
|
30
|
+
# "e4" => nil # Empty square
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# result = engine.evaluate(board_state, {}, "CHESS")
|
34
|
+
#
|
35
|
+
# if result
|
36
|
+
# puts "Move is valid!"
|
37
|
+
# puts "Board changes: #{result.diff}"
|
38
|
+
# # => { "e2" => nil, "e4" => "CHESS:P" }
|
39
|
+
# puts "Piece gained: #{result.gain}" # => nil (no capture)
|
40
|
+
# puts "Piece dropped: #{result.drop}" # => nil (not a drop move)
|
41
|
+
# else
|
42
|
+
# puts "Move is not valid under current conditions"
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# @example Piece drops in Shogi
|
46
|
+
# # Shogi allows captured pieces to be dropped back onto the board
|
47
|
+
# piece_data = Sashite::Ggn.load_file("shogi_moves.json")
|
48
|
+
# engine = piece_data.fetch("SHOGI:P").fetch("*").fetch("5e")
|
49
|
+
#
|
50
|
+
# # Player has captured pawns available
|
51
|
+
# captures = { "SHOGI:P" => 2 }
|
52
|
+
#
|
53
|
+
# # Current board state (5th file is clear of unpromoted pawns)
|
54
|
+
# board_state = {
|
55
|
+
# "5e" => nil, # Target square is empty
|
56
|
+
# "5a" => nil, "5b" => nil, "5c" => nil, "5d" => nil,
|
57
|
+
# "5f" => nil, "5g" => nil, "5h" => nil, "5i" => nil
|
58
|
+
# }
|
59
|
+
#
|
60
|
+
# result = engine.evaluate(board_state, captures, "SHOGI")
|
61
|
+
#
|
62
|
+
# if result
|
63
|
+
# puts "Pawn drop is valid!"
|
64
|
+
# puts "Board changes: #{result.diff}" # => { "5e" => "SHOGI:P" }
|
65
|
+
# puts "Piece dropped from hand: #{result.drop}" # => "SHOGI:P"
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# @example Captures with piece promotion
|
69
|
+
# # A chess pawn capturing and promoting to queen
|
70
|
+
# piece_data = Sashite::Ggn.load_file("chess_moves.json")
|
71
|
+
# engine = piece_data.fetch("CHESS:P").fetch("g7").fetch("h8")
|
72
|
+
#
|
73
|
+
# # Board with enemy piece on h8
|
74
|
+
# board_state = {
|
75
|
+
# "g7" => "CHESS:P", # Our pawn ready to promote
|
76
|
+
# "h8" => "chess:r" # Enemy rook (lowercase = opponent)
|
77
|
+
# }
|
78
|
+
#
|
79
|
+
# result = engine.evaluate(board_state, {}, "CHESS")
|
80
|
+
#
|
81
|
+
# if result
|
82
|
+
# puts "Pawn promotes and captures!"
|
83
|
+
# puts "Final position: #{result.diff}"
|
84
|
+
# # => { "g7" => nil, "h8" => "CHESS:Q" }
|
85
|
+
# puts "Captured piece: #{result.gain}" # => nil (no capture _in hand_)
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# @example Loading GGN data from different sources
|
89
|
+
# # From file
|
90
|
+
# piece_data = Sashite::Ggn.load_file("moves.json")
|
91
|
+
#
|
92
|
+
# # From JSON string
|
93
|
+
# json_string = '{"CHESS:K": {"e1": {"e2": [{"perform": {"e1": null, "e2": "CHESS:K"}}]}}}'
|
94
|
+
# piece_data = Sashite::Ggn.load_string(json_string)
|
95
|
+
#
|
96
|
+
# # From Hash
|
97
|
+
# ggn_hash = { "CHESS:K" => { "e1" => { "e2" => [{ "perform" => { "e1" => nil, "e2" => "CHESS:K" } }] } } }
|
98
|
+
# piece_data = Sashite::Ggn.load_hash(ggn_hash)
|
99
|
+
module Sashite
|
100
|
+
# Base namespace for all Sashité notation libraries.
|
101
|
+
#
|
102
|
+
# Sashité provides a comprehensive suite of specifications and implementations
|
103
|
+
# for representing abstract strategy board games in a rule-agnostic manner.
|
104
|
+
# This allows for unified game engines, cross-game analysis, and hybrid
|
105
|
+
# game variants.
|
106
|
+
#
|
107
|
+
# @see https://sashite.com/ Official Sashité website
|
108
|
+
# @see https://sashite.dev/ Developer documentation and specifications
|
109
|
+
end
|
110
|
+
|
111
|
+
# Load the main GGN implementation
|
112
|
+
require_relative "sashite/ggn"
|
metadata
CHANGED
@@ -1,144 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-ggn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
8
|
-
autorequire:
|
7
|
+
- Cyril Kato
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
13
|
+
name: json_schemer
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
18
|
+
version: 2.4.0
|
19
|
+
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
version: '5'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10'
|
55
|
-
description: A Ruby interface for data serialization in GGN format.
|
56
|
-
email:
|
57
|
-
- contact@cyril.io
|
25
|
+
version: 2.4.0
|
26
|
+
description: A Ruby implementation of the General Gameplay Notation (GGN) specification.
|
27
|
+
GGN is a rule-agnostic, JSON-based format for describing pseudo-legal moves in abstract
|
28
|
+
strategy board games. This library provides parsing, validation, and evaluation
|
29
|
+
capabilities for GGN documents, enabling game engines to work with movement rules
|
30
|
+
across different board games including Chess, Shogi, Xiangqi, and custom variants.
|
31
|
+
email: contact@cyril.email
|
58
32
|
executables: []
|
59
33
|
extensions: []
|
60
34
|
extra_rdoc_files: []
|
61
35
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".ruby-version"
|
64
|
-
- ".travis.yml"
|
65
|
-
- Gemfile
|
66
36
|
- LICENSE.md
|
67
37
|
- README.md
|
68
|
-
- Rakefile
|
69
|
-
- VERSION.semver
|
70
38
|
- lib/sashite-ggn.rb
|
71
39
|
- lib/sashite/ggn.rb
|
72
|
-
- lib/sashite/ggn/
|
73
|
-
- lib/sashite/ggn/
|
74
|
-
- lib/sashite/ggn/
|
75
|
-
- lib/sashite/ggn/
|
76
|
-
- lib/sashite/ggn/
|
77
|
-
- lib/sashite/ggn/
|
78
|
-
- lib/sashite/ggn/
|
79
|
-
- lib/sashite/ggn/digit_excluding_zero.rb
|
80
|
-
- lib/sashite/ggn/direction.rb
|
81
|
-
- lib/sashite/ggn/gameplay.rb
|
82
|
-
- lib/sashite/ggn/gameplay_into_base64.rb
|
83
|
-
- lib/sashite/ggn/integer.rb
|
84
|
-
- lib/sashite/ggn/last_moved_actor.rb
|
85
|
-
- lib/sashite/ggn/maximum_magnitude.rb
|
86
|
-
- lib/sashite/ggn/name.rb
|
87
|
-
- lib/sashite/ggn/negative_integer.rb
|
88
|
-
- lib/sashite/ggn/null.rb
|
89
|
-
- lib/sashite/ggn/object.rb
|
90
|
-
- lib/sashite/ggn/occupied.rb
|
91
|
-
- lib/sashite/ggn/pattern.rb
|
92
|
-
- lib/sashite/ggn/previous_moves_counter.rb
|
93
|
-
- lib/sashite/ggn/promotable_into_actors.rb
|
94
|
-
- lib/sashite/ggn/required.rb
|
95
|
-
- lib/sashite/ggn/self.rb
|
96
|
-
- lib/sashite/ggn/square.rb
|
97
|
-
- lib/sashite/ggn/state.rb
|
98
|
-
- lib/sashite/ggn/subject.rb
|
99
|
-
- lib/sashite/ggn/unsigned_integer.rb
|
100
|
-
- lib/sashite/ggn/unsigned_integer_excluding_zero.rb
|
101
|
-
- lib/sashite/ggn/verb.rb
|
102
|
-
- lib/sashite/ggn/zero.rb
|
103
|
-
- sashite-ggn.gemspec
|
104
|
-
- test/_test_helper.rb
|
105
|
-
- test/test_ggn.rb
|
106
|
-
- test/test_ggn_ability.rb
|
107
|
-
- test/test_ggn_actor.rb
|
108
|
-
- test/test_ggn_ally.rb
|
109
|
-
- test/test_ggn_area.rb
|
110
|
-
- test/test_ggn_attacked.rb
|
111
|
-
- test/test_ggn_boolean.rb
|
112
|
-
- test/test_ggn_digit.rb
|
113
|
-
- test/test_ggn_digit_excluding_zero.rb
|
114
|
-
- test/test_ggn_direction.rb
|
115
|
-
- test/test_ggn_gameplay.rb
|
116
|
-
- test/test_ggn_gameplay_into_base64.rb
|
117
|
-
- test/test_ggn_integer.rb
|
118
|
-
- test/test_ggn_last_moved_actor.rb
|
119
|
-
- test/test_ggn_maximum_magnitude.rb
|
120
|
-
- test/test_ggn_name.rb
|
121
|
-
- test/test_ggn_negative_integer.rb
|
122
|
-
- test/test_ggn_null.rb
|
123
|
-
- test/test_ggn_object.rb
|
124
|
-
- test/test_ggn_occupied.rb
|
125
|
-
- test/test_ggn_pattern.rb
|
126
|
-
- test/test_ggn_previous_moves_counter.rb
|
127
|
-
- test/test_ggn_promotable_into_actors.rb
|
128
|
-
- test/test_ggn_required.rb
|
129
|
-
- test/test_ggn_self.rb
|
130
|
-
- test/test_ggn_square.rb
|
131
|
-
- test/test_ggn_state.rb
|
132
|
-
- test/test_ggn_subject.rb
|
133
|
-
- test/test_ggn_unsigned_integer.rb
|
134
|
-
- test/test_ggn_unsigned_integer_excluding_zero.rb
|
135
|
-
- test/test_ggn_verb.rb
|
136
|
-
- test/test_ggn_zero.rb
|
40
|
+
- lib/sashite/ggn/piece.rb
|
41
|
+
- lib/sashite/ggn/piece/source.rb
|
42
|
+
- lib/sashite/ggn/piece/source/destination.rb
|
43
|
+
- lib/sashite/ggn/piece/source/destination/engine.rb
|
44
|
+
- lib/sashite/ggn/piece/source/destination/engine/transition.rb
|
45
|
+
- lib/sashite/ggn/schema.rb
|
46
|
+
- lib/sashite/ggn/validation_error.rb
|
137
47
|
homepage: https://github.com/sashite/ggn.rb
|
138
48
|
licenses:
|
139
49
|
- MIT
|
140
|
-
metadata:
|
141
|
-
|
50
|
+
metadata:
|
51
|
+
bug_tracker_uri: https://github.com/sashite/ggn.rb/issues
|
52
|
+
documentation_uri: https://rubydoc.info/github/sashite/ggn.rb/main
|
53
|
+
homepage_uri: https://github.com/sashite/ggn.rb
|
54
|
+
source_code_uri: https://github.com/sashite/ggn.rb
|
55
|
+
specification_uri: https://sashite.dev/documents/ggn/1.0.0/
|
56
|
+
rubygems_mfa_required: 'true'
|
142
57
|
rdoc_options: []
|
143
58
|
require_paths:
|
144
59
|
- lib
|
@@ -146,49 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
61
|
requirements:
|
147
62
|
- - ">="
|
148
63
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
64
|
+
version: 3.2.0
|
150
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
66
|
requirements:
|
152
67
|
- - ">="
|
153
68
|
- !ruby/object:Gem::Version
|
154
69
|
version: '0'
|
155
70
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.2.2
|
158
|
-
signing_key:
|
71
|
+
rubygems_version: 3.6.9
|
159
72
|
specification_version: 4
|
160
|
-
summary: General Gameplay Notation
|
161
|
-
test_files:
|
162
|
-
- test/_test_helper.rb
|
163
|
-
- test/test_ggn.rb
|
164
|
-
- test/test_ggn_ability.rb
|
165
|
-
- test/test_ggn_actor.rb
|
166
|
-
- test/test_ggn_ally.rb
|
167
|
-
- test/test_ggn_area.rb
|
168
|
-
- test/test_ggn_attacked.rb
|
169
|
-
- test/test_ggn_boolean.rb
|
170
|
-
- test/test_ggn_digit.rb
|
171
|
-
- test/test_ggn_digit_excluding_zero.rb
|
172
|
-
- test/test_ggn_direction.rb
|
173
|
-
- test/test_ggn_gameplay.rb
|
174
|
-
- test/test_ggn_gameplay_into_base64.rb
|
175
|
-
- test/test_ggn_integer.rb
|
176
|
-
- test/test_ggn_last_moved_actor.rb
|
177
|
-
- test/test_ggn_maximum_magnitude.rb
|
178
|
-
- test/test_ggn_name.rb
|
179
|
-
- test/test_ggn_negative_integer.rb
|
180
|
-
- test/test_ggn_null.rb
|
181
|
-
- test/test_ggn_object.rb
|
182
|
-
- test/test_ggn_occupied.rb
|
183
|
-
- test/test_ggn_pattern.rb
|
184
|
-
- test/test_ggn_previous_moves_counter.rb
|
185
|
-
- test/test_ggn_promotable_into_actors.rb
|
186
|
-
- test/test_ggn_required.rb
|
187
|
-
- test/test_ggn_self.rb
|
188
|
-
- test/test_ggn_square.rb
|
189
|
-
- test/test_ggn_state.rb
|
190
|
-
- test/test_ggn_subject.rb
|
191
|
-
- test/test_ggn_unsigned_integer.rb
|
192
|
-
- test/test_ggn_unsigned_integer_excluding_zero.rb
|
193
|
-
- test/test_ggn_verb.rb
|
194
|
-
- test/test_ggn_zero.rb
|
73
|
+
summary: General Gameplay Notation (GGN) parser and validator for Ruby
|
74
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.2
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/VERSION.semver
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
data/lib/sashite/ggn/ability.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative 'subject'
|
2
|
-
require_relative 'verb'
|
3
|
-
require_relative 'object'
|
4
|
-
|
5
|
-
module Sashite
|
6
|
-
module GGN
|
7
|
-
module Ability
|
8
|
-
PATTERN = /#{Subject::PATTERN}\^#{Verb::PATTERN}=#{Object::PATTERN}/
|
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
|
-
subject = Subject.load io.split('^').fetch 0
|
18
|
-
verb = Verb.load io.split('^').fetch(1).split('=').fetch 0
|
19
|
-
object = Object.load io.split('=').fetch 1
|
20
|
-
|
21
|
-
{
|
22
|
-
subject: subject,
|
23
|
-
verb: verb,
|
24
|
-
object: object
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
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
|
data/lib/sashite/ggn/gameplay.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'pattern'
|
2
|
-
|
3
|
-
module Sashite
|
4
|
-
module GGN
|
5
|
-
module Gameplay
|
6
|
-
PATTERN = /#{Pattern::PATTERN}(\. #{Pattern::PATTERN})*\./
|
7
|
-
|
8
|
-
def self.valid? io
|
9
|
-
io.match("^#{PATTERN}$") &&
|
10
|
-
io.split('. ').sort.join('. ') == io &&
|
11
|
-
io[0..-2].split('. ').uniq.join('. ').concat('.') == io
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.load io
|
15
|
-
raise ArgumentError unless valid? io
|
16
|
-
io[0..-2].split('. ').map { |s| Pattern.load s }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
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
|