Skip to content

Instantly share code, notes, and snippets.

@dkblay
Last active August 6, 2019 15:47
Show Gist options
  • Save dkblay/fabb1cf902a6dafe2184e0adba604c5d to your computer and use it in GitHub Desktop.
Save dkblay/fabb1cf902a6dafe2184e0adba604c5d to your computer and use it in GitHub Desktop.
game
import { colorCode } from "./constants";
class Game {
constructor({
id,
name,
slug,
mana_cost,
rarity_id,
color_id,
type_id,
health,
attack
}) {
this.id = id;
this.name = name;
this.health = health;
this.manaCost = mana_cost;
this.rarityId = rarity_id;
this.colorId = color_id;
this.type = type_id;
this.slug = slug;
this.attack = attack;
this.color = this.setColor(this.colorId);
}
setColor(colorId) {
let color = null;
switch (colorId) {
case 1:
color = colorCode.bigStone;
break;
case 2:
color = colorCode.siverTree;
break;
case 3:
color = colorCode.redDaMask;
break;
default:
color = colorCode.ronChi;
}
return color;
}
}
export default Game;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment