Merge branch 'develop' into on_block

This commit is contained in:
nicfreeman1209 2021-05-09 21:18:41 +01:00 committed by GitHub
commit 5937209b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 561 additions and 664 deletions

View File

@ -4,6 +4,7 @@ on:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
- develop
jobs:
build:
name: Check Actions

View File

@ -13,10 +13,10 @@ name: "CodeQL"
on:
push:
branches: [ main ]
branches: [ main, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [ main, develop ]
schedule:
- cron: '27 22 * * 1'

View File

@ -1,53 +1,20 @@
---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore:
- 'gh-pages'
branches: [ main, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [ main, develop ]
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
- run: npm run lint
################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: docker://github/super-linter:v2.2.0
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_ANSIBLE: false
DEFAULT_BRANCH: "main"

View File

@ -1,11 +1,19 @@
# Release Notes
- add 'on the block' indicator
- fix players being moved or removed during nomination
- add vue linter
- use "Exile" rather than "Banishment" for exiles
- added global animation toggle for better performance
- added record vote history toggle to session menu, and clear vote history button
- add support for custom Fabled characters
---
### Version 2.12.0
- tweak reference sheet to better fit screen in single column layout
- add warning icon overlay for setup roles on character assignment modal
- added Heretic and Marionette plus King and Choirboy to list of available characters
- added Heretic and Marionette plus King/Choirboy and the Gangster to list of available characters
---

View File

@ -19,6 +19,9 @@ Before submitting your contribution, please make sure to take a moment and read
- The `main` branch is what is currently deployed to the website. All development should be done in dedicated branches.
- The `develop` branch contains the changes that will be deployed to main next. In order to prepare a release, development
branches should have their Pull Request against `develop` and only releases should be merged from `develop` into `main`.
- Work in the `src` folder and **DO NOT** checkin `dist` in the commits.
- It's OK to have multiple small commits as you work on the PR - GitHub will automatically squash it before merging.
@ -30,6 +33,9 @@ Before submitting your contribution, please make sure to take a moment and read
- If fixing a bug:
- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`.
- Provide a detailed description of the bug in the PR. Live demo preferred.
- You'll need to update the `CHANGELOG.md` with a description of your changes before you open a pull request and your code
should pass the lint check.
## Development Setup

View File

@ -96,7 +96,8 @@ For base game characters, it is sufficient to only provide the ID, similar to wh
- **remindersGlobal**: global reminder tokens that will always be available, no matter if the character is assigned to a player or not
- **setup**: whether this token affects setup (orange leaf), like the Drunk or Baron
- **name**: the displayed name of this character
- **team**: the team of the character, has to be one of `townsfolk`, `outsider`, `minion`, `demon` or `traveler`
- **team**: the team of the character, has to be one of `townsfolk`, `outsider`, `minion`, `demon`, `traveler` or `fabled`<br>
_Note_: if you create a custom Fabled character, it will be automatically added to the game when the custom script is loaded
- **ability**: the displayed ability text of the character
## [Code of Conduct](CODE_OF_CONDUCT.md)

807
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build ./src/main.js",
"lint": "vue-cli-service lint"
"lint": "vue-cli-service lint --no-fix --max-warnings=0"
},
"main": "App.vue",
"dependencies": {

View File

@ -3,7 +3,10 @@
id="app"
@keyup="keyup"
tabindex="-1"
:class="{ night: grimoire.isNight }"
:class="{
night: grimoire.isNight,
static: grimoire.isStatic
}"
:style="{
backgroundImage: grimoire.background
? `url('${grimoire.background}')`
@ -110,7 +113,7 @@ export default {
this.$store.commit("toggleModal", "roles");
break;
case "v":
if (this.session.voteHistory.length) {
if (this.session.voteHistory.length || !this.session.isSpectator) {
this.$store.commit("toggleModal", "voteHistory");
}
break;
@ -202,6 +205,14 @@ ul {
align-items: center;
align-content: center;
justify-content: center;
// disable all animations
&.static *,
&.static *:after,
&.static *:before {
transition: none !important;
animation: none !important;
}
}
#version {

BIN
src/assets/icons/fabled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View File

@ -60,13 +60,14 @@
</li>
<li @click="toggleNightOrder" v-if="players.length">
Night order
<em
><font-awesome-icon
<em>
<font-awesome-icon
:icon="[
'fas',
grimoire.isNightOrder ? 'check-square' : 'square'
]"
/></em>
/>
</em>
</li>
<li v-if="players.length">
Zoom
@ -82,6 +83,10 @@
/>
</em>
</li>
<li @click="setBackground">
Background image
<em><font-awesome-icon icon="image"/></em>
</li>
<li v-if="!edition.isOfficial" @click="imageOptIn">
<small>Show Custom Images</small>
<em
@ -92,9 +97,12 @@
]"
/></em>
</li>
<li @click="setBackground">
Background image
<em><font-awesome-icon icon="image"/></em>
<li @click="toggleStatic">
Disable Animations
<em
><font-awesome-icon
:icon="['fas', grimoire.isStatic ? 'check-square' : 'square']"
/></em>
</li>
<li @click="toggleMuted">
Mute Sounds
@ -131,10 +139,10 @@
<em><font-awesome-icon icon="theater-masks"/></em>
</li>
<li
v-if="session.voteHistory.length"
v-if="session.voteHistory.length || !session.isSpectator"
@click="toggleModal('voteHistory')"
>
Nomination history<em>[V]</em>
Vote history<em>[V]</em>
</li>
<li @click="leaveSession">
Leave Session
@ -319,6 +327,10 @@ export default {
clearPlayers() {
if (this.session.isSpectator) return;
if (confirm("Are you sure you want to remove all players?")) {
// abort vote if in progress
if (this.session.nomination) {
this.$store.commit("session/nomination");
}
this.$store.commit("players/clear");
}
},
@ -339,6 +351,7 @@ export default {
"toggleImageOptIn",
"toggleMuted",
"toggleNightOrder",
"toggleStatic",
"setZoom",
"toggleModal"
])

View File

@ -132,15 +132,15 @@
<li @click="changeName">
<font-awesome-icon icon="user-edit" />Rename
</li>
<li @click="movePlayer()">
<li @click="movePlayer()" :class="{ disabled: session.lockedVote }">
<font-awesome-icon icon="redo-alt" />
Move player
</li>
<li @click="swapPlayer()">
<li @click="swapPlayer()" :class="{ disabled: session.lockedVote }">
<font-awesome-icon icon="exchange-alt" />
Swap seats
</li>
<li @click="removePlayer">
<li @click="removePlayer" :class="{ disabled: session.lockedVote }">
<font-awesome-icon icon="times-circle" />
Remove
</li>
@ -786,7 +786,8 @@ li.move:not(.from) .player .overlay svg.move {
}
li.disabled {
cursor: default;
cursor: not-allowed;
opacity: 0.5;
&:hover {
color: white;
}

View File

@ -152,20 +152,52 @@ export default {
this.$store.commit("toggleModal", "role");
},
removePlayer(playerIndex) {
if (this.session.isSpectator) return;
if (this.session.isSpectator || this.session.lockedVote) return;
if (
confirm(
`Do you really want to remove ${this.players[playerIndex].name}?`
)
) {
const { nomination } = this.session;
if (nomination) {
if (nomination.includes(playerIndex)) {
// abort vote if removed player is either nominator or nominee
this.$store.commit("session/nomination");
} else if (
nomination[0] > playerIndex ||
nomination[1] > playerIndex
) {
// update nomination array if removed player has lower index
this.$store.commit("session/setNomination", [
nomination[0] > playerIndex ? nomination[0] - 1 : nomination[0],
nomination[1] > playerIndex ? nomination[1] - 1 : nomination[1]
]);
}
}
this.$store.commit("players/remove", playerIndex);
}
},
swapPlayer(from, to) {
if (this.session.isSpectator || this.session.lockedVote) return;
if (to === undefined) {
this.cancel();
this.swap = from;
} else {
if (this.session.nomination) {
// update nomination if one of the involved players is swapped
const swapTo = this.players.indexOf(to);
const updatedNomination = this.session.nomination.map(nom => {
if (nom === this.swap) return swapTo;
if (nom === swapTo) return this.swap;
return nom;
});
if (
this.session.nomination[0] !== updatedNomination[0] ||
this.session.nomination[1] !== updatedNomination[1]
) {
this.$store.commit("session/setNomination", updatedNomination);
}
}
this.$store.commit("players/swap", [
this.swap,
this.players.indexOf(to)
@ -174,10 +206,27 @@ export default {
}
},
movePlayer(from, to) {
if (this.session.isSpectator || this.session.lockedVote) return;
if (to === undefined) {
this.cancel();
this.move = from;
} else {
if (this.session.nomination) {
// update nomination if it is affected by the move
const moveTo = this.players.indexOf(to);
const updatedNomination = this.session.nomination.map(nom => {
if (nom === this.move) return moveTo;
if (nom > this.move && nom <= moveTo) return nom - 1;
if (nom < this.move && nom >= moveTo) return nom + 1;
return nom;
});
if (
this.session.nomination[0] !== updatedNomination[0] ||
this.session.nomination[1] !== updatedNomination[1]
) {
this.$store.commit("session/setNomination", updatedNomination);
}
}
this.$store.commit("players/move", [
this.move,
this.players.indexOf(to)
@ -186,6 +235,7 @@ export default {
}
},
nominatePlayer(from, to) {
if (this.session.isSpectator || this.session.lockedVote) return;
if (to === undefined) {
this.cancel();
if (from !== this.nominate) {

View File

@ -135,7 +135,7 @@ export default {
const nomination = this.session.nomination[0];
return {
transform: `rotate(${Math.round((nomination / players) * 360)}deg)`,
transitionDuration: this.session.votingSpeed - 0.1 + "s"
transitionDuration: this.session.votingSpeed - 100 + "ms"
};
},
nominee: function() {

View File

@ -115,6 +115,7 @@ export default {
.maximized {
background: rgba(0, 0, 0, 0.95);
padding: 0;
border-radius: 0;
height: 100%;
width: 100%;
max-width: 100%;

View File

@ -1,17 +1,36 @@
<template>
<Modal
class="vote-history"
v-if="modals.voteHistory && session.voteHistory"
v-if="modals.voteHistory && (session.voteHistory || !session.isSpectator)"
@close="toggleModal('voteHistory')"
>
<font-awesome-icon
@click="clearVoteHistory"
icon="trash-alt"
class="clear"
title="Clear history"
title="Clear vote history"
v-if="session.isSpectator"
/>
<h3>Nomination history</h3>
<h3>Vote history</h3>
<template v-if="!session.isSpectator">
<div class="options">
<div class="option" @click="setRecordVoteHistory">
<font-awesome-icon
:icon="[
'fas',
session.isVoteHistoryAllowed ? 'check-square' : 'square'
]"
/>
Accessible to players
</div>
<div class="option" @click="clearVoteHistory">
<font-awesome-icon icon="trash-alt" />
Clear for everyone
</div>
</div>
</template>
<table>
<thead>
<tr>
@ -79,8 +98,16 @@ export default {
...mapState(["session", "modals"])
},
methods: {
...mapMutations(["toggleModal"]),
...mapMutations("session", ["clearVoteHistory"])
clearVoteHistory() {
this.$store.commit("session/clearVoteHistory");
},
setRecordVoteHistory() {
this.$store.commit(
"session/setVoteHistoryAllowed",
!this.session.isVoteHistoryAllowed
);
},
...mapMutations(["toggleModal"])
}
};
</script>
@ -98,6 +125,24 @@ export default {
}
}
.options {
display: flex;
justify-content: center;
align-items: center;
justify-content: center;
align-content: center;
}
.option {
color: white;
text-decoration: none;
margin: 0 15px;
&:hover {
color: red;
cursor: pointer;
}
}
h3 {
margin: 0 40px 0 10px;
svg {

View File

@ -1484,6 +1484,19 @@
"Good player executed"],
"setup": false,
"ability": "If more than 1 good player is executed, you win. All players know you are in play. After day 5, evil wins."
},
{
"id": "gangster",
"name": "Gangster",
"edition": "",
"team": "traveler",
"firstNight": 0,
"firstNightReminder": "",
"otherNight": 0,
"otherNightReminder": "",
"reminders": [],
"setup": false,
"ability": "Once per day, you may choose to kill a living neighbour, if your other living neighbour agrees."
}
]

View File

@ -81,6 +81,7 @@ export default new Vuex.Store({
isNightOrder: true,
isPublic: true,
isMenuOpen: false,
isStatic: false,
isMuted: false,
isImageOptIn: false,
zoom: 0,
@ -144,6 +145,7 @@ export default new Vuex.Store({
toggleMuted: toggle("isMuted"),
toggleMenu: toggle("isMenuOpen"),
toggleNightOrder: toggle("isNightOrder"),
toggleStatic: toggle("isStatic"),
toggleNight: toggle("isNight"),
toggleGrimoire: toggle("isPublic"),
toggleImageOptIn: toggle("isImageOptIn"),
@ -162,54 +164,62 @@ export default new Vuex.Store({
* @param roles Array of role IDs or full role definitions
*/
setCustomRoles(state, roles) {
state.roles = new Map(
roles
// replace numerical role object keys with matching key names
.map(role => {
if (role[0]) {
const customKeys = Object.keys(customRole);
const mappedRole = {};
for (let prop in role) {
if (customKeys[prop]) {
mappedRole[customKeys[prop]] = role[prop];
}
const processedRoles = roles
// replace numerical role object keys with matching key names
.map(role => {
if (role[0]) {
const customKeys = Object.keys(customRole);
const mappedRole = {};
for (let prop in role) {
if (customKeys[prop]) {
mappedRole[customKeys[prop]] = role[prop];
}
return mappedRole;
} else {
return role;
}
})
// clean up role.id
.map(role => {
role.id = role.id.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
return mappedRole;
} else {
return role;
})
// map existing roles to base definition or pre-populate custom roles to ensure all properties
.map(
role =>
rolesJSONbyId.get(role.id) ||
state.roles.get(role.id) ||
Object.assign({}, customRole, role)
)
// default empty icons and placeholders
.map(role => {
if (rolesJSONbyId.get(role.id)) return role;
role.imageAlt = // map team to generic icon
{
townsfolk: "good",
outsider: "outsider",
minion: "minion",
demon: "evil"
}[role.team] || "custom";
return role;
})
// filter out roles that don't match an existing role and also don't have name/ability/team
.filter(role => role.name && role.ability && role.team)
// sort by team
.sort((a, b) => b.team.localeCompare(a.team))
// convert to Map
}
})
// clean up role.id
.map(role => {
role.id = role.id.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
return role;
})
// map existing roles to base definition or pre-populate custom roles to ensure all properties
.map(
role =>
rolesJSONbyId.get(role.id) ||
state.roles.get(role.id) ||
Object.assign({}, customRole, role)
)
// default empty icons and placeholders
.map(role => {
if (rolesJSONbyId.get(role.id)) return role;
role.imageAlt = // map team to generic icon
{
townsfolk: "good",
outsider: "outsider",
minion: "minion",
demon: "evil",
fabled: "fabled"
}[role.team] || "custom";
return role;
})
// filter out roles that don't match an existing role and also don't have name/ability/team
.filter(role => role.name && role.ability && role.team)
// sort by team
.sort((a, b) => b.team.localeCompare(a.team));
// convert to Map without Fabled
state.roles = new Map(
processedRoles
.filter(role => role.team !== "fabled")
.map(role => [role.id, role])
);
// update Fabled to include custom Fabled from this script
state.fabled = new Map([
...processedRoles.filter(r => r.team === "fabled").map(r => [r.id, r]),
...fabledJSON.map(role => [role.id, role])
]);
// update extraTravelers map to only show travelers not in this script
state.otherTravelers = new Map(
rolesJSON

View File

@ -26,6 +26,7 @@ const state = () => ({
isVoteInProgress: false,
voteHistory: [],
markedPlayerId: -1,
isVoteHistoryAllowed: true,
isRolesDistributed: false
});
@ -47,6 +48,8 @@ const mutations = {
setVotingSpeed: set("votingSpeed"),
setVoteInProgress: set("isVoteInProgress"),
setMarkedPlayerId: set("markedPlayerId"),
setNomination: set("nomination"),
setVoteHistoryAllowed: set("isVoteHistoryAllowed"),
claimSeat: set("claimedSeat"),
distributeRoles: set("isRolesDistributed"),
setSessionId(state, sessionId) {
@ -72,15 +75,16 @@ const mutations = {
* @param players
*/
addHistory(state, players) {
if (!state.isVoteHistoryAllowed && state.isSpectator) return;
if (!state.nomination || state.lockedVote <= players.length) return;
const isBanishment = players[state.nomination[1]].role.team === "traveler";
const isExile = players[state.nomination[1]].role.team === "traveler";
state.voteHistory.push({
timestamp: new Date(),
nominator: players[state.nomination[0]].name,
nominee: players[state.nomination[1]].name,
type: isBanishment ? "Banishment" : "Execution",
type: isExile ? "Exile" : "Execution",
majority: Math.ceil(
players.filter(player => !player.isDead || isBanishment).length / 2
players.filter(player => !player.isDead || isExile).length / 2
),
votes: players
.filter((player, index) => state.votes[index])

View File

@ -11,6 +11,9 @@ module.exports = store => {
if (localStorage.getItem("muted")) {
store.commit("toggleMuted", true);
}
if (localStorage.getItem("static")) {
store.commit("toggleStatic", true);
}
if (localStorage.getItem("imageOptIn")) {
store.commit("toggleImageOptIn", true);
}
@ -39,8 +42,8 @@ module.exports = store => {
}
if (localStorage.fabled !== undefined) {
store.commit("players/setFabled", {
fabled: JSON.parse(localStorage.fabled).map(id =>
store.state.fabled.get(id)
fabled: JSON.parse(localStorage.fabled).map(
fabled => store.state.fabled.get(fabled.id) || fabled
)
});
}
@ -91,6 +94,13 @@ module.exports = store => {
localStorage.removeItem("muted");
}
break;
case "toggleStatic":
if (state.grimoire.isStatic) {
localStorage.setItem("static", 1);
} else {
localStorage.removeItem("static");
}
break;
case "toggleImageOptIn":
if (state.grimoire.isImageOptIn) {
localStorage.setItem("imageOptIn", 1);
@ -127,7 +137,11 @@ module.exports = store => {
case "players/setFabled":
localStorage.setItem(
"fabled",
JSON.stringify(state.players.fabled.map(({ id }) => id))
JSON.stringify(
state.players.fabled.map(fabled =>
fabled.isCustom ? fabled : { id: fabled.id }
)
)
);
break;
case "players/add":

View File

@ -176,6 +176,11 @@ class LiveSession {
if (!this._isSpectator) return;
this._store.commit("toggleNight", params);
break;
case "isVoteHistoryAllowed":
if (!this._isSpectator) return;
this._store.commit("session/setVoteHistoryAllowed", params);
this._store.commit("session/clearVoteHistory");
break;
case "votingSpeed":
if (!this._isSpectator) return;
this._store.commit("session/setVotingSpeed", params);
@ -272,12 +277,13 @@ class LiveSession {
this._sendDirect(playerId, "gs", {
gamestate: this._gamestate,
isNight: grimoire.isNight,
isVoteHistoryAllowed: session.isVoteHistoryAllowed,
nomination: session.nomination,
votingSpeed: session.votingSpeed,
lockedVote: session.lockedVote,
isVoteInProgress: session.isVoteInProgress,
markedPlayerId: session.markedPlayerId,
fabled: fabled.map(({ id }) => id),
markedPlayerId: session.markedPlayerId,
fabled: fabled.map(f => (f.isCustom ? f : { id: f.id })),
...(session.nomination ? { votes: session.votes } : {})
});
}
@ -294,6 +300,7 @@ class LiveSession {
gamestate,
isLightweight,
isNight,
isVoteHistoryAllowed,
nomination,
votingSpeed,
votes,
@ -348,6 +355,7 @@ class LiveSession {
});
if (!isLightweight) {
this._store.commit("toggleNight", !!isNight);
this._store.commit("session/setVoteHistoryAllowed", isVoteHistoryAllowed);
this._store.commit("session/nomination", {
nomination,
votes,
@ -356,8 +364,8 @@ class LiveSession {
isVoteInProgress,
});
this._store.commit("session/setMarkedPlayerId", markedPlayerId);
this._store.commit("players/setFabled", {
fabled: fabled.map(id => this._store.state.fabled.get(id))
this._store.commit("players/setFabled", {
fabled: fabled.map(f => this._store.state.fabled.get(f.id) || f)
});
}
}
@ -416,7 +424,7 @@ class LiveSession {
const { fabled } = this._store.state.players;
this._send(
"fabled",
fabled.map(({ id }) => id)
fabled.map(f => (f.isCustom ? f : { id: f.id }))
);
}
@ -428,7 +436,7 @@ class LiveSession {
_updateFabled(fabled) {
if (!this._isSpectator) return;
this._store.commit("players/setFabled", {
fabled: fabled.map(id => this._store.state.fabled.get(id))
fabled: fabled.map(f => this._store.state.fabled.get(f.id) || f)
});
}
@ -665,10 +673,12 @@ class LiveSession {
/**
* A player nomination. ST only
* This also syncs the voting speed to the players.
* @param nomination [nominator, nominee]
* Payload can be an object with {nomination} property or just the nomination itself, or undefined.
* @param payload [nominator, nominee]|{nomination}
*/
nomination({ nomination } = {}) {
nomination(payload) {
if (this._isSpectator) return;
const nomination = payload ? payload.nomination || payload : payload;
const players = this._store.state.players.players;
if (
!nomination ||
@ -695,6 +705,17 @@ class LiveSession {
this._send("isNight", this._store.state.grimoire.isNight);
}
/**
* Send the isVoteHistoryAllowed state. ST only
*/
setVoteHistoryAllowed() {
if (this._isSpectator) return;
this._send(
"isVoteHistoryAllowed",
this._store.state.session.isVoteHistoryAllowed
);
}
/**
* Send the voting speed. ST only
* @param votingSpeed voting speed in seconds, minimum 1
@ -841,6 +862,7 @@ export default store => {
}
break;
case "session/nomination":
case "session/setNomination":
session.nomination(payload);
break;
case "session/setVoteInProgress":
@ -858,6 +880,9 @@ export default store => {
case "session/clearVoteHistory":
session.clearVoteHistory();
break;
case "session/setVoteHistoryAllowed":
session.setVoteHistoryAllowed();
break;
case "toggleNight":
session.setIsNight();
break;