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

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

主站蜘蛛池模板: 峡江县| 万年县| 和龙市| 马山县| 宁远县| 句容市| 满洲里市| 福安市| 方正县| 治多县| 德保县| 景德镇市| 合阳县| 赣榆县| 城口县| 南阳市| 安图县| 邵阳市| 扎兰屯市| 福鼎市| 蓬溪县| 平利县| 徐汇区| 蚌埠市| 澎湖县| 项城市| 于田县| 丹棱县| 定州市| 运城市| 鹤岗市| 奈曼旗| 宁阳县| 崇阳县| 遂平县| 九龙坡区| 宜州市| 牡丹江市| 方正县| 洛川县| 德兴市|