+ 'selected': isSelected,
+ }" @click="onClick">
{{ player.name }}
@@ -37,7 +47,7 @@ function onClick() {
{{ roleTitle }}
-
+
diff --git a/availabili.tf/src/player.ts b/availabili.tf/src/player.ts
index 181b181..2a0ba6d 100644
--- a/availabili.tf/src/player.ts
+++ b/availabili.tf/src/player.ts
@@ -8,4 +8,5 @@ export interface PlayerTeamRole {
name: string;
role: string;
main: boolean;
+ availability: number;
}
diff --git a/availabili.tf/src/stores/roster.ts b/availabili.tf/src/stores/roster.ts
index 042093e..c3b0adb 100644
--- a/availabili.tf/src/stores/roster.ts
+++ b/availabili.tf/src/stores/roster.ts
@@ -1,13 +1,158 @@
-import { type Player } from "@/player";
+import { type Player, type PlayerTeamRole } from "@/player";
import { defineStore } from "pinia";
-import { reactive, ref, type Reactive, type Ref } from "vue";
+import { computed, reactive, ref, type Reactive, type Ref } from "vue";
export const useRosterStore = defineStore("roster", () => {
+ const neededRoles: Reactive
> = reactive([
+ "Pocket Scout",
+ "Flank Scout",
+ "Pocket Soldier",
+ "Roamer",
+ "Demoman",
+ "Medic",
+ ]);
+
+ const selectedPlayers: Reactive<{ [key: string]: PlayerTeamRole }> = reactive({});
+
const selectedRole: Ref = ref("Pocket Scout");
- const availablePlayers: Reactive> = reactive([]);
+
+ const availablePlayers: Reactive> = reactive([
+ {
+ steamId: 2840,
+ name: "Wesker U",
+ role: "Flank Scout",
+ main: true,
+ availability: 1,
+ },
+ {
+ steamId: 2839,
+ name: "JustGetAHouse",
+ role: "Flank Scout",
+ main: false,
+ availability: 1,
+ },
+ {
+ steamId: 2839,
+ name: "JustGetAHouse",
+ role: "Pocket Scout",
+ main: true,
+ availability: 1,
+ },
+ {
+ steamId: 2841,
+ name: "VADIKUS007",
+ role: "Pocket Soldier",
+ main: true,
+ availability: 2,
+ },
+ {
+ steamId: 2841,
+ name: "VADIKUS007",
+ role: "Roamer",
+ main: false,
+ availability: 2,
+ },
+ {
+ steamId: 2282,
+ name: "Bergman777",
+ role: "Demoman",
+ main: true,
+ availability: 2,
+ },
+ {
+ steamId: 2842,
+ name: "BossOfThisGym",
+ role: "Roamer",
+ main: false,
+ availability: 2,
+ },
+ {
+ steamId: 2842,
+ name: "BossOfThisGym",
+ role: "Demoman",
+ main: false,
+ availability: 2,
+ },
+ {
+ steamId: 2842,
+ name: "BossOfThisGym",
+ role: "Pocket Scout",
+ main: false,
+ availability: 2,
+ },
+ //{
+ // steamId: 2843,
+ // name: "samme1g",
+ // role: "Medic",
+ // main: true,
+ // availability: 2,
+ //},
+ {
+ steamId: 2843,
+ name: "samme1g",
+ role: "Pocket Soldier",
+ main: false,
+ availability: 2,
+ },
+ {
+ steamId: 2843,
+ name: "samme1g",
+ role: "Roamer",
+ main: false,
+ availability: 2,
+ },
+ {
+ steamId: 2844,
+ name: "FarbrorBarbro",
+ role: "Roamer",
+ main: true,
+ availability: 1,
+ },
+ {
+ steamId: 2844,
+ name: "FarbrorBarbro",
+ role: "Pocket Soldier",
+ main: false,
+ availability: 1,
+ },
+ ]);
+
+ const availablePlayerRoles = computed(() => {
+ return availablePlayers.filter((player) => player.role == selectedRole.value);
+ });
+
+ const definitelyAvailable = computed(() => {
+ return availablePlayerRoles.value.filter((player) => player.availability == 2);
+ });
+
+ const canBeAvailable = computed(() => {
+ return availablePlayerRoles.value.filter((player) => player.availability == 1);
+ });
+
+ function selectPlayerForRole(player: PlayerTeamRole, role: string) {
+ console.log("selecting.");
+ if (player) {
+ const existingRole = Object.keys(selectedPlayers).find((selectedRole) => {
+ return selectedPlayers[selectedRole]?.steamId == player.steamId &&
+ role != selectedRole;
+ });
+
+ if (existingRole) {
+ delete selectedPlayers[existingRole];
+ }
+ }
+
+ selectedPlayers[role] = player;
+ }
return {
+ neededRoles,
+ selectedPlayers,
selectedRole,
availablePlayers,
+ availablePlayerRoles,
+ selectPlayerForRole,
+ definitelyAvailable,
+ canBeAvailable,
}
});
diff --git a/availabili.tf/src/views/RosterBuilderView.vue b/availabili.tf/src/views/RosterBuilderView.vue
index 276cefb..34b5239 100644
--- a/availabili.tf/src/views/RosterBuilderView.vue
+++ b/availabili.tf/src/views/RosterBuilderView.vue
@@ -2,42 +2,43 @@
import PlayerCard from "../components/PlayerCard.vue";
import RoleSlot from "../components/RoleSlot.vue";
import PlayerTeamRole from "../player.ts";
-import { reactive } from "vue";
+import { computed, reactive } from "vue";
import { useRosterStore } from "../stores/roster";
const rosterStore = useRosterStore();
-const testPlayer: PlayerTeamRole = {
- name: "JustGetAHouse",
- role: "Pocket Scout",
- main: false,
-}
-
-const testPlayer2: PlayerTeamRole = {
- name: "Wesker U",
- role: "Pocket Scout",
- main: true,
-}
-
-const players = [testPlayer, testPlayer2];
-
-const selectPlayers = reactive();
+const hasAvailablePlayers = computed(() => {
+ return rosterStore.availablePlayerRoles.length > 0;
+});
-
-
- {{ rosterStore.selectedRole }}
-
-
-
-
-
-
+
+ Roster
+
+
+
+
Available
+
+
+ No players are currently available for this role.
+
+
+
+
Available if needed
+
+
-
-
-
+