-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
39 lines (34 loc) · 914 Bytes
/
lib.js
File metadata and controls
39 lines (34 loc) · 914 Bytes
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
var request = require("request");
var _ = require("lodash");
var poker = require("./poker.js");
module.exports = {
getDeckID: getDeckID,
}
function getDeckID() {
var options = { method: 'GET',
url: 'https://deckofcardsapi.com/api/deck/new/shuffle/',
qs: { deck_count: '1' },
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
drawCard(body.deck_id);
});
}
function drawCard(id) {
var cards = [];
var options = { method: 'GET',
url: 'https://deckofcardsapi.com/api/deck/'+id+'/draw',
qs: { count: '5' },
json: true,
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
_.forEach(body.cards, (k) => {
cards.push(k.code);
})
cards = _.join(cards, " ");
console.log(cards);
console.log("Player Rank => ", poker.getHandStrength(cards));
});
}