-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex3.js
94 lines (72 loc) · 1.86 KB
/
index3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var readlineSync = require('readline-sync');
var getStrategy = require('./strategy');
var Hand = require('./hand');
var decision;
var strategy;
cardShow = () => {
console.log('User:')
console.log(user.show());
user.describe();
console.log('Dealer:')
console.log(dealer.show());
dealer.describe();
}
decisionAsk = () => {
if (user.handresult.pair) {
var answer = readlineSync.question( '(H)it, (S)tand, (D)ouble or S(P)lit?');
}
else {
var answer = readlineSync.question( '(H)it, (S)tand, (D)ouble?');
}
return answer;
}
turnPlay = () => {
cardShow();
decision = decisionAsk();
strategy = getStrategy(dealer.handresult.sum, user.handresult.sum, user.handresult.pair, user.handresult.soft);
console.log('Strategy: ' + strategy)
if (strategy == decision) {
console.log('Good choice!');
return decision;
}
}
user = new Hand(2);
dealer = new Hand(1);
switch (turnPlay()) {
case 'H':
user.dealNext();
break;
case 'D':
user.dealNext();
break;
case 'S':
;
break;
}
dealer.dealNext();
// game
// setting up user with money
// holding plays record: stacks (cards[], decisions[], good_strategies[]), winnings[],
// setting up play
// keeping score: plays, wins, strategies, money
//play.start(fresh)
// create one stack. stack has money. get them from user
// stacks[1]
//stack.split
// remove stack, add two new stacks
// get more money into second stack
// you have two stacks (users) now
//stack.hit
// draw card, allow for decision again
//stack.double
// get more money
// do not allow to draw card more. wrap up stack
//stack.stand
// wrapUp stack
// play: stacks[], dealer
//play.wrapUp
wrapUp = () => {
// finishing dealer
// comparing outcome for every stack
// adding/removing money
}