gameplay modifiers

This commit is contained in:
Alberto Xamin 2020-12-13 10:31:16 +01:00
parent 90b6aad809
commit a6a5f95a5b
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
6 changed files with 57 additions and 8 deletions

View File

@ -101,6 +101,14 @@ def toggle_expansion(sid, expansion_name):
g = sio.get_session(sid).game
g.toggle_expansion(expansion_name)
@sio.event
def toggle_comp(sid):
sio.get_session(sid).game.toggle_competitive()
@sio.event
def toggle_replace_with_bot(sid):
sio.get_session(sid).game.toggle_disconnect_bot()
@sio.event
def join_room(sid, room):
room_name = room['name']
@ -130,9 +138,13 @@ def chat_message(sid, msg):
elif '/removebot' in msg and not ses.game.started:
if any([p.is_bot for p in ses.game.players]):
[p for p in ses.game.players if p.is_bot][-1].disconnect()
elif '/suicide' in msg and ses.game.started:
elif '/suicide' in msg and ses.game.started and ses.lives > 0:
ses.lives = 0
ses.notify_self()
elif '/togglecomp' in msg and ses.game:
ses.game.toggle_competitive()
elif '/togglebot' in msg and ses.game:
ses.game.toggle_disconnect_bot()
elif '/cancelgame' in msg and ses.game.started:
ses.game.reset()
elif '/gameinfo' in msg:

View File

@ -24,6 +24,8 @@ class Game:
self.password = ''
self.expansions = []
self.shutting_down = False
self.is_competitive = False
self.disconnect_bot = True
def notify_room(self):
if len([p for p in self.players if p.character == None]) != 0:
@ -32,6 +34,8 @@ class Game:
'started': self.started,
'players': [{'name':p.name, 'ready': p.character != None} for p in self.players],
'password': self.password,
'is_competitive': self.is_competitive,
'disconnect_bot': self.disconnect_bot,
'expansions': self.expansions,
})
@ -44,6 +48,14 @@ class Game:
self.expansions.append(expansion_name)
self.notify_room()
def toggle_competitive(self):
self.is_competitive = not self.is_competitive
self.notify_room()
def toggle_disconnect_bot(self):
self.disconnect_bot = not self.disconnect_bot
self.notify_room()
def add_player(self, player: players.Player):
if player.is_bot and len(self.players) >= 8:
return
@ -215,7 +227,10 @@ class Game:
def handle_disconnect(self, player: players.Player):
print(f'player {player.name} left the game {self.name}')
if player in self.players:
self.player_death(player=player, disconnected=True)
if self.disconnect_bot:
player.is_bot = True
else:
self.player_death(player=player, disconnected=True)
else:
self.dead_players.remove(player)
if len([p for p in self.players if not p.is_bot])+len([p for p in self.dead_players if not p.is_bot]) == 0:

View File

@ -474,7 +474,7 @@ class Player:
if self.mancato_needed <= 0:
self.game.responders_did_respond_resume_turn()
return
if len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
self.take_damage_response()
self.game.responders_did_respond_resume_turn()
@ -492,7 +492,7 @@ class Player:
for i in range(len(self.equipment)):
if self.equipment[i].can_be_used_now:
print('usable', self.equipment[i])
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not isinstance(self.character, chars.Jourdonnais)\
if not self.game.is_competitive and len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not isinstance(self.character, chars.Jourdonnais)\
and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
print('Cant defend')
@ -514,7 +514,7 @@ class Player:
def get_indians(self, attacker):
self.attacker = attacker
if len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
print('Cant defend')
self.take_damage_response()
return False
@ -528,7 +528,7 @@ class Player:
def get_dueled(self, attacker):
self.attacker = attacker
if len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
print('Cant defend')
self.take_damage_response()
self.game.responders_did_respond_resume_turn()

View File

@ -31,6 +31,10 @@
<div v-if="!started">
<h3>{{$t("expansions")}}</h3>
<PrettyCheck @click.native="toggleExpansions('dodge_city')" :disabled="!isRoomOwner" v-model="useDodgeCity" class="p-switch p-fill" style="margin-top:5px; margin-bottom:3px;">Dodge City</PrettyCheck>
<h3>{{$t('mods')}}</h3>
<PrettyCheck @click.native="toggleCompetitive" :disabled="!isRoomOwner" v-model="is_competitive" class="p-switch p-fill" style="margin-top:5px; margin-bottom:3px;">{{$t('mod_comp')}}</PrettyCheck>
<br>
<PrettyCheck @click.native="toggleReplaceWithBot" :disabled="!isRoomOwner" v-model="disconnect_bot" class="p-switch p-fill" style="margin-top:5px; margin-bottom:3px;">{{$t('disconnect_bot')}}</PrettyCheck>
</div>
<div v-if="started">
<deck :endTurnAction="()=>{wantsToEndTurn = true}"/>
@ -85,6 +89,8 @@ export default {
password: '',
useDodgeCity: false,
hasToSetUsername: false,
is_competitive: false,
disconnect_bot: false,
}),
sockets: {
room(data) {
@ -92,6 +98,8 @@ export default {
this.started = data.started
this.password = data.password
this.privateRoom = data.password !== ''
this.is_competitive = data.is_competitive
this.disconnect_bot = data.disconnect_bot
this.useDodgeCity = data.expansions.indexOf('dodge_city') !== -1
this.players = data.players.map(x => {
return {
@ -161,6 +169,14 @@ export default {
if (!this.isRoomOwner) return;
this.$socket.emit('toggle_expansion', name)
},
toggleCompetitive() {
if (!this.isRoomOwner) return;
this.$socket.emit('toggle_comp')
},
toggleReplaceWithBot() {
if (!this.isRoomOwner) return;
this.$socket.emit('toggle_replace_with_bot')
},
getActionEmoji(p) {
if (p.is_my_turn === undefined || p.pending_action === undefined) return '';
if (p.pending_action != 4) {

View File

@ -79,5 +79,8 @@
"special_bart_cassidy": "{0} received a compensation because he was injured.",
"special_el_gringo": "{0} stole a card from {1} when he was was injured.",
"special_calamity": "{0} played {1} as Bang! against {2}."
}
},
"mods": "Modifiers",
"mod_comp": "Competitive mode (disables automatic take damage)",
"disconnect_bot": "Replace players that disconnect with bots"
}

View File

@ -79,5 +79,8 @@
"special_bart_cassidy": "{0} ha ricevuto un risarcimento perchè è stato ferito.",
"special_el_gringo": "{0} rubato una carta a {1} mentre veniva colpito.",
"special_calamity": "{0} ha giovato {1} come un Bang! contro {2}."
}
},
"mods": "Modificatori",
"mod_comp": "Modalità competitiva (disattiva il prendi danno automatico)",
"disconnect_bot": "Sostituisci i giocatori che si disconnettono con bot"
}