forked from bcgame-project/verify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard.js
More file actions
28 lines (22 loc) · 641 Bytes
/
card.js
File metadata and controls
28 lines (22 loc) · 641 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
class Card {
static POINTS = ' ,A,2,3,4,5,6,7,8,9,10,J,Q,K'.split(',');
static SUITS = ['♠', '♥', '♣', '♦'];
cardId;
suit;
suitStr;
point;
pointStr;
constructor(cardId) {
this.cardId = cardId;
this.suit = (cardId & 240) / 16 - 10;
this.suitStr = Card.SUITS[this.suit];
this.point = cardId % 16;
this.pointStr = Card.POINTS[this.point];
}
static encodeByString(suit, point) {
return this.encode(Card.SUITS.indexOf(suit), Card.POINTS.indexOf(point));
}
static encode(suit, point) {
return ((suit + 10) << 4) + point;
}
}