mirror of
https://github.com/bra1n/townsquare.git
synced 2025-04-04 22:24:36 +00:00
adding search to role modal to find off script characters
This commit is contained in:
parent
9da7d45515
commit
f1e1f7f773
3 changed files with 62 additions and 33 deletions
|
@ -97,7 +97,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
keyup({ key, ctrlKey, metaKey }) {
|
keyup({ key, ctrlKey, metaKey }) {
|
||||||
if (ctrlKey || metaKey) return;
|
if (ctrlKey || metaKey || true) return;
|
||||||
switch (key.toLocaleLowerCase()) {
|
switch (key.toLocaleLowerCase()) {
|
||||||
case "g":
|
case "g":
|
||||||
this.$store.commit("toggleGrimoire");
|
this.$store.commit("toggleGrimoire");
|
||||||
|
|
|
@ -8,7 +8,26 @@
|
||||||
: "bluffing"
|
: "bluffing"
|
||||||
}}
|
}}
|
||||||
</h3>
|
</h3>
|
||||||
<ul class="tokens" v-if="tab === 'editionRoles' || !otherTravelers.size">
|
<div
|
||||||
|
v-if="fabled.find((r) => r.id === 'plusone') && tab === 'editionRoles'"
|
||||||
|
>
|
||||||
|
<span>Find a Plus One character: </span>
|
||||||
|
<input type="text" v-model="filter" />
|
||||||
|
</div>
|
||||||
|
<ul class="tokens" v-if="filteredRoles.length > 0">
|
||||||
|
<li
|
||||||
|
v-for="role in filteredRoles.slice(0, 10)"
|
||||||
|
@class="[role.team]"
|
||||||
|
:key="role.id"
|
||||||
|
@click="setRole(role)"
|
||||||
|
>
|
||||||
|
<token :role="role" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul
|
||||||
|
class="tokens"
|
||||||
|
v-if="tab === 'editionRoles' || !otherTravelers.length > 0"
|
||||||
|
>
|
||||||
<li
|
<li
|
||||||
v-for="role in availableRoles"
|
v-for="role in availableRoles"
|
||||||
:class="[role.team]"
|
:class="[role.team]"
|
||||||
|
@ -18,9 +37,12 @@
|
||||||
<Token :role="role" />
|
<Token :role="role" />
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="tokens" v-if="tab === 'otherTravelers' && otherTravelers.size">
|
<ul
|
||||||
|
class="tokens"
|
||||||
|
v-if="tab === 'otherTravelers' && otherTravelers.length > 0"
|
||||||
|
>
|
||||||
<li
|
<li
|
||||||
v-for="role in otherTravelers.values()"
|
v-for="role in otherTravelers"
|
||||||
:class="[role.team]"
|
:class="[role.team]"
|
||||||
:key="role.id"
|
:key="role.id"
|
||||||
@click="setRole(role)"
|
@click="setRole(role)"
|
||||||
|
@ -30,7 +52,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
<div
|
<div
|
||||||
class="button-group"
|
class="button-group"
|
||||||
v-if="playerIndex >= 0 && otherTravelers.size && !session.isSpectator"
|
v-if="
|
||||||
|
playerIndex >= 0 && otherTravelers.length > 0 && !session.isSpectator
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="button"
|
class="button"
|
||||||
|
@ -57,15 +81,25 @@ export default {
|
||||||
components: { Token, Modal },
|
components: { Token, Modal },
|
||||||
props: ["playerIndex"],
|
props: ["playerIndex"],
|
||||||
computed: {
|
computed: {
|
||||||
|
filteredRoles() {
|
||||||
|
if (this.filter === "") {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var filteredRoles = this.otherRoles.filter((role) => {
|
||||||
|
return role.name.toLowerCase().includes(this.filter.toLowerCase());
|
||||||
|
});
|
||||||
|
console.log(filteredRoles);
|
||||||
|
return filteredRoles;
|
||||||
|
},
|
||||||
availableRoles() {
|
availableRoles() {
|
||||||
const availableRoles = [];
|
const availableRoles = [];
|
||||||
const players = this.$store.state.players.players;
|
const players = this.$store.state.players.players;
|
||||||
this.$store.state.roles.forEach(role => {
|
this.$store.state.roles.forEach((role) => {
|
||||||
// don't show bluff roles that are already assigned to players
|
// don't show bluff roles that are already assigned to players
|
||||||
if (
|
if (
|
||||||
this.playerIndex >= 0 ||
|
this.playerIndex >= 0 ||
|
||||||
(this.playerIndex < 0 &&
|
(this.playerIndex < 0 &&
|
||||||
!players.some(player => player.role.id === role.id))
|
!players.some((player) => player.role.id === role.id))
|
||||||
) {
|
) {
|
||||||
availableRoles.push(role);
|
availableRoles.push(role);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +108,14 @@ export default {
|
||||||
return availableRoles;
|
return availableRoles;
|
||||||
},
|
},
|
||||||
...mapState(["modals", "roles", "session"]),
|
...mapState(["modals", "roles", "session"]),
|
||||||
...mapState("players", ["players"]),
|
...mapState("players", ["players", "fabled"]),
|
||||||
...mapState(["otherTravelers"])
|
...mapState(["otherTravelers"]),
|
||||||
|
...mapState(["otherRoles"]),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tab: "editionRoles"
|
tab: "editionRoles",
|
||||||
|
filter: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -88,7 +124,7 @@ export default {
|
||||||
// assign to bluff slot (index < 0)
|
// assign to bluff slot (index < 0)
|
||||||
this.$store.commit("players/setBluff", {
|
this.$store.commit("players/setBluff", {
|
||||||
index: this.playerIndex * -1 - 1,
|
index: this.playerIndex * -1 - 1,
|
||||||
role
|
role,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (this.session.isSpectator && role.team === "traveler") return;
|
if (this.session.isSpectator && role.team === "traveler") return;
|
||||||
|
@ -97,7 +133,7 @@ export default {
|
||||||
this.$store.commit("players/update", {
|
this.$store.commit("players/update", {
|
||||||
player,
|
player,
|
||||||
property: "role",
|
property: "role",
|
||||||
value: role
|
value: role,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.tab = "editionRoles";
|
this.tab = "editionRoles";
|
||||||
|
@ -107,8 +143,8 @@ export default {
|
||||||
this.tab = "editionRoles";
|
this.tab = "editionRoles";
|
||||||
this.toggleModal("role");
|
this.toggleModal("role");
|
||||||
},
|
},
|
||||||
...mapMutations(["toggleModal"])
|
...mapMutations(["toggleModal"]),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -22,28 +22,20 @@ const getRolesByEdition = (edition = editionJSON[0]) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTravelersNotInEdition = (edition = editionJSON[0]) => {
|
const getTravelersNotInEdition = (edition = editionJSON[0]) => {
|
||||||
return new Map(
|
return rolesJSON.filter(
|
||||||
rolesJSON
|
|
||||||
.filter(
|
|
||||||
(r) =>
|
(r) =>
|
||||||
r.team === "traveler" &&
|
r.team === "traveler" &&
|
||||||
r.edition !== edition.id &&
|
r.edition !== edition.id &&
|
||||||
!edition.roles.includes(r.id)
|
!edition.roles.includes(r.id)
|
||||||
)
|
|
||||||
.map((role) => [role.id, role])
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRolesNotInEdition = (edition = editionJSON[0]) => {
|
const getRolesNotInEdition = (edition = editionJSON[0]) => {
|
||||||
return new Map(
|
return rolesJSON.filter(
|
||||||
rolesJSON
|
|
||||||
.filter(
|
|
||||||
(r) =>
|
(r) =>
|
||||||
r.team !== "traveler" &&
|
r.team !== "traveler" &&
|
||||||
r.edition !== edition.id &&
|
r.edition !== edition.id &&
|
||||||
!edition.roles.includes(r.id)
|
!edition.roles.includes(r.id)
|
||||||
)
|
|
||||||
.map((role) => [role.id, role.name])
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,7 +136,7 @@ export default new Vuex.Store({
|
||||||
edition: editionJSONbyId.get("tb"),
|
edition: editionJSONbyId.get("tb"),
|
||||||
roles: getRolesByEdition(),
|
roles: getRolesByEdition(),
|
||||||
otherTravelers: getTravelersNotInEdition(),
|
otherTravelers: getTravelersNotInEdition(),
|
||||||
otherRoles: getTravelersNotInEdition(),
|
otherRoles: getRolesNotInEdition(),
|
||||||
fabled,
|
fabled,
|
||||||
jinxes,
|
jinxes,
|
||||||
},
|
},
|
||||||
|
@ -284,6 +276,7 @@ export default new Vuex.Store({
|
||||||
state.edition = editionJSONbyId.get(edition.id);
|
state.edition = editionJSONbyId.get(edition.id);
|
||||||
state.roles = getRolesByEdition(state.edition);
|
state.roles = getRolesByEdition(state.edition);
|
||||||
state.otherTravelers = getTravelersNotInEdition(state.edition);
|
state.otherTravelers = getTravelersNotInEdition(state.edition);
|
||||||
|
state.otherRoles = getRolesNotInEdition(state.edition);
|
||||||
} else {
|
} else {
|
||||||
state.edition = edition;
|
state.edition = edition;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue