Skip to content

Commit

Permalink
playing-field: always mirror for convenience
Browse files Browse the repository at this point in the history
even if a field is not mirrored and only cyan is shown, teams may want
to use magenta.
  • Loading branch information
TarikViehmann committed Jul 17, 2024
1 parent 760d572 commit 4595e2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
19 changes: 8 additions & 11 deletions src/components/spectator/PlayingField.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// TEMPLATE --------------------------------------------------------------------
s// TEMPLATE
--------------------------------------------------------------------
<template>
<Modal v-if="showPopup" title="Welcome" icon="fa-face-smile" ref="modal">
<ConfirmSetMachinePosePopup @update:isConfirmed="handleConfirmation" />
Expand Down Expand Up @@ -41,7 +42,7 @@
<template v-for="hIndex in horizontalFieldSize">
<PlayingFieldSquare
:zone="getZoneNameFor(hIndex, verticalFieldSize - vIndex + 1)"
:with-dot="vIndex != 1 && (isFieldMirrored || hIndex != 1)"
:with-dot="vIndex != 1 && hIndex != 1"
:isSelected="
selectedSquare?.zone ===
getZoneNameFor(hIndex, verticalFieldSize - vIndex + 1)
Expand Down Expand Up @@ -122,16 +123,12 @@ const showPopup = ref(false)
// zones - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function getZoneNameFor(x: number, y: number): string {
let zone = ''
if (isFieldMirrored.value) {
if (x < 0) {
zone += 'M_'
} else if (x > 0) {
zone += 'C_'
} else {
throw new Error('x coordinate of a field can not be zero')
}
} else {
if (x < 0) {
zone += 'M_'
} else if (x > 0) {
zone += 'C_'
} else {
throw new Error('x coordinate of a field can not be zero')
}
zone += 'Z'
zone += Math.abs(x).toString()
Expand Down
10 changes: 3 additions & 7 deletions src/store/fieldStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ export const useFieldStore = defineStore('fieldStore', () => {
)

// -> full horizontal field size (in number of squares)
const fullHorizontalFieldSize: ComputedRef<number> = computed(() =>
isFieldMirrored.value
? horizontalFieldSize.value * 2
: horizontalFieldSize.value,
const fullHorizontalFieldSize: ComputedRef<number> = computed(
() => horizontalFieldSize.value * 2,
)

// -> number of pixels of the horiontal or vertical diameter of a square
Expand Down Expand Up @@ -73,9 +71,7 @@ export const useFieldStore = defineStore('fieldStore', () => {
squareDiameterPixels.value / 2 -
(parseInt(zoneArr[4]) - 1) * squareDiameterPixels.value,
]
if (isFieldMirrored.value) {
pos[0] += fieldWidthPixels.value / 2
}
pos[0] += fieldWidthPixels.value / 2
if (zoneArr[0] == 'M') {
pos[0] -= parseInt(zoneArr[3]) * squareDiameterPixels.value
} else if (zoneArr[0] == 'C') {
Expand Down

0 comments on commit 4595e2a

Please sign in to comment.