-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (44 loc) · 1.54 KB
/
app.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
let Card = require("./lib/card");
let Deck = require("./lib/deck");
let faces = require("./lib/shared").faces;
let suits = require("./lib/shared").suits;
let config = require("./lib/config");
let roles = config.roles;
var combinationRoles = Object.create(roles);
let deck = new Deck();
function init(){
for (role of roles) {
combinationRoles.shift();
for (cRole of combinationRoles) {
if (role.name != cRole.name) deck.cards.push(new Card(role, cRole));
}
}
let defaultHandSize = config.defaultHandSize;
let hand = deck.cards.length / roles.length;
let cardDifference = (deck.cards.length) * defaultHandSize / hand - deck.cards.length;
console.log("TOTALS ------------------------------");
console.log(`${roles.length} roles`);
console.log(`${deck.cards.length} combinations`);
if (hand < defaultHandSize) console.log(`${hand} cards in hand. You need ${cardDifference} more combinations to bring this to ${defaultHandSize}`);
else console.log(`${hand} cards in hand`);
}
init();
let data = {
cards: deck.getCards(),
numbers: deck.getDataCount()
}
/*
var http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
var app = http.createServer(function(req,res){
res.setHeader('Content-Type', 'application/json');
init();
let data = {
cards: deck.getCards(),
numbers: deck.getDataCount()
}
res.end(JSON.stringify(JSON.stringify(data)));
});
app.listen(port, hostname);
*/