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

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.

主站蜘蛛池模板: 平凉市| 吉安市| 图木舒克市| 城口县| 宜阳县| 古交市| 徐州市| 磴口县| 米易县| 静海县| 益阳市| 板桥市| 兴山县| 军事| 饶平县| 沂南县| 成武县| 加查县| 萝北县| 上高县| 祁阳县| 大新县| 永寿县| 凤翔县| 姚安县| 静安区| 镇平县| 加查县| 任丘市| 榆树市| 靖江市| 威远县| 邵阳市| 马鞍山市| 天峨县| 邵阳市| 长岛县| 平阳县| 望都县| 余庆县| 磐石市|