-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbetTester.html
executable file
·155 lines (147 loc) · 4.54 KB
/
betTester.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<script>
var hand_score = {
"Royal Flush" : 10,
"Straight Flush" : 9,
"4 of a Kind" : 8,
"Full House" : 7,
"Flush" : 6,
"3 of a Kind" : 5,
"Staight" : 4,
"2 Pairs" : 3,
"Pair" : 2,
"High Card" : 1
};
var card_score = {
"Ace" : 14,
"King" : 13,
"Queen" : 12,
"Jack" : 11,
"10" : 10,
"9" : 9,
"8" : 8,
"7" : 7,
"6" : 6,
"5" : 5,
"4" : 4,
"3" : 3,
"2" : 2
};
var suit_score = {
"Spades" : 4,
"Diamonds" : 3,
"Clubs" : 2,
"Hearts" : 1
};
/*var current_bet = {
"Hand" : "High Card",
"Card1" : "2",
"Card2" : "3",
"Suit" : "Hearts"
};
var last_bet = {
"Hand" : "High Card",
"Card1" : "2",
"Card2" : "3",
"NumberOfCards": "1",
"Suit" : "Hearts"
};*/
function compare(current_bet,last_bet)
{
if(hand_score[current_bet.Hand] > hand_score[last_bet.Hand])
return true;
else if (hand_score[current_bet.Hand] == hand_score[last_bet.Hand])
{
if (current_bet.Hand=="Full House" || current_bet.Hand =="2 of a Kind")
{
if(card_score[current_bet.Card1] > card_score[last_bet.Card1])
return true;
else if(current_bet.Card1 == current_bet.Card1)
{
if(card_score[current_bet.Card2] > card_score[last_bet.Card2])
return true;
else
return false;
}
else
return false;
}
else if (current_bet.Hand=="Flush" || current_bet.Hand=="Straight Flush" || current_bet.Hand=="Royal Flush")
{
if(current_bet.NumberOfCards > last_bet.NumberOfCards)
return true;
else if(current_bet.NumberOfCards==last_bet.NumberOfCards)
{
if(suit_score[current_bet.Suit] > suit_score[last_bet.Suit])
return true;
else if (current_bet.Suit == last_bet.Suit)
{
if(card_score[current_bet.Card1] > card_score[last_bet.Card1])
return true;
else
return false;
}
else
return false;
}
else
return false;
}
else if(current_bet.Hand=="4 of a Kind" || current_bet.Hand=="Pair" || current_bet.Hand=="3 of a Kind")
{
if(card_score[current_bet.Card1] > card_score[last_bet.Card1])
return true;
else
return false;
}
else
{
if(card_score[current_bet.Card1] > card_score[last_bet.Card1])
return true;
else
return false;
}
}
else
return false;
}
function call()
{
//document.write("Hello");
lb = new Object();
lb.Hand = document.getElementById("hand").value;
lb.Card1 = document.getElementById("card1").value;
lb.Card2 = document.getElementById("card2").value;
lb.Suit = document.getElementById("suit").value;
lb.NumberOfCards = document.getElementById("number").value;
cb = new Object();
cb.Hand = document.getElementById("cu_hand").value;
cb.Card1 = document.getElementById("cu_card1").value;
cb.Card2 = document.getElementById("cu_card2").value;
cb.Suit = document.getElementById("cu_suit").value;
cb.NumberOfCards = document.getElementById("cu_number").value;
if(compare(cb,lb))
document.write("Current Bet is Accepted");
else
document.write("Current Bet is not acceptable");
}
</script>
</head>
<body>
<h1> Last Bet </h1>
Hand = <input id="hand" type="text">
Card1 = <input id="card1" type="text">
Card2 = <input id="card2" type="text">
Suit = <input id="suit" type="text">
Number = <input id="number" type="text">
<h1> Current Bet </h1>
Hand = <input id="cu_hand" type="text">
Card1 = <input id="cu_card1" type="text">
Card2 = <input id="cu_card2" type="text">
Suit = <input id="cu_suit" type="text">
Number = <input id="cu_number" type="text">
<br> <br>
<button onclick="call()"> Compare </button>
</body>
</html>