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

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.

主站蜘蛛池模板: 甘泉县| 德令哈市| 贵溪市| 兴仁县| 泰顺县| 陵川县| 都江堰市| 中山市| 贵州省| 绥化市| 卓尼县| 崇义县| 乌鲁木齐市| 西乡县| 沂源县| 盐津县| 民勤县| 南宫市| 福州市| 天长市| 梅州市| 于田县| 冀州市| 共和县| 城步| 平泉县| 读书| 休宁县| 淳安县| 石台县| 奉新县| 文水县| 和林格尔县| 安溪县| 绩溪县| 体育| 湟中县| 蓝山县| 社旗县| 安平县| 商南县|