mirror of https://github.com/bra1n/townsquare.git
re-enabled custom role support
This commit is contained in:
parent
ec64584da5
commit
d409186ff1
|
@ -83,6 +83,7 @@
|
|||
</template>
|
||||
|
||||
<template v-if="tab === 'session'">
|
||||
<!-- Session -->
|
||||
<li class="headline" v-if="session.sessionId">
|
||||
{{ session.isSpectator ? "Playing" : "Hosting" }}
|
||||
</li>
|
||||
|
@ -106,7 +107,10 @@
|
|||
Send Characters
|
||||
<em><font-awesome-icon icon="theater-masks"/></em>
|
||||
</li>
|
||||
<li v-if="session.isSpectator" @click="imageOptIn">
|
||||
<li
|
||||
v-if="session.isSpectator && !edition.isOfficial"
|
||||
@click="imageOptIn"
|
||||
>
|
||||
Show Custom Images
|
||||
<em
|
||||
><font-awesome-icon
|
||||
|
@ -213,7 +217,7 @@ import { mapMutations, mapState } from "vuex";
|
|||
|
||||
export default {
|
||||
computed: {
|
||||
...mapState(["grimoire", "session"]),
|
||||
...mapState(["grimoire", "session", "edition"]),
|
||||
...mapState("players", ["players"])
|
||||
},
|
||||
data() {
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
class="edition"
|
||||
:class="['edition-' + edition.id]"
|
||||
:style="{
|
||||
backgroundImage: `url(${edition.logo ||
|
||||
require('../assets/editions/' + edition.id + '.png')})`
|
||||
backgroundImage: `url(${
|
||||
edition.logo && grimoire.isImageOptIn
|
||||
? edition.logo
|
||||
: require('../assets/editions/' + edition.id + '.png')
|
||||
})`
|
||||
}"
|
||||
></li>
|
||||
<li v-if="players.length - teams.traveler < 5">
|
||||
|
|
|
@ -103,25 +103,23 @@ export default new Vuex.Store({
|
|||
},
|
||||
getters: {
|
||||
/**
|
||||
* Return all custom roles, with default values stripped.
|
||||
* Return all custom roles, with default values and non-essential data stripped.
|
||||
* @param roles
|
||||
* @returns {[]}
|
||||
*/
|
||||
customRoles: ({ roles }) => {
|
||||
customRolesStripped: ({ roles }) => {
|
||||
const customRoles = [];
|
||||
const strippedProps = ["firstNightReminder", "otherNightReminder"]
|
||||
roles.forEach(role => {
|
||||
if (!role.isCustom) {
|
||||
customRoles.push({ id: role.id });
|
||||
} else {
|
||||
const strippedRole = {};
|
||||
for (let prop in role) {
|
||||
const value = role[prop];
|
||||
if (
|
||||
prop === "image" &&
|
||||
value.toLocaleLowerCase().includes(imageBase)
|
||||
) {
|
||||
if (strippedProps.includes(prop)) {
|
||||
continue;
|
||||
}
|
||||
const value = role[prop];
|
||||
if (prop !== "isCustom" && value !== customRole[prop]) {
|
||||
strippedRole[prop] = value;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ module.exports = store => {
|
|||
} else {
|
||||
localStorage.setItem(
|
||||
"roles",
|
||||
JSON.stringify(store.getters.customRoles)
|
||||
JSON.stringify(payload)
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -354,12 +354,10 @@ class LiveSession {
|
|||
const { edition } = this._store.state;
|
||||
let roles;
|
||||
if (!edition.isOfficial) {
|
||||
roles = Array.from(this._store.state.roles.keys());
|
||||
roles = this._store.getters.customRolesStripped;
|
||||
}
|
||||
this._sendDirect(playerId, "edition", {
|
||||
edition: edition.isOfficial
|
||||
? { id: edition.id }
|
||||
: Object.assign({}, edition, { logo: "" }),
|
||||
edition: edition.isOfficial ? { id: edition.id } : edition,
|
||||
...(roles ? { roles } : {})
|
||||
});
|
||||
}
|
||||
|
@ -374,10 +372,7 @@ class LiveSession {
|
|||
if (!this._isSpectator) return;
|
||||
this._store.commit("setEdition", edition);
|
||||
if (roles) {
|
||||
this._store.commit(
|
||||
"setCustomRoles",
|
||||
roles.map(id => ({ id }))
|
||||
);
|
||||
this._store.commit("setCustomRoles", roles);
|
||||
if (this._store.state.roles.size !== roles.length) {
|
||||
const missing = [];
|
||||
roles.forEach(id => {
|
||||
|
|
Loading…
Reference in New Issue