-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
55 lines (49 loc) · 1.11 KB
/
Copy pathtest.js
File metadata and controls
55 lines (49 loc) · 1.11 KB
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
var Utils = require("./utils.js");
var utils = new Utils();
function isActionCard(card, penalising) {
penalising = (typeof penalising === "undefined") ? false : penalising;
if (card && !penalising) {
var cardNumber = parseInt(card);
if (cardNumber in utils.has(["1", "2", "13"])) {
return true;
} else {
return false;
}
}
if (card && penalising) {
console.log("should never see this");
var cardNumber = parseInt(card);
if (cardNumber === 2) {
return true;
} else {
return false;
}
}
}
function removeDuplicates(arr) {
arr.sort();
var i = arr.length - 1;
while (i > 0) {
if (arr[i] === arr[i - 1]) {
arr.splice(i, 1);
}
i--;
}
}
function isSuiteInHand(suite, hand){
if (suite) {
var suitesInHand = [];
for (var i = 0; i < hand.length; i++) {
console.log(hand[i]);
suitesInHand.push(hand[i][hand[i].length-1]);
}
if (utils.indexOf(suitesInHand, suite) > -1) {
return true;
} else {
return false;
}
}
}
var s = "H";
var h = ["2D","1S","1D","2C"];
console.log(isSuiteInHand(s, h));