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 +4 -4
- data/README.md +11 -0
- data/lib/Boy2Man/janken.rb +12 -1
- data/lib/Boy2Man/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 651da5542ce090d2e04c3155ebf6234c46783a03
|
4
|
+
data.tar.gz: 94de98d13d2ab16b04bb788fbe004e77d09567d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/Boy2Man/janken.rb
CHANGED
@@ -71,7 +71,18 @@ module Boy2Man
|
|
71
71
|
|
72
72
|
private
|
73
73
|
def predict
|
74
|
-
@history.
|
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
|
data/lib/Boy2Man/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2013-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|