ghosts
This commit is contained in:
parent
3394b10896
commit
579501e01c
@ -270,14 +270,18 @@ class Game:
|
||||
def play_turn(self):
|
||||
self.incremental_turn += 1
|
||||
if self.players[self.turn].lives <= 0 or self.players[self.turn].is_dead:
|
||||
if self.check_event(ce.DeadMan) and not self.did_resuscitate_deadman and len(self.get_dead_players()) > 0:
|
||||
self.did_resuscitate_deadman = True
|
||||
pl = sorted(self.get_dead_players(), key=lambda x:x.death_turn)[0]
|
||||
if self.check_event(ce.DeadMan) and not self.did_resuscitate_deadman and pl != self.players[self.turn]:
|
||||
self.did_resuscitate_deadman = True
|
||||
pl.is_dead = False
|
||||
pl.is_ghost = False
|
||||
pl.lives = 2
|
||||
pl.hand.append(self.deck.draw())
|
||||
pl.hand.append(self.deck.draw())
|
||||
pl.notify_self()
|
||||
elif self.check_event(ceh.CittaFantasma):
|
||||
pl.is_ghost = True
|
||||
pl.notify_self()
|
||||
else:
|
||||
return self.next_turn()
|
||||
self.player_bangs = 0
|
||||
@ -323,8 +327,14 @@ class Game:
|
||||
|
||||
def next_turn(self):
|
||||
if self.shutting_down: return
|
||||
if self.players[self.turn].is_dead and self.players[self.turn].is_ghost and self.check_event(ceh.CittaFantasma):
|
||||
self.players[self.turn].is_ghost = False
|
||||
for i in range(len(self.players[self.turn].attacker.hand)):
|
||||
self.deck.scrap(self.players[self.turn].attacker.hand.pop(), True)
|
||||
for i in range(len(self.players[self.turn].attacker.equipment)):
|
||||
self.deck.scrap(self.players[self.turn].attacker.equipment.pop(), True)
|
||||
self.players[self.turn].notify_self()
|
||||
pls = self.get_alive_players()
|
||||
print(self.turn)
|
||||
if len(pls) > 0:
|
||||
if self.check_event(ceh.CorsaAllOro):
|
||||
self.turn = (self.turn - 1) % len(self.players)
|
||||
@ -368,7 +378,7 @@ class Game:
|
||||
else: return False
|
||||
|
||||
def player_death(self, player: pl.Player, disconnected=False):
|
||||
if not player in self.players: return
|
||||
if not player in self.players or player.is_ghost: return
|
||||
import bang.expansions.dodge_city.characters as chd
|
||||
print(player.attacker)
|
||||
if player.attacker and player.attacker in self.players and isinstance(player.attacker.role, roles.Sheriff) and isinstance(player.role, roles.Vice):
|
||||
@ -481,7 +491,7 @@ class Game:
|
||||
|
||||
def get_visible_players(self, player: pl.Player):
|
||||
pls = self.get_alive_players()
|
||||
if len(pls) == 0: return []
|
||||
if len(pls) == 0 or player not in pls: return []
|
||||
i = pls.index(player)
|
||||
sight = player.get_sight()
|
||||
mindist = 99 if not self.check_event(ce.Agguato) else 1
|
||||
@ -491,11 +501,12 @@ class Game:
|
||||
'lives': pls[j].lives,
|
||||
'max_lives': pls[j].max_lives,
|
||||
'is_sheriff': isinstance(pls[j].role, roles.Sheriff),
|
||||
'cards': len(pls[j].hand)+len(pls[j].equipment)
|
||||
'cards': len(pls[j].hand)+len(pls[j].equipment),
|
||||
'is_ghost': pls[j].is_ghost,
|
||||
} for j in range(len(pls)) if i != j]
|
||||
|
||||
def get_alive_players(self):
|
||||
return [p for p in self.players if not p.is_dead]
|
||||
return [p for p in self.players if not p.is_dead or p.is_ghost]
|
||||
|
||||
def get_dead_players(self):
|
||||
return [p for p in self.players if p.is_dead]
|
||||
@ -513,6 +524,7 @@ class Game:
|
||||
'pending_action': p.pending_action,
|
||||
'character': p.character.__dict__ if p.character else None,
|
||||
'real_character': p.real_character.__dict__ if p.real_character else None,
|
||||
'icon': p.role.icon if self.initial_players == 3 and p.role else '🤠'
|
||||
'icon': p.role.icon if self.initial_players == 3 and p.role else '🤠',
|
||||
'is_ghost': p.is_ghost,
|
||||
} for p in self.get_alive_players()]
|
||||
self.sio.emit('players_update', room=self.name, data=data)
|
||||
|
@ -63,6 +63,7 @@ class Player:
|
||||
self.special_use_count = 0
|
||||
self.is_dead = False
|
||||
self.death_turn = 0
|
||||
self.is_ghost = False
|
||||
|
||||
def reset(self):
|
||||
self.hand: cs.Card = []
|
||||
@ -96,6 +97,7 @@ class Player:
|
||||
self.mancato_needed = 0
|
||||
self.molly_discarded_cards = 0
|
||||
self.is_dead = False
|
||||
self.is_ghost = False
|
||||
self.death_turn = 0
|
||||
|
||||
def join_game(self, game):
|
||||
@ -181,7 +183,7 @@ class Player:
|
||||
self.pending_action = PendingAction.CHOOSE
|
||||
elif self.character and self.character.check(self.game, chars.SuzyLafayette) and len(self.hand) == 0 and ( not self.is_my_turn or self.pending_action == PendingAction.PLAY):
|
||||
self.hand.append(self.game.deck.draw(True))
|
||||
if self.lives <= 0 and self.max_lives > 0:
|
||||
if self.lives <= 0 and self.max_lives > 0 and not self.is_ghost:
|
||||
print('dying, attacker', self.attacker)
|
||||
if self.character.check(self.game, chars.SidKetchum) and len(self.hand) > 1:
|
||||
self.lives += 1
|
||||
@ -203,7 +205,7 @@ class Player:
|
||||
ser['sight'] = self.get_sight()
|
||||
ser['lives'] = max(ser['lives'], 0)
|
||||
|
||||
if self.lives <= 0 and self.max_lives > 0:
|
||||
if self.lives <= 0 and self.max_lives > 0 and not self.is_ghost:
|
||||
self.pending_action = PendingAction.WAIT
|
||||
ser['hand'] = []
|
||||
ser['equipment'] = []
|
||||
@ -310,7 +312,7 @@ class Player:
|
||||
self.choose(randrange(0, len(target.hand)+len(target.equipment)))
|
||||
|
||||
def play_turn(self, can_play_vendetta = True):
|
||||
if self.lives == 0 or self.is_dead:
|
||||
if (self.lives == 0 or self.is_dead) and not self.is_ghost:
|
||||
return self.end_turn(forced=True)
|
||||
self.scrapped_cards = 0
|
||||
self.can_play_ranch = True
|
||||
@ -333,6 +335,8 @@ class Player:
|
||||
self.heal_if_needed()
|
||||
if self.lives <= 0:
|
||||
return self.notify_self()
|
||||
|
||||
#non è un elif perchè vera custer deve fare questo poi cambiare personaggio
|
||||
if self.game.check_event(ce.FratelliDiSangue) and self.lives > 1 and not self.is_giving_life and len([p for p in self.game.get_alive_players() if p != self and p.lives < p.max_lives]):
|
||||
self.available_cards = [{
|
||||
'name': p.name,
|
||||
|
@ -52,7 +52,7 @@ export default {
|
||||
sockets: {
|
||||
self(self){
|
||||
self = JSON.parse(self)
|
||||
this.isPlaying = self.lives > 0
|
||||
this.isPlaying = self.lives > 0 || self.is_ghost
|
||||
this.pending_action = self.pending_action
|
||||
},
|
||||
scrap(card) {
|
||||
|
@ -16,10 +16,13 @@
|
||||
<Card v-if="startGameCard" :card="startGameCard" @click.native="startGame"/>
|
||||
<!-- <div style="position: relative;width:260pt;height:400pt;"> -->
|
||||
<div v-for="p in playersTable" v-bind:key="p.card.name" style="position:relative;">
|
||||
<transition-group v-if="p.max_lives" name="list" tag="div" class="tiny-health">
|
||||
<transition-group v-if="p.max_lives && !p.is_ghost" name="list" tag="div" class="tiny-health">
|
||||
<span v-for="(n, i) in p.lives" v-bind:key="n" :alt="i">❤️</span>
|
||||
<span v-for="(n, i) in (p.max_lives-p.lives)" v-bind:key="n" :alt="i">💀</span>
|
||||
</transition-group>
|
||||
<div v-else-if="p.is_ghost" class="tiny-health">
|
||||
<span :alt="i">👻</span>
|
||||
</div>
|
||||
<Card :card="p.card" :class="{is_my_turn:p.is_my_turn}"/>
|
||||
<Card v-if="p.character" :card="p.character" class="character tiny-character" @click.native="selectedInfo = [p.character]"/>
|
||||
<Card v-if="p.character && p.character.name !== p.real_character.name" style="transform:scale(0.5) translate(-90px, -50px);" :card="p.character" class="character tiny-character" @click.native="selectedInfo = [p.character]"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<p v-if="instruction && lives > 0" class="center-stuff">{{instruction}}</p>
|
||||
<p v-if="instruction && (lives > 0 || is_ghost)" class="center-stuff">{{instruction}}</p>
|
||||
<!-- <button v-if="canEndTurn" @click="end_turn">Termina Turno</button> -->
|
||||
<div class="equipment-slot">
|
||||
<Card v-if="my_role" :card="my_role" class="back"
|
||||
@ -11,7 +11,7 @@
|
||||
<span v-for="(n, i) in lives" v-bind:key="n" :alt="i">❤️</span>
|
||||
<span v-for="(n, i) in (max_lives-lives)" v-bind:key="n" :alt="i">💀</span>
|
||||
</transition-group>
|
||||
<transition-group v-if="lives > 0" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
||||
<transition-group v-if="lives > 0 || is_ghost" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
||||
<Card v-for="card in equipment" v-bind:key="card.name+card.number" :card="card"
|
||||
@pointerenter.native="desc=($i18n.locale=='it'?card.desc:card.desc_eng)" @pointerleave.native="desc=''"
|
||||
@click.native="play_card(card, true)" />
|
||||
@ -24,7 +24,7 @@
|
||||
<button v-if="is_my_turn && character.name === 'Chuck Wengam' && lives > 1" @click="chuckSpecial">{{$t('special_ability')}}</button>
|
||||
<button v-if="is_my_turn && character.name === 'José Delgrado' && special_use_count < 2 && hand.filter(x => x.is_equipment).length > 0" @click="joseScrap=true">{{$t('special_ability')}}</button>
|
||||
<button v-if="is_my_turn && character.name === 'Doc Holyday' && special_use_count < 1 && hand.length > 1" @click="holydayScrap=true">{{$t('special_ability')}}</button>
|
||||
<div v-if="lives > 0" style="position:relative">
|
||||
<div v-if="lives > 0 || is_ghost" style="position:relative">
|
||||
<span id="hand_text">{{$t('hand')}}</span>
|
||||
<transition-group name="list" tag="div" class="hand">
|
||||
<Card v-for="card in hand" v-bind:key="card.name+card.number" :card="card"
|
||||
@ -39,7 +39,7 @@
|
||||
<Chooser v-if="card_against" :text="$t('card_against')" :cards="visiblePlayers" :select="selectAgainst" :cancel="cancelCardAgainst"/>
|
||||
<Chooser v-if="pending_action == 3" :text="respondText" :cards="respondCards" :select="respond"/>
|
||||
<Chooser v-if="shouldChooseCard" :text="$t(choose_text)" :cards="available_cards" :select="choose"/>
|
||||
<Chooser v-if="lives <= 0 && max_lives > 0" :text="$t('you_died')" :cancelText="$t('spectate')" :cancel="()=>{max_lives = 0}"/>
|
||||
<Chooser v-if="lives <= 0 && max_lives > 0 && !is_ghost" :text="$t('you_died')" :cancelText="$t('spectate')" :cancel="()=>{max_lives = 0}"/>
|
||||
<Chooser v-if="win_status !== undefined" :text="win_status?$t('you_win'):$t('you_lose')" />
|
||||
<Chooser v-if="show_role" :text="$t('you_are')" :cards="[my_role]" :hintText="($i18n.locale=='it'?my_role.goal:my_role.goal_eng)" :select="() => {show_role=false}" :cancel="() => {show_role=false}" :cancelText="$t('ok')" />
|
||||
<Chooser v-if="notifycard" :key="notifycard.card" :text="`${notifycard.player} ${$t('did_pick_as')}:`" :cards="[notifycard.card]" :hintText="$t(notifycard.message)" class="turn-notify-4s"/>
|
||||
@ -106,6 +106,7 @@ export default {
|
||||
holydayScrap: false,
|
||||
special_use_count: 0,
|
||||
mancato_needed: 0,
|
||||
is_ghost: false,
|
||||
name: '',
|
||||
}),
|
||||
sockets: {
|
||||
@ -141,6 +142,7 @@ export default {
|
||||
this.sight = self.sight
|
||||
this.attacker = self.attacker
|
||||
this.mancato_needed = self.mancato_needed
|
||||
this.is_ghost = self.is_ghost
|
||||
if (this.pending_action == 5 && self.target_p) {
|
||||
this.chooseCardFromPlayer(self.target_p)
|
||||
} else if (this.pending_action == 5) {
|
||||
|
Loading…
Reference in New Issue
Block a user