hazama_kuroo 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hazama_kuroo/version.rb +1 -1
- data/lib/hazama_kuroo.rb +37 -54
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cbf6d04d5196b2969f36c1a85c902ec7cb458beeee9127dc7425684ff03bef1
|
4
|
+
data.tar.gz: 4c13a822d68055f0192e051d309b6d0ff7097f783d1a98948055c24a3e0b2e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4750a94114732d51832fbccfc2c33973d6a5f8cb697e637d7017189d5ba032c10da65fe31e2ad6de6df1eaafef35cb9e43b188342b021861b48e86a4076a11e
|
7
|
+
data.tar.gz: 3b0ae5c5d1f2fc9859d53b114dc83b957c829c8a279ebf89921d740c95a3498ba79022b04b519c0ed123f868f4bbbb18401e54ad5411bebecc194e5d80a35a77
|
data/lib/hazama_kuroo/version.rb
CHANGED
data/lib/hazama_kuroo.rb
CHANGED
@@ -4,34 +4,31 @@ require "hazama_kuroo/version"
|
|
4
4
|
module HazamaKuroo
|
5
5
|
# 実行メソッド
|
6
6
|
def self.run
|
7
|
-
|
7
|
+
cs = gen
|
8
8
|
puts 'Game Start'
|
9
|
-
|
10
|
-
puts "HZM: #{
|
11
|
-
|
12
|
-
puts "YOU: #{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
hk = dft cs
|
10
|
+
puts "HZM: #{hk[0][0]} ***"
|
11
|
+
yu = dft cs
|
12
|
+
puts "YOU: #{yu[0][0]} #{yu[1][0]}"
|
13
|
+
ooe yu[0]
|
14
|
+
sio yu[0]
|
15
|
+
ooe yu[1]
|
16
|
+
sio yu[1]
|
17
17
|
|
18
|
-
|
19
|
-
while
|
20
|
-
|
21
|
-
while
|
22
|
-
case
|
18
|
+
f = 1
|
19
|
+
while f do
|
20
|
+
print 'Hit? [y/n] '
|
21
|
+
while s = gets do
|
22
|
+
case s.chomp
|
23
23
|
when 'y'
|
24
|
-
|
25
|
-
puts "YOU: #{
|
26
|
-
|
27
|
-
|
28
|
-
if 21 < (sum
|
29
|
-
puts lose
|
30
|
-
flg = false
|
31
|
-
end
|
24
|
+
yu << (deal cs)
|
25
|
+
puts "YOU: #{yu[-1][0]}"
|
26
|
+
ooe yu[-1]
|
27
|
+
sio yu[-1]
|
28
|
+
(puts 'Lose'; f = false) if 21 < (sum yu)
|
32
29
|
when 'n'
|
33
|
-
|
34
|
-
|
30
|
+
std yu, hk, cs
|
31
|
+
f = false
|
35
32
|
else
|
36
33
|
puts ope
|
37
34
|
exit
|
@@ -42,7 +39,7 @@ module HazamaKuroo
|
|
42
39
|
end
|
43
40
|
|
44
41
|
# カードを 52 枚用意する
|
45
|
-
def self.
|
42
|
+
def self.gen
|
46
43
|
ms = %w[S C H D]
|
47
44
|
c = []
|
48
45
|
ms.each do |m|
|
@@ -67,29 +64,27 @@ module HazamaKuroo
|
|
67
64
|
end
|
68
65
|
|
69
66
|
# 初期デッキを作る
|
70
|
-
def self.
|
67
|
+
def self.dft cs
|
71
68
|
[] << (deal cs) << (deal cs)
|
72
69
|
end
|
73
70
|
|
74
71
|
# カードを配る
|
75
72
|
def self.deal cs
|
76
|
-
while 1
|
73
|
+
while 1 do
|
77
74
|
m = rand(4)
|
78
75
|
n = rand(11)
|
79
|
-
|
80
|
-
cs[m][n][2] = 1
|
81
|
-
break
|
82
|
-
end
|
76
|
+
(cs[m][n][2] = 1; break) if 0 == cs[m][n][2]
|
83
77
|
end
|
84
78
|
cs[m][n]
|
85
79
|
end
|
86
80
|
|
87
81
|
# Ace をどうするか
|
88
|
-
def self.
|
82
|
+
def self.ooe a
|
89
83
|
if 'A' == a[1] && 0 == a[3]
|
90
|
-
|
91
|
-
|
92
|
-
|
84
|
+
|
85
|
+
print "#{a[0]}? [1/11] "
|
86
|
+
s = gets
|
87
|
+
case s.chomp
|
93
88
|
when '1'
|
94
89
|
a[1] = 1
|
95
90
|
when '11'
|
@@ -102,7 +97,7 @@ module HazamaKuroo
|
|
102
97
|
end
|
103
98
|
|
104
99
|
# 不正操作だったら強制終了
|
105
|
-
def self.
|
100
|
+
def self.sio c
|
106
101
|
if c[1].nil?
|
107
102
|
puts ope
|
108
103
|
exit
|
@@ -110,10 +105,10 @@ module HazamaKuroo
|
|
110
105
|
end
|
111
106
|
|
112
107
|
# 勝負する
|
113
|
-
def self.
|
108
|
+
def self.std y, d, cs
|
114
109
|
a = sum y
|
115
110
|
puts "Hole Card: #{d[1][0]}"
|
116
|
-
b =
|
111
|
+
b = dbd d, cs, a
|
117
112
|
if 21 < b || b < a
|
118
113
|
puts 'Win!'
|
119
114
|
elsif a < b
|
@@ -133,26 +128,14 @@ module HazamaKuroo
|
|
133
128
|
end
|
134
129
|
|
135
130
|
# stand 後のディーラーの作業
|
136
|
-
def self.
|
131
|
+
def self.dbd d, cs, a
|
137
132
|
d[0][1] = 11 if 'A' == d[0][1]
|
138
|
-
|
139
|
-
if 11 == d[0][1]
|
140
|
-
s = d[0][1] + 1
|
141
|
-
else
|
142
|
-
s = d[0][1] + 11
|
143
|
-
end
|
144
|
-
else
|
145
|
-
s = d[0][1] + d[1][1]
|
146
|
-
end
|
133
|
+
s = d[0][1] + ('A' == d[1][1] ? (11 == d[0][1] ? 1 : 11) : d[1][1])
|
147
134
|
|
148
|
-
while s < 17
|
135
|
+
while s < 17 || s <= a do
|
149
136
|
t = deal cs
|
150
137
|
puts "HZM: #{t[0]}"
|
151
|
-
|
152
|
-
s += 1
|
153
|
-
else
|
154
|
-
s += t[1]
|
155
|
-
end
|
138
|
+
s += ('A' == t[1] ? (s < 10 ? 11 : 1) : t[1])
|
156
139
|
end
|
157
140
|
s
|
158
141
|
end
|