sashite-hand 1.0.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 +7 -0
- data/LICENSE.md +22 -0
- data/README.md +116 -0
- data/lib/sashite/hand.rb +44 -0
- data/lib/sashite-hand.rb +9 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0a34e61b9b036899e230483af790988ca1ee15a47d046e75422158062a1f8688
|
|
4
|
+
data.tar.gz: 2f40ad92442b907e0385ccae4363bfe3c3aad561b2b94264b8456f3623eda193
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f18bec432f3ab88e64957c17400c317e7f1068b247fa04f5b26d682ca3601c4d892e647406a9c0afb90cf04bb60d67cfc72a262323335587b3629e5d7c4b2445
|
|
7
|
+
data.tar.gz: a3891d91130f6b7fb78767d049b6e543ce4ccc6eb49fb93a4a56ec9a6eea1f4401bf3a2b86e59f7164043fe5d91c763abb7f4dce19e68ee9aa267cf33993c0ef
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2025 Sashite
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Hand.rb
|
|
2
|
+
|
|
3
|
+
[](https://github.com/sashite/hand.rb/tags)
|
|
4
|
+
[](https://rubydoc.info/github/sashite/hand.rb/main)
|
|
5
|
+

|
|
6
|
+
[](https://github.com/sashite/hand.rb/raw/main/LICENSE.md)
|
|
7
|
+
|
|
8
|
+
> **HAND** (Hold And Notation Designator) implementation for the Ruby language.
|
|
9
|
+
|
|
10
|
+
## What is HAND?
|
|
11
|
+
|
|
12
|
+
HAND (Hold And Notation Designator) is a standardized notation for representing piece reserve locations in board games where pieces can be held off-board and potentially placed. This applies to games like Shōgi, Crazyhouse, Go, and other games featuring reserve mechanics.
|
|
13
|
+
|
|
14
|
+
This gem implements the [HAND Specification v1.0.0](https://sashite.dev/specs/hand/1.0.0/), providing a minimalist Ruby interface using a single character: `*` (asterisk).
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
# In your Gemfile
|
|
20
|
+
gem "sashite-hand"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or install manually:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
gem install sashite-hand
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require "sashite/hand"
|
|
33
|
+
|
|
34
|
+
# Check if a location represents the reserve
|
|
35
|
+
Sashite::Hand.reserve?("*") # => true
|
|
36
|
+
Sashite::Hand.reserve?("a1") # => false
|
|
37
|
+
Sashite::Hand.reserve?("**") # => false
|
|
38
|
+
|
|
39
|
+
# Get the canonical representation
|
|
40
|
+
Sashite::Hand.to_s # => "*"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Movement Notation Examples
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
# From reserve to board
|
|
47
|
+
source = "*"
|
|
48
|
+
destination = "e4"
|
|
49
|
+
puts "#{source} → #{destination}" # => "* → e4"
|
|
50
|
+
|
|
51
|
+
# Shōgi piece drop
|
|
52
|
+
puts "Dropping piece from reserve to 5e" if Sashite::Hand.reserve?("*")
|
|
53
|
+
|
|
54
|
+
# Go stone placement
|
|
55
|
+
supply = "*"
|
|
56
|
+
puts "Placing stone from supply to dd" if Sashite::Hand.reserve?(supply)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Integration with CELL
|
|
60
|
+
|
|
61
|
+
HAND complements the [CELL specification](https://sashite.dev/specs/cell/) for complete location coverage:
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
def valid_location?(location)
|
|
65
|
+
Sashite::Cell.valid?(location) || Sashite::Hand.reserve?(location)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
valid_location?("*") # => true (reserve)
|
|
69
|
+
valid_location?("a1") # => true (board position)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API Reference
|
|
73
|
+
|
|
74
|
+
### Methods
|
|
75
|
+
|
|
76
|
+
- `Sashite::Hand.reserve?(location)` - Check if location represents the reserve
|
|
77
|
+
- `Sashite::Hand.to_s` - Get the canonical HAND representation (`"*"`)
|
|
78
|
+
|
|
79
|
+
### Constants
|
|
80
|
+
|
|
81
|
+
- `Sashite::Hand::RESERVE` - The reserve location character (`"*"`)
|
|
82
|
+
|
|
83
|
+
## Properties
|
|
84
|
+
|
|
85
|
+
* **Minimalist**: Single character (`*`) for all reserve operations
|
|
86
|
+
* **Universal**: Works across different board game systems
|
|
87
|
+
* **Rule-agnostic**: Independent of specific reserve mechanics
|
|
88
|
+
* **Complementary**: Designed to work with CELL coordinates
|
|
89
|
+
|
|
90
|
+
## Protocol Mapping
|
|
91
|
+
|
|
92
|
+
Following the [Game Protocol](https://sashite.dev/game-protocol/):
|
|
93
|
+
|
|
94
|
+
| Protocol Attribute | HAND Encoding | Meaning |
|
|
95
|
+
|-------------------|---------------|---------|
|
|
96
|
+
| **Location** | `*` | Any off-board reserve area |
|
|
97
|
+
|
|
98
|
+
## Related Specifications
|
|
99
|
+
|
|
100
|
+
- [CELL](https://sashite.dev/specs/cell/) - Board position coordinates
|
|
101
|
+
- [GGN](https://sashite.dev/specs/ggn/) - Movement possibility rules
|
|
102
|
+
- [PMN](https://sashite.dev/specs/pmn/) - Portable Move Notation
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
- [Official HAND Specification v1.0.0](https://sashite.dev/specs/hand/1.0.0/)
|
|
107
|
+
- [Game Protocol Foundation](https://sashite.dev/game-protocol/)
|
|
108
|
+
- [API Documentation](https://rubydoc.info/github/sashite/hand.rb/main)
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Available as open source under the [MIT License](https://opensource.org/licenses/MIT).
|
|
113
|
+
|
|
114
|
+
## About
|
|
115
|
+
|
|
116
|
+
Maintained by [Sashité](https://sashite.com/) — promoting chess variants and sharing the beauty of board game cultures.
|
data/lib/sashite/hand.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sashite
|
|
4
|
+
# HAND (Hold And Notation Designator) implementation
|
|
5
|
+
#
|
|
6
|
+
# HAND defines a simple, standardized notation for piece reserve locations
|
|
7
|
+
# in board games where pieces can be held off-board and potentially placed.
|
|
8
|
+
#
|
|
9
|
+
# @see https://sashite.dev/specs/hand/1.0.0/
|
|
10
|
+
# @author Sashité
|
|
11
|
+
#
|
|
12
|
+
# @example Basic usage
|
|
13
|
+
# Sashite::Hand.reserve?("*") # => true
|
|
14
|
+
# Sashite::Hand.reserve?("a1") # => false
|
|
15
|
+
# Sashite::Hand.to_s # => "*"
|
|
16
|
+
module Hand
|
|
17
|
+
# The reserve location character
|
|
18
|
+
RESERVE = "*"
|
|
19
|
+
|
|
20
|
+
# Check if a string represents the reserve location
|
|
21
|
+
#
|
|
22
|
+
# @param string [String] the string to check
|
|
23
|
+
# @return [Boolean] true if the string is the reserve location
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# Sashite::Hand.reserve?("*") # => true
|
|
27
|
+
# Sashite::Hand.reserve?("a1") # => false
|
|
28
|
+
# Sashite::Hand.reserve?("**") # => false
|
|
29
|
+
# Sashite::Hand.reserve?("") # => false
|
|
30
|
+
def self.reserve?(string)
|
|
31
|
+
RESERVE.eql?(string)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Get the canonical HAND representation
|
|
35
|
+
#
|
|
36
|
+
# @return [String] the reserve location character
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# Sashite::Hand.to_s # => "*"
|
|
40
|
+
def self.to_s
|
|
41
|
+
RESERVE
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/sashite-hand.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sashite-hand
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Cyril Kato
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Hold And Notation Designator (HAND) provides a standardized notation
|
|
13
|
+
for piece reserve locations in board games where pieces can be held off-board and
|
|
14
|
+
potentially placed. Implements HAND Specification v1.0.0.
|
|
15
|
+
email: contact@cyril.email
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- LICENSE.md
|
|
21
|
+
- README.md
|
|
22
|
+
- lib/sashite-hand.rb
|
|
23
|
+
- lib/sashite/hand.rb
|
|
24
|
+
homepage: https://github.com/sashite/hand.rb
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
bug_tracker_uri: https://github.com/sashite/hand.rb/issues
|
|
29
|
+
documentation_uri: https://rubydoc.info/github/sashite/hand.rb/main
|
|
30
|
+
homepage_uri: https://github.com/sashite/hand.rb
|
|
31
|
+
source_code_uri: https://github.com/sashite/hand.rb
|
|
32
|
+
specification_uri: https://sashite.dev/specs/hand/1.0.0/
|
|
33
|
+
rubygems_mfa_required: 'true'
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: 3.2.0
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.6.9
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: HAND (Hold And Notation Designator) implementation for Ruby
|
|
51
|
+
test_files: []
|