proper card scrapping
This commit is contained in:
parent
a8e728c966
commit
4ba53b2589
@ -106,5 +106,10 @@ def choose(sid, card_index):
|
|||||||
ses = sio.get_session(sid)
|
ses = sio.get_session(sid)
|
||||||
ses.choose(card_index)
|
ses.choose(card_index)
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
def scrap(sid, card_index):
|
||||||
|
ses = sio.get_session(sid)
|
||||||
|
ses.scrap(card_index)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
eventlet.wsgi.server(eventlet.listen(('', 5001)), app)
|
eventlet.wsgi.server(eventlet.listen(('', 5001)), app)
|
||||||
|
@ -234,7 +234,7 @@ class Player:
|
|||||||
else:
|
else:
|
||||||
self.equipment.append(card)
|
self.equipment.append(card)
|
||||||
else:
|
else:
|
||||||
did_play_card = len(self.hand) + 1 > self.lives
|
did_play_card = False
|
||||||
if isinstance(card, cards.Bang) and self.has_played_bang and not any([isinstance(c, cards.Volcanic) for c in self.equipment]) and againts != None:
|
if isinstance(card, cards.Bang) and self.has_played_bang and not any([isinstance(c, cards.Volcanic) for c in self.equipment]) and againts != None:
|
||||||
self.hand.insert(hand_index, card)
|
self.hand.insert(hand_index, card)
|
||||||
return
|
return
|
||||||
@ -461,6 +461,11 @@ class Player:
|
|||||||
covers += card.vis_mod
|
covers += card.vis_mod
|
||||||
return self.character.visibility_mod + covers
|
return self.character.visibility_mod + covers
|
||||||
|
|
||||||
|
def scrap(self, card_index):
|
||||||
|
if self.is_my_turn or isinstance(self.character, characters.SidKetchum):
|
||||||
|
self.game.deck.scrap(self.hand.pop(card_index))
|
||||||
|
self.notify_self()
|
||||||
|
|
||||||
def end_turn(self, forced=False):
|
def end_turn(self, forced=False):
|
||||||
if not self.is_my_turn: return
|
if not self.is_my_turn: return
|
||||||
if len(self.hand) > self.max_lives and not forced:
|
if len(self.hand) > self.max_lives and not forced:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="deck">
|
<div class="deck">
|
||||||
|
<card v-if="endTurnAction" v-show="pending_action == 2" :card="endTurnCard" class="end-turn" @click.native="endTurnAction"/>
|
||||||
<div style="position:relative">
|
<div style="position:relative">
|
||||||
<div class="card back" style="position:absolute; bottom:-3pt;right:-3pt;"/>
|
<div class="card back" style="position:absolute; bottom:-3pt;right:-3pt;"/>
|
||||||
<div class="card back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
|
<div class="card back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
|
||||||
@ -18,6 +19,9 @@ import Card from '@/components/Card.vue'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Deck',
|
name: 'Deck',
|
||||||
|
props: {
|
||||||
|
endTurnAction: Function
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
Card,
|
Card,
|
||||||
},
|
},
|
||||||
@ -26,6 +30,10 @@ export default {
|
|||||||
name: 'PewPew!',
|
name: 'PewPew!',
|
||||||
icon: '💥',
|
icon: '💥',
|
||||||
},
|
},
|
||||||
|
endTurnCard: {
|
||||||
|
name: 'Termina turno!',
|
||||||
|
icon: '⛔️'
|
||||||
|
},
|
||||||
lastScrap: null,
|
lastScrap: null,
|
||||||
previousScrap: null,
|
previousScrap: null,
|
||||||
pending_action: false,
|
pending_action: false,
|
||||||
@ -88,4 +96,10 @@ export default {
|
|||||||
transform: translate(0,10px);
|
transform: translate(0,10px);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
.end-turn {
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 3pt rgb(138, 12, 12),
|
||||||
|
0 0 0 6pt white,
|
||||||
|
0 0 5pt 6pt #aaa !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -22,8 +22,8 @@
|
|||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
</div>
|
</div>
|
||||||
<div v-if="started">
|
<div v-if="started">
|
||||||
<deck/>
|
<deck :endTurnAction="()=>{wantsToEndTurn = true}"/>
|
||||||
<player :chooseCardFromPlayer="choose"/>
|
<player :isEndingTurn="wantsToEndTurn" :cancelEndingTurn="()=>{wantsToEndTurn = false}" :chooseCardFromPlayer="choose"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<chat/>
|
<chat/>
|
||||||
@ -65,6 +65,7 @@ export default {
|
|||||||
self: {},
|
self: {},
|
||||||
hasToChoose: false,
|
hasToChoose: false,
|
||||||
chooseCards: [],
|
chooseCards: [],
|
||||||
|
wantsToEndTurn: false,
|
||||||
}),
|
}),
|
||||||
sockets: {
|
sockets: {
|
||||||
room(data) {
|
room(data) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<p v-if="instruction" class="center-stuff">{{instruction}}</p>
|
<p v-if="instruction" class="center-stuff">{{instruction}}</p>
|
||||||
<button v-if="canEndTurn" @click="end_turn">Termina Turno</button>
|
<!-- <button v-if="canEndTurn" @click="end_turn">Termina Turno</button> -->
|
||||||
<div class="equipment-slot">
|
<div class="equipment-slot">
|
||||||
<Card v-if="my_role" :card="my_role" class="back"
|
<Card v-if="my_role" :card="my_role" class="back"
|
||||||
@pointerenter.native="desc=my_role.goal" @pointerleave.native="desc=''"/>
|
@pointerenter.native="desc=my_role.goal" @pointerleave.native="desc=''"/>
|
||||||
@ -34,6 +34,7 @@
|
|||||||
<Chooser v-if="notifycard" :text="`${notifycard.player} ha pescato come seconda carta:`" :cards="[notifycard.card]" hintText="Se la carta è cuori o quadri ne pesca un'altra" class="turn-notify-4s"/>
|
<Chooser v-if="notifycard" :text="`${notifycard.player} ha pescato come seconda carta:`" :cards="[notifycard.card]" hintText="Se la carta è cuori o quadri ne pesca un'altra" class="turn-notify-4s"/>
|
||||||
<Chooser v-if="!show_role && is_my_turn" text="GIOCA IL TUO TURNO" :key="is_my_turn" class="turn-notify" />
|
<Chooser v-if="!show_role && is_my_turn" text="GIOCA IL TUO TURNO" :key="is_my_turn" class="turn-notify" />
|
||||||
<Chooser v-if="hasToPickResponse" :text="`ESTRAI UNA CARTA ${attacker?('PER DIFENDERTI DA '+attacker):''}`" :key="hasToPickResponse" class="turn-notify" />
|
<Chooser v-if="hasToPickResponse" :text="`ESTRAI UNA CARTA ${attacker?('PER DIFENDERTI DA '+attacker):''}`" :key="hasToPickResponse" class="turn-notify" />
|
||||||
|
<Chooser v-if="showScrapScreen" :text="`SCARTA ${hand.length}/${lives}`" :cards="hand" :select="scrap" :key="hasToPickResponse" :cancel="cancelEndingTurn"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -44,7 +45,9 @@ import Chooser from '@/components/Chooser.vue'
|
|||||||
export default {
|
export default {
|
||||||
name: 'Player',
|
name: 'Player',
|
||||||
props: {
|
props: {
|
||||||
chooseCardFromPlayer: Function
|
chooseCardFromPlayer: Function,
|
||||||
|
isEndingTurn: Boolean,
|
||||||
|
cancelEndingTurn: Function,
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Card,
|
Card,
|
||||||
@ -113,6 +116,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
|
showScrapScreen() {
|
||||||
|
return this.isEndingTurn && !this.canEndTurn && this.is_my_turn;
|
||||||
|
},
|
||||||
visiblePlayers() {
|
visiblePlayers() {
|
||||||
this.range;
|
this.range;
|
||||||
return this.playersDistances.filter(x => {
|
return this.playersDistances.filter(x => {
|
||||||
@ -157,6 +163,9 @@ export default {
|
|||||||
console.log('ending turn')
|
console.log('ending turn')
|
||||||
this.$socket.emit('end_turn')
|
this.$socket.emit('end_turn')
|
||||||
},
|
},
|
||||||
|
scrap(c) {
|
||||||
|
this.$socket.emit('scrap', this.hand.indexOf(c))
|
||||||
|
},
|
||||||
play_card(card) {
|
play_card(card) {
|
||||||
if (this.pending_action == 2) {
|
if (this.pending_action == 2) {
|
||||||
if (card.need_target &&
|
if (card.need_target &&
|
||||||
@ -203,6 +212,18 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$socket.emit('refresh')
|
this.$socket.emit('refresh')
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isEndingTurn(val) {
|
||||||
|
if (val && this.canEndTurn) {
|
||||||
|
this.end_turn()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
canEndTurn(val) {
|
||||||
|
if (val && this.isEndingTurn) {
|
||||||
|
this.end_turn()
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user