Boy2Man 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad1515c7fbf182d910e436e725d895e6db0c3d1d
4
- data.tar.gz: 560da65ae2ccd74bd5494ada9fc2e843bd82c89f
3
+ metadata.gz: 651da5542ce090d2e04c3155ebf6234c46783a03
4
+ data.tar.gz: 94de98d13d2ab16b04bb788fbe004e77d09567d6
5
5
  SHA512:
6
- metadata.gz: 64345a1514b2dd1315482e84c16c8d7790a37b9b68c0730bad848c187c4f95f948849a4536db7e9a0e02e55d2b02ac95ca2da41eac50cb03cdabf6108fe3ef38
7
- data.tar.gz: a2a0b03535cf2a5bcdac4cb6d73f19a6a43e7daec560669762e01f39c9f0c5d5c4c4f3bf1c8900b1898a3d4657682a0608ea52faf3d5250224e2e3201cdb8111
6
+ metadata.gz: b6ae8ec94576ec9bfaee57900aadef62a67e664ca56d30bc86408fe7934749b38c6ffa05de8c34e4227091c83bf25dd5d0b66864b1aeb256211faacf31681b33
7
+ data.tar.gz: d9c0ac812a9933a375bef24ccc6921cf10afe1f97f70a3f239f59892902e1e090c069e31c736344bfad884cd7af847b57401b5619ebf5800cdff43f8b730bf7d
data/README.md CHANGED
@@ -25,6 +25,17 @@ Or install it yourself as:
25
25
  and then game will start.
26
26
 
27
27
  ### As a Library
28
+ ```ruby
29
+ require 'Boy2Man'
30
+
31
+ janken = Boy2Man::Janken.new
32
+ janken.pon # => "グー or チョキ or パー"
33
+
34
+ # you can use Japanese also
35
+ じゃんけん = Boy2Man::Janken.new
36
+ じゃんけん.ぽん
37
+ じゃんけん.ほい
38
+ ```
28
39
 
29
40
  see <http://rubydoc.info/gems/Boy2Man>
30
41
 
@@ -71,7 +71,18 @@ module Boy2Man
71
71
 
72
72
  private
73
73
  def predict
74
- @history.empty? ? %w(グー チョキ パー).sample : @history.sample
74
+ if @history.length < 2
75
+ %w(グー チョキ パー).sample
76
+ else
77
+ possible_hands = Array.new
78
+ @history.each_with_index do |hand, i|
79
+ if hand == @history.last
80
+ possible_hands.push @history[i+1]
81
+ end
82
+ end
83
+ possible_hands.compact!
84
+ possible_hands.empty? ? %w(グー チョキ パー).sample : possible_hands.sample
85
+ end
75
86
  end
76
87
 
77
88
  end
@@ -1,3 +1,3 @@
1
1
  module Boy2Man
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Boy2Man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zakuni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler