Merge branch 'dev' into main

This commit is contained in:
Giulio 2022-03-11 10:42:18 +01:00
commit 594e74e111
7 changed files with 69 additions and 22 deletions

View File

@ -80,8 +80,10 @@ class Game:
self.is_hidden = True
self.is_replay = True
self.replay_speed = 1
for i in range(len(log)):
print('replay:', i, 'of', len(log))
for i in range(len(log)-1):
print('replay:', i, 'of', len(log)-3, '->', log[i])
if (log[i] == "@@@"):
break
cmd = log[i].split(';')
if cmd[1] == 'players':
self.expansions = json.loads(cmd[4].replace("'",'"'))

View File

@ -57,6 +57,24 @@ def get_online_players(sid):
global online_players
sio.emit('players', room='lobby', data=online_players)
@sio.event
def report(sid, text):
ses: Player = sio.get_session(sid)
data=''
if hasattr(ses, 'game'):
data = "\n".join(ses.game.rpc_log[:-1]).strip()
data = data +"\n@@@\n" +text
#print(data)
response = requests.post("https://www.toptal.com/developers/hastebin/documents", data)
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://www.toptal.com/developers/hastebin/{key}')
response = webhook.execute()
sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'})
else:
print("WARNING: DISCORD_WEBHOOK not found")
print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}')
@sio.event
def set_username(sid, username):
ses = sio.get_session(sid)
@ -337,18 +355,6 @@ def chat_message(sid, msg, pl=None):
ses.game.add_player(bot)
bot.bot_spin()
return
if '/report' in msg and not ses.game.is_replay:
data = "\n".join(ses.game.rpc_log[:-1]).strip()
response = requests.post("https://www.toptal.com/developers/hastebin/documents", data)
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://www.toptal.com/developers/hastebin/{key}')
response = webhook.execute()
sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'})
else:
print("WARNING: DISCORD_WEBHOOK not found")
print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}')
return
if '/replay' in msg and not '/replayspeed' in msg:
_cmd = msg.split()
if len(_cmd) == 2:

View File

@ -9,6 +9,7 @@
</div>
<help v-if="showHelp"/>
<div style="position:fixed;bottom:4pt;right:4pt;display:flex;">
<input type=button class="btn" style="min-width:28pt;cursor:pointer;" @click="()=>{sending_report = true}" :value=" $t('report') " />
<input type="button" class="btn" value="Discord" style="min-width:28pt;cursor:pointer;" @click="joinDiscord"/>
<input type="button" class="btn" :value="(showHelp?'X':'?')" style="min-width:28pt;border-radius:100%;cursor:pointer;" @click="getHelp"/>
<select id="theme" class="btn" v-model="theme">
@ -38,15 +39,19 @@
<button @click="showUpdateUI = false">Cancel</button>
</div>
</div>
<transition name="bounce">
<full-screen-input v-if="sending_report" :defaultValue="''" :text="$t('report_bug')" :val="report" :cancel="cancelReport" :send="sendReport" :canCancel="true"/>
</transition>
</div>
</template>
<script>
import FullScreenInput from './components/FullScreenInput.vue'
import Help from './components/Help.vue';
// import Vue from 'vue'
export default {
components: { Help },
components: { Help, FullScreenInput },
name: 'App',
data: () => ({
isConnected: false,
@ -54,6 +59,8 @@ export default {
showUpdateUI: false,
showHelp:false,
theme: 'light',
report: '',
sending_report: false,
}),
computed: {
},
@ -99,7 +106,16 @@ export default {
},
joinDiscord() {
window.open('https://discord.gg/Dr58dZ2na8', '_blank');
}
},
cancelReport(){
this.sending_report = false
},
sendReport(text){
if (text.trim().length > 0){
this.sending_report = false
this.$socket.emit('report', text)
}
},
},
watch: {
theme() {

View File

@ -5,7 +5,10 @@
<input v-model="val" class="chooserInput"/>
</form>
<p v-if="hintText">{{hintText}}</p>
<div style="margin-top:6pt;" class="button center-stuff" v-if="showCancelBtn && val" @click="cancel(val)"><span>{{realCancelText}}</span></div>
<div class="center-stuff">
<div style="margin-top:6pt;margin-right:6pt;" class="button center-stuff" v-if="canCancel" @click="cancel()"><span>{{realCancelText}}</span></div>
<div style="margin-top:6pt;margin-left:6pt;" class="button center-stuff" v-if="showSendBtn && val" @click="send(val)"><span>{{realSendText}}</span></div>
</div>
</div>
</template>
@ -14,21 +17,31 @@ export default {
name: 'FullScreenInput',
props: {
cancel: Function,
send: Function,
defaultValue: String,
cancelText: {
type: String,
default: '',
},
sendText: {
type: String,
default: '',
},
text: String,
hintText: String,
canCancel: {
type: Boolean,
default: false,
},
},
data: () => ({
val: '',
realCancelText: ''
realCancelText: '',
realSendText: ''
}),
computed: {
showCancelBtn() {
if (this.cancel)
showSendBtn() {
if (this.send)
return true
return false
}
@ -36,15 +49,19 @@ export default {
methods: {
submit(e) {
e.preventDefault();
this.cancel(this.val);
this.send(this.val);
}
},
mounted() {
this.realCancelText = this.cancelText
this.realSendText = this.sendText
this.val = this.defaultValue
if (this.realCancelText == '') {
this.realCancelText = this.$t('cancel')
}
if (this.realSendText == '') {
this.realSendText = this.$t('send')
}
},
}
</script>

View File

@ -80,7 +80,7 @@
<Chooser v-show="hasToChoose" :text="`${$t('choose_card')}${target_p?$t('choose_card_from') + target_p:''}`" :cards="chooseCards" :select="chooseCard"/>
</transition>
<transition name="bounce">
<full-screen-input v-if="!started && hasToSetUsername" :defaultValue="storedUsername" :text="$t('choose_username')" :val="username" :cancel="setUsername" :cancelText="$t('ok')"/>
<full-screen-input v-if="!started && hasToSetUsername" :defaultValue="storedUsername" :text="$t('choose_username')" :val="username" :send="setUsername" :sendText="$t('ok')"/>
</transition>
</div>
</template>

View File

@ -10,6 +10,8 @@
"tip_8": "If you disconnect during in an ongoing game you will be replaced by a bot (while you are gone)!",
"online_players": "Online players: ",
"choose_username": "Pick an username:",
"report_bug":"Write what the bug consists of",
"report":"Report a bug",
"available_lobbies": "Available Lobbies:",
"spectate_lobbies": "Spectate ongoing games:",
"no_lobby_available": "No lobbies available",
@ -26,6 +28,7 @@
"you": "YOU",
"owner": "OWNER",
"cancel": "CANCEL",
"send": "SEND",
"password": "Password: ",
"room_password_prompt": "Lobby Password: ",
"private_room": "Private Lobby",

View File

@ -10,6 +10,8 @@
"tip_8": "Se ti disconnetti durante una partita verrai sostituito da un bot (durante la tua assenza)!",
"online_players": "Giocatori online: ",
"choose_username": "Scegli un username:",
"report_bug":"Scrivi in cosa consiste il bug",
"report":"Segnala un bug",
"available_lobbies": "Stanze disponibili:",
"spectate_lobbies": "Osserva le partite in corso:",
"no_lobby_available": "Nessuna stanza disponibile",
@ -26,6 +28,7 @@
"you": "TU",
"owner": "GESTORE",
"cancel": "ANNULLA",
"send": "INVIA",
"password": "Password: ",
"room_password_prompt": "Password Stanza: ",
"private_room": "Stanza Privata",