add debug mode
This commit is contained in:
parent
5354986f63
commit
7a6d8b31d6
@ -201,9 +201,31 @@ def chat_message(sid, msg):
|
|||||||
bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True)
|
bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True)
|
||||||
ses.game.add_player(bot)
|
ses.game.add_player(bot)
|
||||||
bot.bot_spin()
|
bot.bot_spin()
|
||||||
|
return
|
||||||
elif '/removebot' in msg and not ses.game.started:
|
elif '/removebot' in msg and not ses.game.started:
|
||||||
if any([p.is_bot for p in ses.game.players]):
|
if any([p.is_bot for p in ses.game.players]):
|
||||||
[p for p in ses.game.players if p.is_bot][-1].disconnect()
|
[p for p in ses.game.players if p.is_bot][-1].disconnect()
|
||||||
|
return
|
||||||
|
elif '/togglecomp' in msg and ses.game:
|
||||||
|
ses.game.toggle_competitive()
|
||||||
|
return
|
||||||
|
if '/debug' in msg:
|
||||||
|
cmd = msg.split()
|
||||||
|
if len(cmd) == 2 and 'DEPLOY_KEY' in os.environ and cmd[1] == os.environ['DEPLOY_KEY']: # solo chi ha la deploy key può attivare la modalità debug
|
||||||
|
ses.game.debug = not ses.game.debug
|
||||||
|
ses.game.notify_room()
|
||||||
|
elif ses == ses.game.players[0]: # solo l'owner può attivare la modalità debug
|
||||||
|
ses.game.debug = not ses.game.debug
|
||||||
|
ses.game.notify_room()
|
||||||
|
if ses.game.debug:
|
||||||
|
sio.emit('chat_message', room=sid, data={'color': f'red','text':f'debug mode is now active, only the owner of the room can disable it with /debug'})
|
||||||
|
return
|
||||||
|
if not ses.game.debug:
|
||||||
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'debug mode is not active, only the owner of the room can enable it with /debug'})
|
||||||
|
elif '/set_chars' in msg and not ses.game.started:
|
||||||
|
cmd = msg.split()
|
||||||
|
if len(cmd) == 2 and int(cmd[1]) > 0:
|
||||||
|
ses.game.characters_to_distribute = int(cmd[1])
|
||||||
elif '/suicide' in msg and ses.game.started and ses.lives > 0:
|
elif '/suicide' in msg and ses.game.started and ses.lives > 0:
|
||||||
ses.lives = 0
|
ses.lives = 0
|
||||||
ses.notify_self()
|
ses.notify_self()
|
||||||
@ -221,7 +243,7 @@ def chat_message(sid, msg):
|
|||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
||||||
elif '/debug_show_cards' in msg and ses.game.started:
|
elif '/show_cards' in msg and ses.game.started:
|
||||||
cmd = msg.split()
|
cmd = msg.split()
|
||||||
if len(cmd) == 2:
|
if len(cmd) == 2:
|
||||||
if cmd[1] in ses.game.players_map:
|
if cmd[1] in ses.game.players_map:
|
||||||
@ -231,7 +253,7 @@ def chat_message(sid, msg):
|
|||||||
eventlet.sleep(0.3)
|
eventlet.sleep(0.3)
|
||||||
else:
|
else:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
||||||
elif '/ddc' in msg and ses.game.started: #/ddc *
|
elif '/ddc' in msg and ses.game.started: # debug destroy cards usage: [/ddc *] [/ddc username]
|
||||||
cmd = msg.split()
|
cmd = msg.split()
|
||||||
if len(cmd) == 2:
|
if len(cmd) == 2:
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode destroyed {cmd[1]} cards'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode destroyed {cmd[1]} cards'})
|
||||||
@ -246,7 +268,7 @@ def chat_message(sid, msg):
|
|||||||
ses.game.get_player_named(cmd[1]).notify_self()
|
ses.game.get_player_named(cmd[1]).notify_self()
|
||||||
else:
|
else:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
||||||
elif '/dsh' in msg and ses.game.started: #/dsh * 1
|
elif '/dsh' in msg and ses.game.started: #debug set health usage [/dsh * hp] [/dsh username hp]
|
||||||
cmd = msg.split()
|
cmd = msg.split()
|
||||||
if len(cmd) == 3:
|
if len(cmd) == 3:
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and is changing {cmd[1]} health'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and is changing {cmd[1]} health'})
|
||||||
@ -259,17 +281,11 @@ def chat_message(sid, msg):
|
|||||||
ses.game.get_player_named(cmd[1]).notify_self()
|
ses.game.get_player_named(cmd[1]).notify_self()
|
||||||
else:
|
else:
|
||||||
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
|
||||||
elif '/togglecomp' in msg and ses.game:
|
|
||||||
ses.game.toggle_competitive()
|
|
||||||
elif '/togglebot' in msg and ses.game:
|
elif '/togglebot' in msg and ses.game:
|
||||||
ses.game.toggle_disconnect_bot()
|
ses.game.toggle_disconnect_bot()
|
||||||
elif '/cancelgamesudo' in msg and ses.game.started:
|
elif '/cancelgame' in msg and ses.game.started:
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} stopped the current game'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} stopped the current game'})
|
||||||
ses.game.reset()
|
ses.game.reset()
|
||||||
elif '/cancelgame' in msg and ses.game.started:
|
|
||||||
if (ses == ses.game.players[0]):
|
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} stopped the current game'})
|
|
||||||
ses.game.reset()
|
|
||||||
elif '/startgame' in msg and not ses.game.started:
|
elif '/startgame' in msg and not ses.game.started:
|
||||||
ses.game.start_game()
|
ses.game.start_game()
|
||||||
elif '/setbotspeed' in msg:
|
elif '/setbotspeed' in msg:
|
||||||
|
@ -41,7 +41,8 @@ class Game:
|
|||||||
self.pending_winners = []
|
self.pending_winners = []
|
||||||
self.someone_won = False
|
self.someone_won = False
|
||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
|
self.characters_to_distribute = 2 # personaggi da dare a inizio partita
|
||||||
|
self.debug = False
|
||||||
|
|
||||||
def notify_room(self, sid=None):
|
def notify_room(self, sid=None):
|
||||||
if len([p for p in self.players if p.character == None]) != 0 or sid:
|
if len([p for p in self.players if p.character == None]) != 0 or sid:
|
||||||
@ -50,6 +51,7 @@ class Game:
|
|||||||
'started': self.started,
|
'started': self.started,
|
||||||
'players': [{'name':p.name, 'ready': p.character != None, 'is_bot': p.is_bot} for p in self.players],
|
'players': [{'name':p.name, 'ready': p.character != None, 'is_bot': p.is_bot} for p in self.players],
|
||||||
'password': self.password,
|
'password': self.password,
|
||||||
|
'debug': self.debug,
|
||||||
'is_competitive': self.is_competitive,
|
'is_competitive': self.is_competitive,
|
||||||
'disconnect_bot': self.disconnect_bot,
|
'disconnect_bot': self.disconnect_bot,
|
||||||
'expansions': self.expansions,
|
'expansions': self.expansions,
|
||||||
@ -118,9 +120,10 @@ class Game:
|
|||||||
self.play_turn()
|
self.play_turn()
|
||||||
|
|
||||||
def choose_characters(self):
|
def choose_characters(self):
|
||||||
char_cards = random.sample(characters.all_characters(self.expansions), len(self.players)*2)
|
n = self.characters_to_distribute
|
||||||
|
char_cards = random.sample(characters.all_characters(self.expansions), len(self.players)*n)
|
||||||
for i in range(len(self.players)):
|
for i in range(len(self.players)):
|
||||||
self.players[i].set_available_character(char_cards[i * 2 : i * 2 + 2])
|
self.players[i].set_available_character(char_cards[i * n : i * n + n])
|
||||||
|
|
||||||
def start_game(self):
|
def start_game(self):
|
||||||
print('GAME IS STARING')
|
print('GAME IS STARING')
|
||||||
|
@ -90,6 +90,7 @@ class Player:
|
|||||||
self.target_p: str = None
|
self.target_p: str = None
|
||||||
self.is_drawing = False
|
self.is_drawing = False
|
||||||
self.special_use_count = 0
|
self.special_use_count = 0
|
||||||
|
self.not_chosen_character = None
|
||||||
try:
|
try:
|
||||||
del self.win_status
|
del self.win_status
|
||||||
except:
|
except:
|
||||||
@ -116,8 +117,12 @@ class Player:
|
|||||||
def set_character(self, character: str):
|
def set_character(self, character: str):
|
||||||
print(self.available_characters, character)
|
print(self.available_characters, character)
|
||||||
if self.character == None:
|
if self.character == None:
|
||||||
self.character = next(
|
self.character = next(x for x in self.available_characters if x.name == character)
|
||||||
x for x in self.available_characters if x.name == character)
|
if 'high_noon' in self.game.expansions:
|
||||||
|
# questo viene utilizzato per la carta nuova identità
|
||||||
|
self.not_chosen_character = next(x for x in self.available_characters if x.name != character)
|
||||||
|
else:
|
||||||
|
self.not_chosen_character = None
|
||||||
self.real_character = self.character
|
self.real_character = self.character
|
||||||
self.available_characters = []
|
self.available_characters = []
|
||||||
print(f'{self.name}: I chose character {self.character.name}')
|
print(f'{self.name}: I chose character {self.character.name}')
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
<input style="position:absolute;top:0;right:0;max-height:100pt" v-if="!started" type="button" @click="leaveRoom" :value="$t('leave_room')"/>
|
<input style="position:absolute;top:0;right:0;max-height:100pt" v-if="!started" type="button" @click="leaveRoom" :value="$t('leave_room')"/>
|
||||||
</div>
|
</div>
|
||||||
<h3>{{$t('room_players', {username:username})}}</h3>
|
<h3>{{$t('room_players', {username:username})}}</h3>
|
||||||
|
<div v-if="debug" style="position: absolute;top: 6pt;right: 6pt;">
|
||||||
|
<p style="padding:0 10px;background:red;color:white;border-radius:12pt;">DEBUG ON</p>
|
||||||
|
</div>
|
||||||
<div v-if="!started">
|
<div v-if="!started">
|
||||||
<PrettyCheck v-if="isRoomOwner" class="p-switch p-fill" v-model="privateRoom" style="margin-top:5px; margin-bottom:3px;">{{$t("private_room")}}</PrettyCheck>
|
<PrettyCheck v-if="isRoomOwner" class="p-switch p-fill" v-model="privateRoom" style="margin-top:5px; margin-bottom:3px;">{{$t("private_room")}}</PrettyCheck>
|
||||||
<label v-if="password !== ''">{{$t('password')}}<b class="selectable" style="font-size:larger;">{{ password }}</b></label>
|
<label v-if="password !== ''">{{$t('password')}}<b class="selectable" style="font-size:larger;">{{ password }}</b></label>
|
||||||
@ -114,6 +117,7 @@ export default {
|
|||||||
hasToSetUsername: false,
|
hasToSetUsername: false,
|
||||||
is_competitive: false,
|
is_competitive: false,
|
||||||
disconnect_bot: false,
|
disconnect_bot: false,
|
||||||
|
debug: false,
|
||||||
}),
|
}),
|
||||||
sockets: {
|
sockets: {
|
||||||
room(data) {
|
room(data) {
|
||||||
@ -130,6 +134,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.debug = data.debug
|
||||||
this.players = data.players.map(x => {
|
this.players = data.players.map(x => {
|
||||||
return {
|
return {
|
||||||
name: x.name,
|
name: x.name,
|
||||||
|
Loading…
Reference in New Issue
Block a user