fix found bugs

This commit is contained in:
Alberto Xamin 2023-01-06 18:38:57 +00:00
parent 352f7f006f
commit 96edc77efe
6 changed files with 43 additions and 10 deletions

View File

@ -353,7 +353,7 @@ class Game:
def can_card_reach(self, card: cs.Card, player: pl.Player, target:str):
if card and card.range != 0 and card.range < 99:
return not any((True for p in self.get_visible_players(player) if p['name'] == target and p['dist'] >= card.range))
return not any((True for p in self.get_visible_players(player) if p['name'] == target and p['dist'] > card.range))
return True
def attack(self, attacker: pl.Player, target_username:str, double:bool=False, card_name:str=None):

View File

@ -609,7 +609,7 @@ class Player:
self.game.next_player().equipment.append(self.equipment.pop(i))
self.game.next_player().notify_self()
break
if any((isinstance(c, cs.Dinamite) or isinstance(c, cs.Prigione) for c in self.equipment)):
if any((isinstance(c, cs.Dinamite) or isinstance(c, cs.Prigione) or isinstance(self.equipment[i], tvosc.SerpenteASonagli) for c in self.equipment)):
self.notify_self()
return
for i in range(len(self.equipment)):
@ -638,11 +638,12 @@ class Player:
print(f'Did pick {picked}')
self.sio.emit('chat_message', room=self.game.name,
data=f'_flipped|{self.name}|{picked.name}|{picked.num_suit()}')
if picked.check_suit(self.game, [cs.Suit.SPADES]) and pickable_cards == 0:
if not picked.check_suit(self.game, [cs.Suit.SPADES]):
break
elif pickable_cards == 0:
self.lives -= 1
self.sio.emit('chat_message', room=self.game.name, data=f'_snake_bit|{self.name}')
self.end_turn(forced=True)
return
break
if any((isinstance(c, cs.Prigione) for c in self.equipment)):
self.notify_self()
return

View File

@ -73,7 +73,7 @@ def report(sid, text):
data = "\n".join(ses.game.rpc_log[:-1]).strip()
data = data +"\n@@@\n" +text
#print(data)
response = requests.post("https://hastebin.com/documents", data)
response = requests.post("https://hastebin.com/documents", data.encode('utf-8'))
key = json.loads(response.text).get('key')
if "DISCORD_WEBHOOK" in os.environ and len(os.environ['DISCORD_WEBHOOK']) > 0:
webhook = DiscordWebhook(url=os.environ['DISCORD_WEBHOOK'], content=f'New bug report, replay at https://bang.xamin.it/game?replay={key}')
@ -546,6 +546,16 @@ def chat_message(sid, msg, pl=None):
for cn in card_names:
ses.hand.append([c for c in cards if c.name.lower() == cn.lower() or c.name[0:-1].lower() == cn.lower()][0])
ses.notify_self()
elif '/equipcard' in msg:
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and got a card'})
import bang.cards as cs
cmd = msg.split()
if len(cmd) >= 2:
cards = cs.get_starting_deck(ses.game.expansions)
card_names = ' '.join(cmd[1:]).split(',')
for cn in card_names:
ses.equipment.append([c for c in cards if c.name.lower() == cn.lower() or c.name[0:-1].lower() == cn.lower()][0])
ses.notify_self()
elif '/getset' in msg:
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and got a card'})
cmd = msg.split()

View File

