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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b261ae59ff2c1ee5680c4696e6012c4811639aa8
4
- data.tar.gz: 8b59c74fbd3caad1a099b46962ae176ca8fde206
3
+ metadata.gz: 665f027ae63b2c171832fe0534254100735b0d18
4
+ data.tar.gz: 74818c2328408f318a9fb44572634aa22922fe71
5
5
  SHA512:
6
- metadata.gz: 89f69e5d76a923a8a335a9421ded37c0e4c9279849ffc30d2d70fb105f695ab8351b7e42c70c3e9f82cc2921d37403f0ec8ba57dee83c79087719badbd3c1f9c
7
- data.tar.gz: f4a3055bff38e22b708c88259e37f297a4900091f3f48fddb7a83cdb070ac68f614af751ff58b2bece4e3475db8dca406c4e80a1c1498837de12e3c7903f1b5f
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` to move
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 = "a"
30
- RIGHT = "d"
31
- EXIT = "\u{0003}"
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
- case STDIN.getch
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
@@ -1,3 +1,3 @@
1
1
  module PGN
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stacey Touset