Skip to content

Commit 93f1924

Browse files
committed
feature: restrict matchmaking
1 parent b3ea4d9 commit 93f1924

4 files changed

Lines changed: 81 additions & 4 deletions

File tree

components/matchmaking/Matchmaking.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ import FiveStackToolTip from "../FiveStackToolTip.vue";
137137

138138
<div class="flex flex-row gap-4">
139139
<div
140-
v-for="type in e_match_types"
140+
v-for="type in allowedMatchTypes"
141141
:key="type.value"
142142
class="flex-1 p-4 border rounded-lg transition-all duration-300 relative overflow-hidden group h-[100px]"
143143
:class="{
@@ -324,6 +324,9 @@ export default {
324324
};
325325
},
326326
methods: {
327+
isMatchmakingTypeEnabled(matchType: string): boolean {
328+
return useApplicationSettingsStore().isMatchmakingTypeEnabled(matchType);
329+
},
327330
getRegionlatencyResult(region: string):
328331
| {
329332
isLan: boolean;
@@ -371,6 +374,14 @@ export default {
371374
},
372375
},
373376
computed: {
377+
allowedMatchTypes(): {
378+
value: e_match_types_enum;
379+
description: string;
380+
}[] {
381+
return this.e_match_types.filter((type) =>
382+
this.isMatchmakingTypeEnabled(type.value.toLowerCase()),
383+
);
384+
},
374385
isInQueue(): boolean {
375386
return !!this.matchMakingQueueDetails;
376387
},

i18n/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
"default_models_description": "Enable default player models for all players in the match.",
203203
"auto_cancel_duration": "Auto Cancel Duration",
204204
"auto_cancel_duration_description": "This is the duration in minutes that a match will be auto canceled if not started within the duration.",
205+
"matchmaking_type_description": "Toggle matchmaking for each type that will allow players to join matchmaking for this type of match.",
205206
"update": "Update",
206207
"players": {
207208
"force_name_registration": "Force Player Name Registration",
@@ -257,7 +258,6 @@
257258
"preferred": "Preferred",
258259
"max_acceptable_latency": "Maximum Acceptable Latency",
259260
"max_latency_description": "If no regions are preferred, matchmaking will only use regions with latency below this value."
260-
261261
}
262262
},
263263
"watch": {

pages/settings/application/index.vue

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ definePageMeta({
1111
<form @submit.prevent="updateSettings" class="grid gap-4">
1212
<div
1313
class="flex flex-row items-center justify-between rounded-lg border p-4 cursor-pointer"
14-
@click="toggleMatchmaking"
14+
@click="toggleMatchmakingType(e_match_types_enum.all)"
1515
>
1616
<div class="space-y-0.5">
1717
<h4 class="text-base font-medium">
@@ -27,6 +27,28 @@ definePageMeta({
2727
/>
2828
</div>
2929

30+
<div v-if="matchMakingAllowed" class="space-y-2">
31+
<div class="grid grid-cols-3 gap-4">
32+
<template v-for="match_type in ['competitive', 'wingman', 'duel']">
33+
<div
34+
class="flex flex-row items-center justify-between rounded-lg border p-4 cursor-pointer"
35+
@click="toggleMatchmakingType(match_type)"
36+
>
37+
<div class="space-y-0.5">
38+
<h4 class="text-base font-medium capitalize">{{ match_type }}</h4>
39+
</div>
40+
<Switch
41+
:model-value="isMatchmakingTypeEnabled(match_type)"
42+
@update:model-value="toggleMatchmakingType(match_type)"
43+
/>
44+
</div>
45+
</template>
46+
</div>
47+
<p class="text-sm text-muted-foreground">
48+
{{ $t(`pages.settings.application.matchmaking_type_description`) }}
49+
</p>
50+
</div>
51+
3052
<FormField v-slot="{ componentField }" name="auto_cancel_duration">
3153
<FormItem>
3254
<FormLabel class="text-lg font-semibold">{{
@@ -258,6 +280,36 @@ export default {
258280
}),
259281
});
260282
},
283+
isMatchmakingTypeEnabled(match_type: e_match_types_enum) {
284+
const matchmakingTypeSetting = this.settings.find(
285+
(setting: { name: string; value: string | null }) =>
286+
setting.name === `public.matchmaking_${match_type}`,
287+
);
288+
return matchmakingTypeSetting?.value !== "false";
289+
},
290+
async toggleMatchmakingType(match_type: e_match_types_enum) {
291+
await (this as any).$apollo.mutate({
292+
mutation: generateMutation({
293+
insert_settings_one: [
294+
{
295+
object: {
296+
name: `public.matchmaking_${match_type}`,
297+
value: this.isMatchmakingTypeEnabled(match_type)
298+
? "false"
299+
: "true",
300+
},
301+
on_conflict: {
302+
constraint: settings_constraint.settings_pkey,
303+
update_columns: [settings_update_column.value],
304+
},
305+
},
306+
{
307+
__typename: true,
308+
},
309+
],
310+
}),
311+
});
312+
},
261313
async toggleDefaultModels() {
262314
await (this as any).$apollo.mutate({
263315
mutation: generateMutation({

stores/ApplicationSettings.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore, acceptHMRUpdate } from "pinia";
22
import { ref, computed, watch } from "vue";
3-
import { e_player_roles_enum } from "~/generated/zeus";
3+
import { e_player_roles_enum, e_match_types_enum } from "~/generated/zeus";
44
import getGraphqlClient from "~/graphql/getGraphqlClient";
55
import { generateSubscription } from "~/graphql/graphqlGen";
66
import { useMatchmakingStore } from "./MatchmakingStore";
@@ -269,6 +269,19 @@ export const useApplicationSettingsStore = defineStore(
269269
globalStream.value = stream;
270270
};
271271

272+
const isMatchmakingTypeEnabled = (
273+
matchType: e_match_types_enum,
274+
): boolean => {
275+
console.info({
276+
matchType,
277+
});
278+
return (
279+
settings.value?.find(
280+
(setting) => setting.name === `public.matchmaking_${matchType}`,
281+
)?.value !== "false"
282+
);
283+
};
284+
272285
return {
273286
settings,
274287
availableRegions,
@@ -285,6 +298,7 @@ export const useApplicationSettingsStore = defineStore(
285298
canAddWithoutInvite,
286299
globalStream,
287300
setGlobalStream,
301+
isMatchmakingTypeEnabled,
288302
};
289303
},
290304
);

0 commit comments

Comments
 (0)