@ -6,6 +6,7 @@
<Card v-for="(c, i) in cards" v-bind:key="c.name ? (c.name+c.number) : i" :card="c" @click.native="select(c)" @pointerenter.native="showDesc(c)" @pointerleave.native="desc=''"/>
</transition-group>
</div>
<h2 v-if="timer > 0 && remainingTime > 0">{{remainingTime}}</h2>
<p v-if="hintText">{{hintText}}</p>
<div style="margin-top:6pt;" class="button center-stuff" v-if="showCancelBtn" @click="cancel"><span>{{realCancelText}}</span></div>
<p v-if="desc" style="bottom:10pt;right:0;left:0;position:absolute;margin:16pt;font-size:18pt">{{desc}}</p>
@ -29,13 +30,19 @@ export default {
type: String,
default: '',
},
timer: {
type: Number,
default: 0,
},
text: String,
hintText: String,
playAudio: Boolean,
},
data: () => ({
desc: '',
realCancelText: ''
realCancelText: '',
remainingTime: 0,
intervalID: '',
}),
computed: {
showCancelBtn() {
@ -57,6 +64,14 @@ export default {
this.desc = (this.$i18n.locale=='it'?card.desc:card.desc_eng)
else
this.desc = this.$t(`cards.${card.name}.desc`)
},
countDown() {
if (this.remainingTime > 0) {
this.remainingTime--;
} else {
this.select(this.cards[0]);
window.clearInterval(this.intervalID);
}
}
},
mounted() {
@ -70,6 +85,12 @@ export default {
if (this.playAudio) {
(new Audio(show_sfx)).play();
}
if (this.timer > 0) {
this.remainingTime = this.timer;
this.intervalID = window.setInterval(() => {
this.countDown();
}, 1000);
}
},
}
</script>

View File

@ -169,6 +169,7 @@ export default {
this.username = data.username
this.didSetUsername = true
this.discordPic = `https://cdn.discordapp.com/avatars/${data.id}/${data.avatar}.png`
localStorage.setItem('username', this.username)
this.$socket.emit('set_username', {name: this.username, discord_token: localStorage.getItem('discord_token')})
}).catch(err => {
console.error(err)

View File

@ -49,15 +49,15 @@
</transition>
<Chooser v-if="is_my_turn && pending_action == 4 && (lives > 0 || is_ghost) && !(emporioCards && emporioCards.cards && emporioCards.cards.length > 0)" :text="$t('wait')" :cards="[]"/>
<Chooser v-if="card_against" :text="$t('card_against')" :hint-text="visiblePlayers.length === 0 ? $t('no_players_in_range'):''" :cards="visiblePlayers" :select="selectAgainst" :cancel="card_against.number !== 42 ? cancelCardAgainst : null"/>
<Chooser v-if="pending_action == 3" :text="respondText" :cards="respondCards" :select="respond" :playAudio="true"/>
<Chooser v-if="shouldChooseCard" :text="$t(choose_text)" :cards="available_cards" :select="choose" :playAudio="true"/>
<Chooser v-if="pending_action == 3" :text="respondText" :cards="respondCards" :select="respond" :playAudio="true" :timer="60"/>
<Chooser v-if="shouldChooseCard" :text="$t(choose_text)" :cards="available_cards" :select="choose" :playAudio="true" :timer="60"/>
<Chooser v-if="lives <= 0 && max_lives > 0 && !is_ghost && !spectator" :text="$t('you_died')" :cancelText="$t('spectate')" :cancel="()=>{max_lives = 0; spectator = true}"/>
<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"/>
<Chooser v-if="cantplaycard" :key="cantplaycard" :text="`${$t('cantplaycard')}`" class="turn-notify-4s"/>
<Chooser v-if="!show_role && is_my_turn && pending_action < 2" :text="$t('play_your_turn')" :key="is_my_turn" class="turn-notify" />
<Chooser v-if="!show_role && availableCharacters.length > 0" :text="$t('choose_character')" :cards="availableCharacters" :select="setCharacter"/>
<Chooser v-if="!show_role && availableCharacters.length > 0" :text="$t('choose_character')" :cards="availableCharacters" :select="setCharacter" :timer="60"/>
<Chooser v-if="hasToPickResponse" :playAudio="true" :text="`${$t('pick_a_card')} ${attacker?($t('to_defend_from')+' '+attacker):''}`" :key="hasToPickResponse" class="turn-notify" />
<Chooser v-if="!card_against && card_with" :text="`${$t('choose_scarp_card_to')} ${card_with.name.toUpperCase()}`" :cards="handComputed.filter(x => x !== card_with)" :select="selectWith" :cancel="()=>{card_with = null}"/>
<Chooser v-if="showScrapScreen" :text="`${$t('discard')} ${hand.length}/${maxHandLength()}`" :cards="hand" :select="scrap" :cancel="cancelEndingTurn"/>