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

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

主站蜘蛛池模板: 乌拉特后旗| 霍林郭勒市| 灵石县| 中西区| 清河县| 富川| 嵩明县| 漯河市| 九台市| 大宁县| 香格里拉县| 洛扎县| 淳化县| 临桂县| 竹溪县| 白城市| 曲水县| 枞阳县| 大兴区| 固阳县| 绥阳县| 松原市| 公安县| 嘉义县| 朝阳县| 东至县| 岳阳县| 和田县| 孙吴县| 万源市| 湾仔区| 乌兰察布市| 江永县| 皋兰县| 建平县| 桃园县| 鄂尔多斯市| 正蓝旗| 定陶县| 耒阳市| 柳江县|