Skip to content

Commit

Permalink
fix: match play types
Browse files Browse the repository at this point in the history
  • Loading branch information
stanrunge committed Dec 23, 2024
1 parent 65ddb91 commit 921c6dc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
28 changes: 14 additions & 14 deletions packages/web/resources/js/Pages/Matches/Play.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import Layout from '@/Shared/Layout.svelte'
import { router, Link } from '@inertiajs/svelte'
import { onMount } from 'svelte'
import type { TeamMember, MatchParticipant, MatchMap, Score } from '@/Types/app'
import type { Match, TeamMember, User, MatchParticipant, MatchMap, Score } from '@/Types/app'
let { match, user } = $props()
let { match, user }: { match: Match; user: User } = $props()
console.log(match)
let shareModalShown = $state(false)
let forfeitModalShown = $state(false)
let matchEndedModalShown = $state(match.finished_at)
let matchEndedModalShown = $state(match.finished_at ? true : false)
let mapPoolStatus = $state(getMapPoolStatus())
onMount(() => {
Expand All @@ -31,14 +31,14 @@
})
function userCanBan() {
return user.profile.team_members.find((tm: TeamMember) =>
tm.team?.match_participants?.find((mp: MatchParticipant) => mp.id == match.current_banner),
return user.profile.team_members?.find((tm) =>
tm.team?.match_participants?.find((mp) => mp.id == match.current_banner),
)
}
function userCanPick() {
return user.profile.team_members.find((tm: TeamMember) =>
tm.team?.match_participants?.find((mp: MatchParticipant) => mp.id == match.current_picker),
return user.profile.team_members?.find((tm) =>
tm.team?.match_participants?.find((mp) => mp.id == match.current_picker),
)
}
Expand Down Expand Up @@ -83,7 +83,7 @@
</script>

<Layout>
<div class="bg-secondary mx-8 my-8 flex items-center justify-between rounded-xl p-4">
<div class="mx-8 my-8 flex items-center justify-between rounded-xl bg-secondary p-4">
<div>
<Link href="/events/1">
<h1 class="text-2xl font-bold">{match.event?.name}</h1>
Expand Down Expand Up @@ -120,13 +120,13 @@
<div class="m-8 flex justify-evenly text-center">
{#each match.match_participants as participant}
<div class="flex flex-col gap-2">
<div class="bg-secondary rounded-xl p-4">
<div class="rounded-xl bg-secondary p-4">
<h2 class="text-xl font-bold">{participant.team.name}</h2>
<img src="/public/" alt="Team Logo" />
</div>

{#each participant.match_participant_players as player}
<div class="bg-secondary flex justify-between gap-2 rounded p-2">
<div class="flex justify-between gap-2 rounded bg-secondary p-2">
<img src="" alt="Player" />
<h3>{player.team_member.profile?.username}</h3>
<p>{getPlayerStatusIcon()}</p>
Expand All @@ -144,21 +144,21 @@
<div class="flex justify-center">
<div class="flex gap-2">
{#each getMatchParticipantScores(map.id, match.match_participants[0].id) as score}
<div class="bg-secondary rounded p-2">
<div class="rounded bg-secondary p-2">
<img src="" class="rounded-full" alt="" />
<h1 class="text-l font-bold">{score.score}</h1>
</div>
{/each}
</div>
<div class="bg-secondary mx-8 my-2 rounded-xl px-8 py-4 text-center">
<div class="mx-8 my-2 rounded-xl bg-secondary px-8 py-4 text-center">
<h1 class="text-l font-bold">
{map.map_pool_map.map.map_set.artist} - {map.map_pool_map.map.map_set.title} [{map
.map_pool_map.map.difficulty_name}]
</h1>
</div>
<div class="flex gap-2">
{#each getMatchParticipantScores(map.id, match.match_participants[1].id) as score}
<div class="bg-secondary rounded p-2">
<div class="rounded bg-secondary p-2">
<img src="" class="rounded-full" alt="" />
<h1 class="text-l font-bold">{score.score}</h1>
</div>
Expand All @@ -185,7 +185,7 @@

return acc
}, {})) as [modsKey, maps]}
<div class="bg-secondary mx-8 my-2 flex items-center rounded-xl p-2">
<div class="mx-8 my-2 flex items-center rounded-xl bg-secondary p-2">
<h3 class="mx-4 text-xl font-bold">{modsKey}</h3>

<div class="flex flex-wrap">
Expand Down
27 changes: 24 additions & 3 deletions packages/web/resources/js/Types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,33 @@ export interface Map {
export interface Match {
id: number
match_participants?: MatchParticipant[]
match_maps?: MatchMap[]
match_maps?: MatchMap[],
finished_at: string | null,
current_picker: number | null,
current_banner: number | null,
action_limit: string | null
}

export interface Score {
export interface Score {
id: number
match_participant_player_id: number
match_participant_player?: MatchParticipantPlayer
score: number
}
}

export interface User {
id: number,
profile_id: number,
profile: Profile
}

export interface Organisation {
id: number,
}

export interface Profile {
id: number,
user_id: number,
user?: User
team_members?: TeamMember[]
}

0 comments on commit 921c6dc

Please sign in to comment.