|
|
|
|
class Card {
|
|
|
|
|
color;
|
|
|
|
|
symbol;
|
|
|
|
|
points;
|
|
|
|
|
facingDown = false;
|
|
|
|
|
assetUrl;
|
|
|
|
|
backAssetUrl;
|
|
|
|
|
|
|
|
|
|
constructor(color, symbol, points, assetBaseUrl = 'img/') {
|
|
|
|
|
this.color = color;
|
|
|
|
|
this.symbol = symbol;
|
|
|
|
|
this.points = points;
|
|
|
|
|
this.assetUrl = this.createAssetPath(assetBaseUrl);
|
|
|
|
|
this.backAssetUrl = this.createBackAssetPath(assetBaseUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createAssetPath(assetBaseUrl) {
|
|
|
|
|
return assetBaseUrl + this.color + this.symbol + '.png'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createBackAssetPath(assetBaseUrl) {
|
|
|
|
|
return assetBaseUrl + 'back.png'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isAnAce() {
|
|
|
|
|
return this.symbol === 'a';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flip() {
|
|
|
|
|
this.facingDown = !this.facingDown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isFacingDown() {
|
|
|
|
|
return this.facingDown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get assetUrl() {
|
|
|
|
|
if (this.isFacingDown()) {
|
|
|
|
|
return this.backAssetUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.assetUrl;
|
|
|
|
|
}
|
|
|
|
|
}
|