Merge branch 'dev' into main
This commit is contained in:
commit
e681957581
@ -175,6 +175,8 @@ class Game:
|
|||||||
attacker.pending_action = pl.PendingAction.PLAY
|
attacker.pending_action = pl.PendingAction.PLAY
|
||||||
attacker.notify_self()
|
attacker.notify_self()
|
||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
|
if self.pending_winners and not self.someone_won:
|
||||||
|
return self.announces_winners()
|
||||||
|
|
||||||
def indian_others(self, attacker: pl.Player):
|
def indian_others(self, attacker: pl.Player):
|
||||||
self.attack_in_progress = True
|
self.attack_in_progress = True
|
||||||
@ -191,6 +193,8 @@ class Game:
|
|||||||
attacker.pending_action = pl.PendingAction.PLAY
|
attacker.pending_action = pl.PendingAction.PLAY
|
||||||
attacker.notify_self()
|
attacker.notify_self()
|
||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
|
if self.pending_winners and not self.someone_won:
|
||||||
|
return self.announces_winners()
|
||||||
|
|
||||||
def attack(self, attacker: pl.Player, target_username:str, double:bool=False):
|
def attack(self, attacker: pl.Player, target_username:str, double:bool=False):
|
||||||
if self.get_player_named(target_username).get_banged(attacker=attacker, double=double):
|
if self.get_player_named(target_username).get_banged(attacker=attacker, double=double):
|
||||||
@ -282,20 +286,10 @@ class Game:
|
|||||||
else:
|
else:
|
||||||
self.ready_count += 1
|
self.ready_count += 1
|
||||||
if self.ready_count == self.waiting_for:
|
if self.ready_count == self.waiting_for:
|
||||||
#TODO: si potrebbe fare un metodo a parte e chiamarlo quando finiscono gli eventi di gatling e indiani
|
|
||||||
self.waiting_for = 0
|
self.waiting_for = 0
|
||||||
self.ready_count = 0
|
self.ready_count = 0
|
||||||
if self.pending_winners:
|
if self.pending_winners and not self.someone_won:
|
||||||
print('WE HAVE A WINNER - responders_did_respond_resume_turn')
|
return self.announces_winners()
|
||||||
for p in self.get_alive_players():
|
|
||||||
p.win_status = p in self.pending_winners
|
|
||||||
if p.win_status:
|
|
||||||
self.sio.emit('chat_message', room=self.name, data=f'_won|{p.name}')
|
|
||||||
p.notify_self()
|
|
||||||
for i in range(5):
|
|
||||||
self.sio.emit('chat_message', room=self.name, data=f'_lobby_reset|{5-i}')
|
|
||||||
eventlet.sleep(1)
|
|
||||||
return self.reset()
|
|
||||||
if self.dalton_on:
|
if self.dalton_on:
|
||||||
self.dalton_on = False
|
self.dalton_on = False
|
||||||
print(f'notifying {self.players[self.turn].name} about his turn')
|
print(f'notifying {self.players[self.turn].name} about his turn')
|
||||||
@ -304,6 +298,26 @@ class Game:
|
|||||||
self.players[self.turn].pending_action = pl.PendingAction.PLAY
|
self.players[self.turn].pending_action = pl.PendingAction.PLAY
|
||||||
self.players[self.turn].notify_self()
|
self.players[self.turn].notify_self()
|
||||||
|
|
||||||
|
def announces_winners(self, winners=None):
|
||||||
|
if (winners is None):
|
||||||
|
print('WE HAVE A WINNER - pending winners')
|
||||||
|
else:
|
||||||
|
print('WE HAVE A WINNER')
|
||||||
|
for p in self.get_alive_players():
|
||||||
|
if winners is None:
|
||||||
|
p.win_status = p in self.pending_winners
|
||||||
|
else:
|
||||||
|
p.win_status = p in winners
|
||||||
|
if p.win_status:
|
||||||
|
if not self.someone_won:
|
||||||
|
self.someone_won = True
|
||||||
|
self.sio.emit('chat_message', room=self.name, data=f'_won|{p.name}')
|
||||||
|
p.notify_self()
|
||||||
|
for i in range(5):
|
||||||
|
self.sio.emit('chat_message', room=self.name, data=f'_lobby_reset|{5-i}')
|
||||||
|
eventlet.sleep(1)
|
||||||
|
return self.reset()
|
||||||
|
|
||||||
def next_player(self):
|
def next_player(self):
|
||||||
pls = self.get_alive_players()
|
pls = self.get_alive_players()
|
||||||
return pls[(pls.index(self.players[self.turn]) + 1) % len(pls)]
|
return pls[(pls.index(self.players[self.turn]) + 1) % len(pls)]
|
||||||
@ -332,6 +346,7 @@ class Game:
|
|||||||
self.deck.flip_event()
|
self.deck.flip_event()
|
||||||
if len(self.deck.event_cards) > 0 and self.deck.event_cards[0] != None:
|
if len(self.deck.event_cards) > 0 and self.deck.event_cards[0] != None:
|
||||||
print(f'flip new event {self.deck.event_cards[0].name}')
|
print(f'flip new event {self.deck.event_cards[0].name}')
|
||||||
|
self.sio.emit('chat_message', room=self.name, data={'color': f'orange','text':f'_flip_event|{self.deck.event_cards[0].name}'})
|
||||||
if self.check_event(ce.DeadMan):
|
if self.check_event(ce.DeadMan):
|
||||||
self.did_resuscitate_deadman = False
|
self.did_resuscitate_deadman = False
|
||||||
elif self.check_event(ce.RouletteRussa):
|
elif self.check_event(ce.RouletteRussa):
|
||||||
@ -374,6 +389,8 @@ class Game:
|
|||||||
def next_turn(self):
|
def next_turn(self):
|
||||||
if self.shutting_down: return
|
if self.shutting_down: return
|
||||||
print(f'{self.players[self.turn].name} invoked next turn')
|
print(f'{self.players[self.turn].name} invoked next turn')
|
||||||
|
if self.pending_winners and not self.someone_won:
|
||||||
|
return self.announces_winners()
|
||||||
pls = self.get_alive_players()
|
pls = self.get_alive_players()
|
||||||
if len(pls) > 0:
|
if len(pls) > 0:
|
||||||
if self.check_event(ceh.CorsaAllOro):
|
if self.check_event(ceh.CorsaAllOro):
|
||||||
@ -481,17 +498,7 @@ class Game:
|
|||||||
winners = [p for p in self.players if p.role != None and p.role.on_player_death(self.get_alive_players(), initial_players=self.initial_players, dead_role=player.role, attacker_role=attacker_role)]
|
winners = [p for p in self.players if p.role != None and p.role.on_player_death(self.get_alive_players(), initial_players=self.initial_players, dead_role=player.role, attacker_role=attacker_role)]
|
||||||
#print(f'win check: ready-{self.ready_count} waiting-{self.waiting_for} winners:{len(winners)}')
|
#print(f'win check: ready-{self.ready_count} waiting-{self.waiting_for} winners:{len(winners)}')
|
||||||
if not self.attack_in_progress and len(winners) > 0 and not self.someone_won:
|
if not self.attack_in_progress and len(winners) > 0 and not self.someone_won:
|
||||||
print('WE HAVE A WINNER')
|
return self.announces_winners(winners)
|
||||||
self.someone_won = True
|
|
||||||
for p in self.get_alive_players():
|
|
||||||
p.win_status = p in winners
|
|
||||||
if p.win_status:
|
|
||||||
self.sio.emit('chat_message', room=self.name, data=f'_won|{p.name}')
|
|
||||||
p.notify_self()
|
|
||||||
for i in range(5):
|
|
||||||
self.sio.emit('chat_message', room=self.name, data=f'_lobby_reset|{5-i}')
|
|
||||||
eventlet.sleep(1)
|
|
||||||
return self.reset()
|
|
||||||
elif len(winners) > 0 and not self.someone_won: # non tutti hanno risposto, ma ci sono vincitori.
|
elif len(winners) > 0 and not self.someone_won: # non tutti hanno risposto, ma ci sono vincitori.
|
||||||
self.pending_winners = winners
|
self.pending_winners = winners
|
||||||
|
|
||||||
|
@ -35,7 +35,12 @@ export default {
|
|||||||
sockets: {
|
sockets: {
|
||||||
chat_message(msg) {
|
chat_message(msg) {
|
||||||
// console.log(msg)
|
// console.log(msg)
|
||||||
if ((typeof msg === "string") && msg.indexOf('_') === 0) {
|
if ((typeof msg === "string" && msg.indexOf('_') === 0) || (msg.color != null && msg.text.indexOf('_') === 0)) {
|
||||||
|
let t_color = null
|
||||||
|
if (msg.color != null) {
|
||||||
|
t_color = msg.color
|
||||||
|
msg = msg.text
|
||||||
|
}
|
||||||
let params = msg.split('|')
|
let params = msg.split('|')
|
||||||
let type = params.shift().substring(1)
|
let type = params.shift().substring(1)
|
||||||
if (["flipped", "respond", "play_card", "play_card_against", "play_card_for", "spilled_beer", "diligenza", "wellsfargo", "saloon", "special_calamity"].indexOf(type) !== -1){
|
if (["flipped", "respond", "play_card", "play_card_against", "play_card_for", "spilled_beer", "diligenza", "wellsfargo", "saloon", "special_calamity"].indexOf(type) !== -1){
|
||||||
@ -54,7 +59,11 @@ export default {
|
|||||||
type += "4"
|
type += "4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.messages.push({text:this.$t(`chat.${type}`, params)});
|
if (t_color != null) {
|
||||||
|
this.messages.push({color:t_color, text:this.$t(`chat.${type}`, params)});
|
||||||
|
} else {
|
||||||
|
this.messages.push({text:this.$t(`chat.${type}`, params)});
|
||||||
|
}
|
||||||
if (type == 'turn' && params[0] == this.username) {
|
if (type == 'turn' && params[0] == this.username) {
|
||||||
(new Audio(turn_sfx)).play();
|
(new Audio(turn_sfx)).play();
|
||||||
} else if (type == 'died_role') {
|
} else if (type == 'died_role') {
|
||||||
|
@ -316,7 +316,7 @@ export default {
|
|||||||
this.$socket.emit('scrap', this.hand.indexOf(c))
|
this.$socket.emit('scrap', this.hand.indexOf(c))
|
||||||
},
|
},
|
||||||
play_card(card, from_equipment) {
|
play_card(card, from_equipment) {
|
||||||
if (from_equipment && (!card.usable_next_turn || !card.can_be_used_now)) return;
|
if (from_equipment && (!card.usable_next_turn || !card.can_be_used_now || (this.eventCard && this.eventCard.name == "Lazo"))) return;
|
||||||
else if (card.usable_next_turn && !card.can_be_used_now) return this.really_play_card(card, null);
|
else if (card.usable_next_turn && !card.can_be_used_now) return this.really_play_card(card, null);
|
||||||
let calamity_special = (card.name === 'Mancato!' && this.character.name === 'Calamity Janet')
|
let calamity_special = (card.name === 'Mancato!' && this.character.name === 'Calamity Janet')
|
||||||
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
|
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
|
||||||
|
@ -102,7 +102,8 @@
|
|||||||
"change_username": "{0} is now {1}.",
|
"change_username": "{0} is now {1}.",
|
||||||
"lobby_reset": "Going back to lobby in {0} seconds...",
|
"lobby_reset": "Going back to lobby in {0} seconds...",
|
||||||
"prison_free": "{0} got out of prison",
|
"prison_free": "{0} got out of prison",
|
||||||
"prison_turn": "{0} stayed in prison this turn"
|
"prison_turn": "{0} stayed in prison this turn",
|
||||||
|
"flip_event": "🎴 EVENT: {0} 🎴"
|
||||||
},
|
},
|
||||||
"foc": {
|
"foc": {
|
||||||
"leggedelwest": "He must play this card on this turn if possible."
|
"leggedelwest": "He must play this card on this turn if possible."
|
||||||
|
@ -102,7 +102,8 @@
|
|||||||
"change_username": "{0} ha cambiato nome in {1}.",
|
"change_username": "{0} ha cambiato nome in {1}.",
|
||||||
"lobby_reset": "Si ritorna alla stanza in {0} secondi...",
|
"lobby_reset": "Si ritorna alla stanza in {0} secondi...",
|
||||||
"prison_free": "{0} è uscito di prigione",
|
"prison_free": "{0} è uscito di prigione",
|
||||||
"prison_turn": "{0} rimane in prigione questo turno"
|
"prison_turn": "{0} rimane in prigione questo turno",
|
||||||
|
"flip_event": "🎴 EVENTO: {0} 🎴"
|
||||||
},
|
},
|
||||||
"foc": {
|
"foc": {
|
||||||
"leggedelwest": "Ed è obbligato a usarla nel suo turno, se possibile"
|
"leggedelwest": "Ed è obbligato a usarla nel suo turno, se possibile"
|
||||||
|
Loading…
Reference in New Issue
Block a user