add spectate button

This commit is contained in:
Alberto Xamin 2023-01-19 10:56:38 +00:00
parent c05e2a69e2
commit d9c3493661
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
3 changed files with 23 additions and 1 deletions

View File

@ -190,6 +190,7 @@ class Game:
'disconnect_bot': self.disconnect_bot, 'disconnect_bot': self.disconnect_bot,
'expansions': self.expansions, 'expansions': self.expansions,
'available_expansions': self.available_expansions, 'available_expansions': self.available_expansions,
'is_replay': self.is_replay,
}) })
self.sio.emit('debug', room=self.name, data=self.debug) self.sio.emit('debug', room=self.name, data=self.debug)
if self.debug: if self.debug:

View File

@ -445,7 +445,7 @@ def chat_message(sid, msg, pl=None):
ses.game.add_player(bot) ses.game.add_player(bot)
bot.bot_spin() bot.bot_spin()
return return
if '/replay' in msg and not '/replayspeed' in msg: if '/replay' in msg and not '/replayspeed' in msg and not '/replaypov' in msg:
_cmd = msg.split() _cmd = msg.split()
if len(_cmd) >= 2: if len(_cmd) >= 2:
replay_id = _cmd[1] replay_id = _cmd[1]
@ -463,6 +463,21 @@ def chat_message(sid, msg, pl=None):
if len(_cmd) == 2: if len(_cmd) == 2:
ses.game.replay_speed = float(_cmd[1]) ses.game.replay_speed = float(_cmd[1])
return return
if '/replaypov' in msg:
_cmd = msg.split()
if len(_cmd) > 1:
name = ' '.join(_cmd[1:])
for p in ses.game.players:
if p.sid == ses.sid:
from tests.dummy_socket import DummySocket
p.sio = DummySocket()
p.sid = ''
pl = ses.game.get_player_named(name)
pl.sio = sio
pl.sid = ses.sid
pl.set_role(pl.role)
pl.notify_self()
return
if '/startwithseed' in msg and not ses.game.started: if '/startwithseed' in msg and not ses.game.started:
if len(msg.split()) > 1: if len(msg.split()) > 1:
ses.game.start_game(int(msg.split()[1])) ses.game.start_game(int(msg.split()[1]))

View File

@ -66,6 +66,7 @@
:card="card" @click.native="selectedInfo = p.gold_rush_equipment" :card="card" @click.native="selectedInfo = p.gold_rush_equipment"
:style="`margin-top: ${i+p.equipment.length<1?10:-(Math.min((p.equipment.length+p.gold_rush_equipment.length+1)*12,80))}pt`"/> :style="`margin-top: ${i+p.equipment.length<1?10:-(Math.min((p.equipment.length+p.gold_rush_equipment.length+1)*12,80))}pt`"/>
</div> </div>
<button v-if="is_replay" style="position:absolute" @click="replayPlayer(p.name)">{{$t('spectate_player')}}</button>
<div v-if="p.is_bot" style="position:absolute;bottom:57%;width:20pt;" class="center-stuff"> <div v-if="p.is_bot" style="position:absolute;bottom:57%;width:20pt;" class="center-stuff">
<span>🤖</span> <span>🤖</span>
</div> </div>
@ -144,6 +145,7 @@ export default {
showTurnFlow: false, showTurnFlow: false,
turnReversed: false, turnReversed: false,
displayAdminStatus: false, displayAdminStatus: false,
is_replay: false,
turn: -1, turn: -1,
}), }),
sockets: { sockets: {
@ -161,6 +163,7 @@ export default {
this.disconnect_bot = data.disconnect_bot this.disconnect_bot = data.disconnect_bot
this.togglable_expansions = data.available_expansions this.togglable_expansions = data.available_expansions
this.expansions = data.expansions this.expansions = data.expansions
this.is_replay = data.is_replay
this.players = data.players.map(x => { this.players = data.players.map(x => {
return { return {
name: x.name, name: x.name,
@ -285,6 +288,9 @@ export default {
console.log(ex+' '+ this.expansions+ (this.expansions.indexOf(ex) !== -1)) console.log(ex+' '+ this.expansions+ (this.expansions.indexOf(ex) !== -1))
return this.expansions.indexOf(ex) !== -1 return this.expansions.indexOf(ex) !== -1
}, },
replayPlayer(player) {
this.$socket.emit('chat_message', `/replaypov ${player}`)
},
leaveRoom() { leaveRoom() {
window.location.replace(window.location.origin) window.location.replace(window.location.origin)
document.title = 'PewPew!' document.title = 'PewPew!'