mirror of https://github.com/bra1n/townsquare.git
adjusted custom scripts with fabled support
added session handling for fabled
This commit is contained in:
parent
f7c8e022a3
commit
a8a87a1e38
|
@ -667,7 +667,7 @@ li.move:not(.from) .player .overlay svg.move {
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Ability text *****/
|
/***** Ability text *****/
|
||||||
#townsquare.public .ability {
|
#townsquare.public .circle .ability {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.circle .player .shroud:hover ~ .token .ability,
|
.circle .player .shroud:hover ~ .token .ability,
|
||||||
|
|
|
@ -115,6 +115,7 @@ export default {
|
||||||
this.isFabledOpen = !this.isFabledOpen;
|
this.isFabledOpen = !this.isFabledOpen;
|
||||||
},
|
},
|
||||||
removeFabled(index) {
|
removeFabled(index) {
|
||||||
|
if (this.session.isSpectator) return;
|
||||||
this.$store.commit("setFabled", { index });
|
this.$store.commit("setFabled", { index });
|
||||||
},
|
},
|
||||||
handleTrigger(playerIndex, [method, params]) {
|
handleTrigger(playerIndex, [method, params]) {
|
||||||
|
@ -427,7 +428,7 @@ export default {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fabled ul li:hover .token:before {
|
#townsquare:not(.spectator) .fabled ul li:hover .token:before {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -88,24 +88,24 @@ export default {
|
||||||
"https://gist.githubusercontent.com/bra1n/0337cc44c6fd2c44f7589256ed5486d2/raw/4a7a1545004620146f47583cde4b05f77dd9b6d2/penanceday.json"
|
"https://gist.githubusercontent.com/bra1n/0337cc44c6fd2c44f7589256ed5486d2/raw/4a7a1545004620146f47583cde4b05f77dd9b6d2/penanceday.json"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Catfishing 8.0 (+Sentinel)",
|
"Catfishing 8.0",
|
||||||
"https://gist.githubusercontent.com/bra1n/8a5ec41a7bbf945f6b7dfc1cef72b569/raw/a9451def4bb7b3c424426e9524ee94f3ac65dbf4/catfishing.json"
|
"https://gist.githubusercontent.com/bra1n/8a5ec41a7bbf945f6b7dfc1cef72b569/raw/86b2ce5293e7160530f8775b8a7118b2078fdd79/catfishing.json"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"On Thin Ice (Teensyville, +Sentinel)",
|
"On Thin Ice (Teensyville)",
|
||||||
"https://gist.githubusercontent.com/bra1n/8dacd9f2abc6f428331ea1213ab153f5/raw/9758aff4b59965dc7a094db549d950be5a26b571/custom-script.json"
|
"https://gist.githubusercontent.com/bra1n/8dacd9f2abc6f428331ea1213ab153f5/raw/0cacbcaf8ed9bddae0cca25a9ada97e9958d868b/on-thin-ice.json"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Race To The Bottom (Teensyville, +Sentinel, +Doomsayer)",
|
"Race To The Bottom (Teensyville)",
|
||||||
"https://gist.githubusercontent.com/bra1n/63e1354cb3dc9d4032bcd0623dc48888/raw/5be4df8386ec61e3a98c32be77f8cac3f8414379/custom-script.json"
|
"https://gist.githubusercontent.com/bra1n/63e1354cb3dc9d4032bcd0623dc48888/raw/5acb0eedcc0a67a64a99c7e0e6271de0b7b2e1b2/race-to-the-bottom.json"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Frankenstein's Mayor by Ted (Teensyville, +Sentinel)",
|
"Frankenstein's Mayor by Ted (Teensyville)",
|
||||||
"https://gist.githubusercontent.com/bra1n/32c52b422cc01b934a4291eeb81dbcee/raw/3ca5a043c41141ac40667dc15097deb327263268/Frankensteins_Mayor_by_Ted.json"
|
"https://gist.githubusercontent.com/bra1n/32c52b422cc01b934a4291eeb81dbcee/raw/5bf770693bbf7aff5e86601c82ca4af3222f4ba6/Frankensteins_Mayor_by_Ted.json"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Vigormortis High School (Teensyville, +Sentinel)",
|
"Vigormortis High School (Teensyville)",
|
||||||
"https://gist.githubusercontent.com/bra1n/1f65bd4a999524719d5dabe98c3c2d27/raw/f28d3268846c182b2078888122003c6f95c6b2cf/VigormortisHighSchool.json"
|
"https://gist.githubusercontent.com/bra1n/1f65bd4a999524719d5dabe98c3c2d27/raw/22bbec6bf56a51a7459e5ae41ed47e41971c5445/VigormortisHighSchool.json"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -150,14 +150,22 @@ export default {
|
||||||
},
|
},
|
||||||
parseRoles(roles) {
|
parseRoles(roles) {
|
||||||
if (!roles || !roles.length) return;
|
if (!roles || !roles.length) return;
|
||||||
this.$store.commit(
|
const customRoles = roles.map(role => {
|
||||||
"setCustomRoles",
|
|
||||||
roles.map(role => {
|
|
||||||
role.id = role.id.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
|
role.id = role.id.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
|
||||||
return role;
|
return role;
|
||||||
})
|
});
|
||||||
);
|
this.$store.commit("setCustomRoles", customRoles);
|
||||||
this.$store.commit("setEdition", "custom");
|
this.$store.commit("setEdition", "custom");
|
||||||
|
// check for fabled and set those too, if present
|
||||||
|
if (customRoles.some(({ id }) => this.$store.state.fabled.has(id))) {
|
||||||
|
const fabled = [];
|
||||||
|
customRoles.forEach(({ id }) => {
|
||||||
|
if (this.$store.state.fabled.has(id)) {
|
||||||
|
fabled.push(this.$store.state.fabled.get(id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$store.commit("setFabled", { fabled });
|
||||||
|
}
|
||||||
this.isCustom = false;
|
this.isCustom = false;
|
||||||
},
|
},
|
||||||
...mapMutations(["toggleModal", "setEdition"])
|
...mapMutations(["toggleModal", "setEdition"])
|
||||||
|
|
|
@ -38,6 +38,7 @@ export default {
|
||||||
this.$store.commit("setFabled", {
|
this.$store.commit("setFabled", {
|
||||||
fabled: role
|
fabled: role
|
||||||
});
|
});
|
||||||
|
this.$store.commit("toggleModal", "fabled");
|
||||||
},
|
},
|
||||||
...mapMutations(["toggleModal"])
|
...mapMutations(["toggleModal"])
|
||||||
}
|
}
|
||||||
|
@ -49,8 +50,8 @@ export default {
|
||||||
|
|
||||||
ul.tokens li {
|
ul.tokens li {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 6vw;
|
width: 8vw;
|
||||||
margin: 1%;
|
margin: 0.5%;
|
||||||
transition: transform 500ms ease;
|
transition: transform 500ms ease;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
@ -134,8 +134,12 @@ export default new Vuex.Store({
|
||||||
setFabled({ grimoire }, { index, fabled } = {}) {
|
setFabled({ grimoire }, { index, fabled } = {}) {
|
||||||
if (index !== undefined) {
|
if (index !== undefined) {
|
||||||
grimoire.fabled.splice(index, 1);
|
grimoire.fabled.splice(index, 1);
|
||||||
} else {
|
} else if (fabled) {
|
||||||
|
if (!Array.isArray(fabled)) {
|
||||||
grimoire.fabled.push(fabled);
|
grimoire.fabled.push(fabled);
|
||||||
|
} else {
|
||||||
|
grimoire.fabled = fabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleModal({ modals }, name) {
|
toggleModal({ modals }, name) {
|
||||||
|
|
|
@ -25,10 +25,10 @@ module.exports = store => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (localStorage.fabled !== undefined) {
|
if (localStorage.fabled !== undefined) {
|
||||||
JSON.parse(localStorage.fabled).forEach(role => {
|
|
||||||
store.commit("setFabled", {
|
store.commit("setFabled", {
|
||||||
fabled: store.state.fabled.get(role) || {}
|
fabled: JSON.parse(localStorage.fabled).map(id =>
|
||||||
});
|
store.state.fabled.get(id)
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (localStorage.players) {
|
if (localStorage.players) {
|
||||||
|
|
|
@ -92,6 +92,9 @@ class LiveSession {
|
||||||
case "edition":
|
case "edition":
|
||||||
this._updateEdition(params);
|
this._updateEdition(params);
|
||||||
break;
|
break;
|
||||||
|
case "fabled":
|
||||||
|
this._updateFabled(params);
|
||||||
|
break;
|
||||||
case "gs":
|
case "gs":
|
||||||
this._updateGamestate(params);
|
this._updateGamestate(params);
|
||||||
break;
|
break;
|
||||||
|
@ -179,6 +182,7 @@ class LiveSession {
|
||||||
}));
|
}));
|
||||||
const { session } = this._store.state;
|
const { session } = this._store.state;
|
||||||
this.sendEdition();
|
this.sendEdition();
|
||||||
|
this.sendFabled();
|
||||||
this._send("gs", {
|
this._send("gs", {
|
||||||
gamestate: this._gamestate,
|
gamestate: this._gamestate,
|
||||||
nomination: session.nomination,
|
nomination: session.nomination,
|
||||||
|
@ -272,6 +276,30 @@ class LiveSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish a fabled update. ST only
|
||||||
|
*/
|
||||||
|
sendFabled() {
|
||||||
|
if (this._isSpectator) return;
|
||||||
|
const { fabled } = this._store.state.grimoire;
|
||||||
|
this._send(
|
||||||
|
"fabled",
|
||||||
|
fabled.map(({ id }) => id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update fabled roles.
|
||||||
|
* @param fabled
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_updateFabled(fabled) {
|
||||||
|
if (!this._isSpectator) return;
|
||||||
|
this._store.commit("setFabled", {
|
||||||
|
fabled: fabled.map(id => this._store.state.fabled.get(id))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a player update.
|
* Publish a player update.
|
||||||
* @param player
|
* @param player
|
||||||
|
@ -557,6 +585,9 @@ export default store => {
|
||||||
case "setEdition":
|
case "setEdition":
|
||||||
session.sendEdition();
|
session.sendEdition();
|
||||||
break;
|
break;
|
||||||
|
case "setFabled":
|
||||||
|
session.sendFabled();
|
||||||
|
break;
|
||||||
case "players/swap":
|
case "players/swap":
|
||||||
session.swapPlayer(payload);
|
session.swapPlayer(payload);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue