add event desc to chat

This commit is contained in:
Alberto Xamin 2023-04-09 10:44:22 +01:00
parent c81a806a6b
commit 475972bf05
No known key found for this signature in database
GPG Key ID: 5ABFCD8A22EA6F5D
2 changed files with 10 additions and 3 deletions

View File

@ -77,13 +77,19 @@ export default {
msg = msg.text msg = msg.text
} }
let desc = undefined let desc = undefined
let desc_pos = -1
let params = msg.split('|') let params = msg.split('|')
let type = params.shift().substring(1) let type = params.shift().substring(1)
if (["flipped", "respond", "play_card", "play_card_against", "play_card_for", "spilled_beer", "diligenza", "wellsfargo", "saloon", "special_calamity", "won", "choose_emporio", "died_role"].indexOf(type) !== -1) { if (["flipped", "respond", "play_card", "play_card_against", "play_card_for", "spilled_beer", "diligenza", "wellsfargo", "saloon", "special_calamity", "won", "choose_emporio", "died_role"].indexOf(type) !== -1) {
desc = this.$t(`cards.${params[1]}.desc`) desc = this.$t(`cards.${params[1]}.desc`)
desc_pos = 3
params[1] = this.$t(`cards.${params[1]}.name`) params[1] = this.$t(`cards.${params[1]}.name`)
} else if (type === "choose_character"){ } else if (type === "choose_character"){
params.push(this.$t(`cards.${params[1]}.desc`)) params.push(this.$t(`cards.${params[1]}.desc`))
} else if (type === "flip_event"){
desc = this.$t(`cards.${params[0]}.desc`)
params[0] = this.$t(`cards.${params[0]}.name`);
desc_pos = 1
} else if (type === "allroles") { } else if (type === "allroles") {
params.forEach((p,i)=>{ params.forEach((p,i)=>{
if (i%2 === 0) { if (i%2 === 0) {
@ -96,10 +102,11 @@ export default {
type += "4" type += "4"
} }
} }
let parts = this.$t(`chat.${type}`, params).split(';').map((x, i)=>({text:x, desc:(i===desc_pos&&desc?desc:null)}))
if (t_color != null) { if (t_color != null) {
this.messages.push({color:t_color, bgcolor: bg_color, text:false, parts:this.$t(`chat.${type}`, params).split(';').map(x=>({text:x}))}); this.messages.push({color:t_color, bgcolor: bg_color, text:false, parts: parts})
} else { } else {
this.messages.push({text:false, parts: this.$t(`chat.${type}`, params).split(';').map((x, i)=>({text:x, desc:(i===3&&desc?desc:null)}))}); this.messages.push({text:false, parts: parts});
} }
if (type == 'turn' && params[0] == this.username) { if (type == 'turn' && params[0] == this.username) {
this.playEffects(turn_sfx); this.playEffects(turn_sfx);

View File

@ -124,7 +124,7 @@
"spilled_beer": ";{0}; spilled a ;{1};.", "spilled_beer": ";{0}; spilled a ;{1};.",
"diligenza": ";{0}; played ;{1}; and draws 2 cards.", "diligenza": ";{0}; played ;{1}; and draws 2 cards.",
"wellsfargo": ";{0}; played ;{1}; and draws 3 cards.", "wellsfargo": ";{0}; played ;{1}; and draws 3 cards.",
"saloon": ";{0}; player ;{1}; and heals 1 HP to everyone alive.", "saloon": ";{0}; played ;{1}; and heals 1 HP to everyone alive.",
"special_bart_cassidy": ";{0}; received a compensation because he was injured.", "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_el_gringo": ";{0}; stole a card from ;{1}; when he was was injured.",
"special_calamity": ";{0}; played ;{1}; as Bang! against ;{2};.", "special_calamity": ";{0}; played ;{1}; as Bang! against ;{2};.",