pgn 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/pgn/game.rb +8 -4
- data/lib/pgn/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 665f027ae63b2c171832fe0534254100735b0d18
|
4
|
+
data.tar.gz: 74818c2328408f318a9fb44572634aa22922fe71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6aa38b81c6ea3e3ae3b7d7ba4f687c2a269c09880fe711ab874f9d3937958789ff78479edab10a2a7d3bfbfe6b272b1e254d5f9fbbad1387ffec50022c5880
|
7
|
+
data.tar.gz: 02b9897e144b842fd7fe30aaee2d41c9c58393b207602bfb54c4f34f2d2fdbb6342e81bacdc50c975a590d3200858313efeeda8aaaf3458d6b2b46dc3068037b
|
data/README.md
CHANGED
@@ -15,8 +15,8 @@ in [portable game notation](http://en.wikipedia.org/wiki/Portable_Game_Notation)
|
|
15
15
|
> game.play
|
16
16
|
```
|
17
17
|
|
18
|
-
Play through the game using `a` to move backward and `d`
|
19
|
-
forward. `^C` quits play mode.
|
18
|
+
Play through the game using `a` or left arrow to move backward, and `d`
|
19
|
+
or right arrow to move forward. `q` or `^C` quits play mode.
|
20
20
|
|
21
21
|
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
|
22
22
|
♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
|
data/lib/pgn/game.rb
CHANGED
@@ -26,9 +26,9 @@ module PGN
|
|
26
26
|
class Game
|
27
27
|
attr_accessor :tags, :moves, :result
|
28
28
|
|
29
|
-
LEFT =
|
30
|
-
RIGHT =
|
31
|
-
EXIT =
|
29
|
+
LEFT = %r{(a|\x1B\[D)\z}
|
30
|
+
RIGHT = %r{(d|\x1B\[C)\z}
|
31
|
+
EXIT = %r{(q|\x03)\z}
|
32
32
|
|
33
33
|
# @param moves [Array<String>] a list of moves in SAN
|
34
34
|
# @param tags [Hash<String, String>] metadata about the game
|
@@ -67,10 +67,14 @@ module PGN
|
|
67
67
|
#
|
68
68
|
def play
|
69
69
|
index = 0
|
70
|
+
hist = Array.new(3, "")
|
71
|
+
|
70
72
|
loop do
|
71
73
|
puts "\e[H\e[2J"
|
72
74
|
puts self.positions[index].inspect
|
73
|
-
|
75
|
+
hist[0..2] = (hist[1..2] << STDIN.getch)
|
76
|
+
|
77
|
+
case hist.join
|
74
78
|
when LEFT
|
75
79
|
index -= 1 if index > 0
|
76
80
|
when RIGHT
|
data/lib/pgn/version.rb
CHANGED