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