官术网_书友最值得收藏!

Drawing cards

Before drawing the cards, we will need to add two properties to the app state in the state.js file:

var state = {
// ...
drawPile: pile,
discardPile: {},
}

The drawPile property is the pile of cards that can be drawn by the players. It is initialized with the pile object defined in the cards.js file. Each key is the ID of a card definition, and the value is the amount of cards of this type in the pile.

The discardPile property is the equivalent of the drawPile property, but it serves a different purpose--all the cards played by the player will be removed from their hand and put into the discard pile. At some point, if the draw pile is empty, it will be refilled with the discard pile (which will be emptied).

主站蜘蛛池模板: 南京市| 那曲县| 福清市| 广州市| 张家港市| 丰台区| 贵南县| 茌平县| 曲阳县| 武胜县| 富锦市| 新龙县| 兴安县| 阿巴嘎旗| 泾阳县| 林西县| 岐山县| 定南县| 永定县| 普格县| 京山县| 简阳市| 东安县| 宁阳县| 苏州市| 巩义市| 梧州市| 商洛市| 和硕县| 大同市| 集贤县| 扶余县| 东丰县| 剑川县| 尼玛县| 武穴市| 宝应县| 大宁县| 临西县| 白水县| 黔江区|