mirror of https://github.com/bra1n/townsquare.git
fix players being moved or removed during a nomination (closes #164)
add vue linter
This commit is contained in:
parent
fb87f6f8cb
commit
71234f3ef9
|
@ -1,53 +1,21 @@
|
|||
---
|
||||
###########################
|
||||
###########################
|
||||
## 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'
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
|
||||
###############
|
||||
# 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"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# Release Notes
|
||||
|
||||
- fix players being moved or removed during nomination
|
||||
- add vue linter
|
||||
|
||||
### 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
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
"main": "App.vue",
|
||||
"dependencies": {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -122,7 +122,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() {
|
||||
|
|
|
@ -45,6 +45,7 @@ const mutations = {
|
|||
setPing: set("ping"),
|
||||
setVotingSpeed: set("votingSpeed"),
|
||||
setVoteInProgress: set("isVoteInProgress"),
|
||||
setNomination: set("nomination"),
|
||||
claimSeat: set("claimedSeat"),
|
||||
distributeRoles: set("isRolesDistributed"),
|
||||
setSessionId(state, sessionId) {
|
||||
|
|
|
@ -656,10 +656,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 ||
|
||||
|
@ -823,6 +825,7 @@ export default store => {
|
|||
}
|
||||
break;
|
||||
case "session/nomination":
|
||||
case "session/setNomination":
|
||||
session.nomination(payload);
|
||||
break;
|
||||
case "session/setVoteInProgress":
|
||||
|
|
Loading…
Reference in New Issue