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

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).

主站蜘蛛池模板: 阳山县| 黄浦区| 玉屏| 克东县| 甘德县| 宜章县| 涞源县| 登封市| 正宁县| 明水县| 会东县| 楚雄市| 辽阳县| 石首市| 宜兰县| 丰原市| 长兴县| 双牌县| 大荔县| 新疆| 巫山县| 富阳市| 义马市| 武平县| 鹤岗市| 顺平县| 开封县| 瑞金市| 泰顺县| 班玛县| 古蔺县| 黄梅县| 会昌县| 沁源县| 曲靖市| 余姚市| 甘谷县| 常山县| 新疆| 科技| 酉阳|