Skip to content

Commit 41a4cf5

Browse files
committed
trigger to mark worked entries depending on the contest's band rule
1 parent c2148fc commit 41a4cf5

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

core/bandmap/bandmap.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"log"
55
"time"
66

7+
"github.com/ftl/conval"
78
"github.com/ftl/hamradio/callsign"
89

910
"github.com/ftl/hellocontest/core"
@@ -59,6 +60,7 @@ type Bandmap struct {
5960
updatePeriod time.Duration
6061
maximumAge time.Duration
6162
weights core.BandmapWeights
63+
bandRule conval.BandRule
6264

6365
do chan func()
6466
closed chan struct{}
@@ -215,6 +217,7 @@ func (m *Bandmap) Hide() {
215217

216218
func (m *Bandmap) ContestChanged(contest core.Contest) {
217219
m.do <- func() {
220+
m.bandRule = contest.Definition.Scoring.QSOBandRule
218221
m.entries.SetBands(contest.Bands())
219222
m.update()
220223
}
@@ -298,6 +301,21 @@ func (m *Bandmap) Add(spot core.Spot) {
298301
}
299302

300303
m.entries.Add(spot, m.clock.Now(), m.weights)
304+
305+
if spot.IsWorked() {
306+
band := spot.Band
307+
switch m.bandRule {
308+
case conval.Once:
309+
band, mode = core.NoBand, core.NoMode
310+
case conval.OncePerBand:
311+
band, mode = band, core.NoMode
312+
case conval.OncePerBandAndMode:
313+
band, mode = band, mode
314+
default:
315+
band, mode = core.NoBand, core.NoMode
316+
}
317+
m.entries.MarkAsWorked(spot.Call, band, mode)
318+
}
301319
}
302320
}
303321

core/bandmap/entries.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (e *Entry) update() {
128128
if lastHeard.Before(s.Time) {
129129
lastHeard = s.Time
130130
}
131-
if source.Priority() > s.Source.Priority() {
131+
if e.Source != core.WorkedSpot && source.Priority() > s.Source.Priority() {
132132
source = s.Source
133133
}
134134
}
@@ -282,6 +282,12 @@ func (l *Entries) findIndexForInsert(entry *Entry) int {
282282
return left
283283
}
284284

285+
func (l *Entries) MarkAsWorked(call callsign.Callsign, band core.Band, mode core.Mode) {
286+
// TODO: implement
287+
// find relevant entries
288+
// set entry.Source = core.WorkedSpot
289+
}
290+
285291
func (l *Entries) CleanOut(maximumAge time.Duration, now time.Time, weights core.BandmapWeights) {
286292
l.cleanOutOldEntries(maximumAge, now)
287293

0 commit comments

Comments
 (0)