Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 21x 21x 21x 21x 21x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 660x 660x 660x 1x 1x 14x 14x 14x 1x 1x 220x 220x 220x 1x 901x 901x 901x 1x 220x 220x 220x 21x 21x 199x 199x 1x 21x 21x 21x 21x 21x 21x 21x 21x 21x | <template>
<div class="formation-field">
<svg
viewBox="0 0 100 120"
class="field-svg"
preserveAspectRatio="xMidYMid meet"
>
<!-- Soccer field -->
<template v-if="sportType !== 'futsal'">
<!-- Field background -->
<rect x="0" y="0" width="100" height="120" class="field-bg soccer-bg" />
<!-- Center circle -->
<circle cx="50" cy="60" r="12" class="field-line" fill="none" />
<circle cx="50" cy="60" r="1" class="field-line" />
<!-- Center line -->
<line x1="0" y1="60" x2="100" y2="60" class="field-line" />
<!-- Goal boxes (top) -->
<rect
x="30"
y="0"
width="40"
height="18"
class="field-line"
fill="none"
/>
<rect
x="38"
y="0"
width="24"
height="8"
class="field-line"
fill="none"
/>
<!-- Goal boxes (bottom) -->
<rect
x="30"
y="102"
width="40"
height="18"
class="field-line"
fill="none"
/>
<rect
x="38"
y="112"
width="24"
height="8"
class="field-line"
fill="none"
/>
<!-- Penalty spots -->
<circle cx="50" cy="14" r="0.8" class="field-line" />
<circle cx="50" cy="106" r="0.8" class="field-line" />
</template>
<!-- Futsal court -->
<template v-else>
<!-- Court background -->
<rect x="0" y="0" width="100" height="120" class="field-bg futsal-bg" />
<!-- Court boundary -->
<rect
x="4"
y="4"
width="92"
height="112"
class="field-line"
fill="none"
rx="2"
/>
<!-- Center line -->
<line x1="4" y1="60" x2="96" y2="60" class="field-line" />
<!-- Center circle -->
<circle cx="50" cy="60" r="8" class="field-line" fill="none" />
<circle cx="50" cy="60" r="1" class="field-line" />
<!-- Penalty arcs (top) -->
<path d="M 35 4 A 15 15 0 0 1 65 4" class="field-line" fill="none" />
<!-- Penalty arcs (bottom) -->
<path
d="M 35 116 A 15 15 0 0 0 65 116"
class="field-line"
fill="none"
/>
<!-- Penalty spots -->
<circle cx="50" cy="18" r="0.8" class="field-line" />
<circle cx="50" cy="102" r="0.8" class="field-line" />
<!-- Goal areas (small rectangles) -->
<rect
x="38"
y="4"
width="24"
height="6"
class="field-line"
fill="none"
/>
<rect
x="38"
y="110"
width="24"
height="6"
class="field-line"
fill="none"
/>
<!-- Corner arcs -->
<path d="M 4 7 A 3 3 0 0 1 7 4" class="field-line" fill="none" />
<path d="M 93 4 A 3 3 0 0 1 96 7" class="field-line" fill="none" />
<path d="M 4 113 A 3 3 0 0 0 7 116" class="field-line" fill="none" />
<path d="M 93 116 A 3 3 0 0 0 96 113" class="field-line" fill="none" />
</template>
<!-- Position markers -->
<g
v-for="pos in formationPositions"
:key="pos.position"
class="position-marker"
:class="{
assigned: getAssignment(pos.position),
clickable: !readonly,
'out-of-position': isOutOfPosition(pos.position),
}"
:transform="`translate(${pos.x}, ${scaleY(pos.y)})`"
@click="handlePositionClick(pos.position)"
>
<!-- Marker circle -->
<circle
r="5"
:class="[
'marker-circle',
{
assigned: getAssignment(pos.position),
'out-of-position': isOutOfPosition(pos.position),
},
]"
/>
<!-- SB-288+: out-of-position warning badge -->
<text
v-if="isOutOfPosition(pos.position)"
class="warn-badge"
text-anchor="middle"
dominant-baseline="central"
x="4.5"
y="-4.5"
font-size="4.5"
>
!
</text>
<!-- Jersey number or position code -->
<text
class="marker-text"
text-anchor="middle"
dominant-baseline="central"
font-size="4"
>
{{ getMarkerLabel(pos.position) }}
</text>
<!-- Player name below marker -->
<text
v-if="getAssignment(pos.position)"
class="player-name"
text-anchor="middle"
y="9"
font-size="3"
>
{{ getPlayerDisplayName(pos.position) }}
</text>
</g>
</svg>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { getFormations } from '../../config/formations';
const props = defineProps({
formation: {
type: String,
required: true,
},
assignments: {
type: Array,
default: () => [],
},
roster: {
type: Array,
default: () => [],
},
readonly: {
type: Boolean,
default: false,
},
sportType: {
type: String,
default: 'soccer',
},
// SB-288+: formation slot codes whose assigned player doesn't play that
// slot's position group. Rendered with an amber ring + "!" badge.
warnPositions: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['position-clicked']);
// True when a slot is assigned a player who's out of position for it.
function isOutOfPosition(positionCode) {
return props.warnPositions.includes(positionCode);
}
// Get positions for the current formation
const formationPositions = computed(() => {
const formations = getFormations(props.sportType);
const formationData = formations[props.formation];
return formationData ? formationData.positions : [];
});
// Scale Y coordinate to fit the SVG viewBox (0-100 -> 10-110 to add padding)
function scaleY(y) {
return 10 + (y * 100) / 100;
}
// Get the assignment for a position
function getAssignment(positionCode) {
return props.assignments.find(a => a.position === positionCode);
}
// Get the label to show on the marker
function getMarkerLabel(positionCode) {
const assignment = getAssignment(positionCode);
if (assignment) {
return assignment.jersey_number || '#';
}
return positionCode;
}
// Get the player display name for a position
function getPlayerDisplayName(positionCode) {
const assignment = getAssignment(positionCode);
if (!assignment) return '';
// If we have a display_name from the assignment, use it
if (assignment.display_name) {
// Truncate long names
const name = assignment.display_name;
return name.length > 12 ? name.substring(0, 10) + '...' : name;
}
// Otherwise try to find in roster
const player = props.roster.find(p => p.id === assignment.player_id);
if (player) {
const name =
player.display_name ||
`${player.first_name || ''} ${player.last_name || ''}`.trim();
return name.length > 12 ? name.substring(0, 10) + '...' : name;
}
return '';
}
function handlePositionClick(positionCode) {
if (!props.readonly) {
emit('position-clicked', positionCode);
}
}
</script>
<style scoped>
.formation-field {
width: 100%;
max-width: 300px;
margin: 0 auto;
}
.field-svg {
width: 100%;
height: auto;
display: block;
}
.field-bg.soccer-bg {
fill: #2e7d32;
}
.field-bg.futsal-bg {
fill: #2962a8;
}
.field-line {
stroke: rgba(255, 255, 255, 0.5);
stroke-width: 0.5;
fill: rgba(255, 255, 255, 0.5);
}
.position-marker {
cursor: default;
}
.position-marker.clickable {
cursor: pointer;
}
.position-marker.clickable:hover .marker-circle {
stroke: #ffc107;
stroke-width: 1;
}
.marker-circle {
fill: rgba(255, 255, 255, 0.3);
stroke: rgba(255, 255, 255, 0.6);
stroke-width: 0.5;
transition: all 0.2s;
}
.marker-circle.assigned {
fill: #2196f3;
stroke: white;
stroke-width: 0.8;
}
.marker-circle.out-of-position {
fill: #b7791f;
stroke: #fbbf24;
stroke-width: 1;
}
.warn-badge {
fill: #fbbf24;
font-weight: bold;
pointer-events: none;
}
.marker-text {
fill: white;
font-weight: bold;
pointer-events: none;
}
.player-name {
fill: white;
font-size: 3px;
pointer-events: none;
}
</style>
|