feat: add score calculation function

This commit is contained in:
uku 2024-10-23 16:34:02 +02:00
parent 728bc1abe1
commit 4919a5258d
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o

View file

@ -28,7 +28,7 @@
let latlng = $state(L.latLng(0, 0));
let distance = $derived(latlng.distanceTo(point));
let points = $derived(5000 * Math.exp(-Math.max(0, distance - 20) / 750));
let points = $derived(calculatePoints());
let lines = $state(true);
let labels = $state(false);
@ -65,6 +65,17 @@
latlng = e.latlng;
});
}
function calculatePoints(): number {
const lenientDistance = Math.max(0, distance - 20);
const score = 5000 * Math.exp(-lenientDistance / 750);
let multiplier = 1; /*
if (lines) multiplier *= 0.5;
if (labels) multiplier *= 0.5; */
return score * multiplier;
}
</script>
<div class="banner" {hidden}>