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

The 'last play' overlay

This one is a bit more complex. We need a new function to get the last played card by a player. In the utils.js file, add the new getLastPlayedCard function:

function getLastPlayedCard (player) {
return cards[player.lastPlayedCardId]
}

We can now use this function in a lastPlayedCard computed property by passing the opponent prop:

Vue.component('overlay-content-last-play', {
template: `<p>
<p v-if="opponent.skippedTurn">{{ opponent.name }} turn was skipped!</p>
<template v-else>
<p>{{ opponent.name }} just played:</p>
<card :def="lastPlayedCard" />
</template>
</p>`,
props: ['opponent'],
computed: {
lastPlayedCard () {
return getLastPlayedCard(this.opponent)
},
},
})

Note that we are directly reusing the card component we made earlier to display the card.

主站蜘蛛池模板: 和林格尔县| 城市| 庄浪县| 阿图什市| 阿拉善右旗| 清水河县| 延边| 神农架林区| 栖霞市| 含山县| 营口市| 镇雄县| 方城县| 辽阳县| 达孜县| 花莲县| 高密市| 武定县| 沛县| 延长县| 肇东市| 卫辉市| 马龙县| 曲阳县| 哈尔滨市| 天峨县| 萨迦县| 道真| 盐山县| 全椒县| 阿克| 昌黎县| 紫云| 尼勒克县| 南充市| 梁河县| 五华县| 阆中市| 汨罗市| 林芝县| 神农架林区|