Skip to content

Commit 24e632b

Browse files
committed
✨ (all) Add faction option to player game settings
1 parent 66a87b7 commit 24e632b

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

admin-app/src/components/GameEdit.vue

+13
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
:label="`${variable[0].toUpperCase()}${variable.slice(1, -1)} name`"
7272
/>
7373
</v-col>
74+
<v-col v-if="variable === 'settings'">
75+
<v-text-field
76+
v-model.trim="info[variable][i].faction"
77+
:label="`${variable[0].toUpperCase()}${variable.slice(1, -1)} faction`"
78+
/>
79+
</v-col>
7480
<v-col cols="auto" v-if="variable !== 'expansions'">
7581
<v-select
7682
:items="[
@@ -202,6 +208,13 @@ export default class GameEdit extends Vue {
202208
this.info.rules = (this.$refs.rules as any).invoke("getMarkdown");
203209
this.info.description = (this.$refs.description as any).invoke("getMarkdown");
204210
211+
// Remove empty faction strings
212+
for (const setting of this.info.settings ?? []) {
213+
if (!setting.faction) {
214+
delete setting.faction;
215+
}
216+
}
217+
205218
this.$emit("game:update", this.info);
206219
}
207220

site-lib/gameinfo.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ViewerInfo {
2424
replayable: boolean;
2525
}
2626

27-
type GameInfoOptions = Array<{
27+
type GameInfoOption = {
2828
label: string;
2929
type: "checkbox" | "select";
3030
name: string;
@@ -36,7 +36,7 @@ type GameInfoOptions = Array<{
3636
}
3737
]
3838
| null;
39-
}>;
39+
};
4040
export interface GameInfo {
4141
_id: {
4242
game: string;
@@ -58,13 +58,13 @@ export interface GameInfo {
5858
};
5959

6060
// [{label: "Do not fill planets with faction color", name: 'noFactionFill', type: 'checkbox'}]
61-
preferences: GameInfoOptions;
61+
preferences: GameInfoOption[];
6262

6363
// Player settings that affect the engine - like autocharge
64-
settings: GameInfoOptions;
64+
settings: Array<GameInfoOption & { faction?: string }>;
6565

6666
// [{label: "Last player <i>rotates</i> sectors before faction selection", name: "advancedRules", type: 'checkbox'}]
67-
options: GameInfoOptions;
67+
options: GameInfoOption[];
6868

6969
// [2, 3, 4]
7070
players: number[];

site-lib/schemas/gameinfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const repr = {
9292
entryPoint: String,
9393
},
9494
preferences: optionSchema,
95-
settings: optionSchema,
95+
settings: [{ ...optionSchema[0], faction: String }],
9696
options: optionSchema,
9797
players: [Number],
9898
expansions: [

webapp-vue/src/components/GameSidebar.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@
6262

6363
<div class="mt-75" v-if="gameInfo && gameInfo.settings.length > 0 && game.status === 'active' && settings">
6464
<h3>Settings</h3>
65-
<div v-for="pref in gameInfo.settings" :key="pref.name">
65+
<div
66+
v-for="pref in gameInfo.settings.filter(
67+
(setting) => !setting.faction || setting.faction === playerUser.faction
68+
)"
69+
:key="pref.name"
70+
>
6671
<template v-if="pref.type === 'checkbox'">
6772
<b-checkbox v-model="settings[pref.name]" @change="postSettings">
6873
{{ pref.label }}

0 commit comments

Comments
 (0)