Example #1
0
File: team.go Project: obowersa/crg
func (t *team) setLastScore(v int64) error {
	if v < 0 {
		return nil
	}
	if v > t.score {
		return nil
	}
	t.lastScore = v
	statemanager.StateUpdateInt64(t.stateIDs["lastScore"], v)
	statemanager.StateUpdateInt64(t.stateIDs["jamScore"], t.score-t.lastScore)
	return nil
}
Example #2
0
func (bt *boxTrip) setOutJamIdx(v int64) {
	if v >= 0 && v < int64(len(bt.sb.jams)) {
		jam := bt.sb.jams[v]
		bt.out.jamIdx = jam.idx
		statemanager.StateUpdateInt64(bt.stateIDs["out.jamIdx"], jam.idx)
		statemanager.StateUpdateInt64(bt.stateIDs["out.period"], jam.period)
		statemanager.StateUpdateInt64(bt.stateIDs["out.jam"], jam.jam)
	}

	statemanager.StateDelete(bt.stateIDs["out.jamIdx"])
	statemanager.StateDelete(bt.stateIDs["out.period"])
	statemanager.StateDelete(bt.stateIDs["out.jam"])
}
Example #3
0
func (mmn *minMaxNumber) sendNumStateUpdate() {
	statemanager.StateUpdateInt64(mmn.stateIDs["precise"], mmn.num)
	diff := mmn.num % mmn.updateOn
	if mmn.countdown {
		diff = -((mmn.updateOn - diff) % mmn.updateOn)
	}

	num := mmn.num - diff
	if num < mmn.min {
		num = mmn.min
	} else if num > mmn.max {
		num = mmn.max
	}
	statemanager.StateUpdateInt64(mmn.stateIDs["num"], num)
}
Example #4
0
func (bt *boxTrip) setInJamIdx(v int64) error {
	if v >= 0 && v < int64(len(bt.sb.jams)) {
		jam := bt.sb.jams[v]
		bt.in.jamIdx = jam.idx
		statemanager.StateUpdateInt64(bt.stateIDs["in.jamIdx"], jam.idx)
		statemanager.StateUpdateInt64(bt.stateIDs["in.period"], jam.period)
		statemanager.StateUpdateInt64(bt.stateIDs["in.jam"], jam.jam)
		return nil
	}

	bt.in.jamIdx = -1
	statemanager.StateDelete(bt.stateIDs["in.jamIdx"])
	statemanager.StateDelete(bt.stateIDs["in.period"])
	statemanager.StateDelete(bt.stateIDs["in.jam"])
	return nil
}
Example #5
0
func (ss *stateSnapshot) unend() {
	ss.setCanRevert(false)
	ss.setEndTicks(0)
	ss.setEndTime(time.Time{})
	ss.setInProgress(true)
	ss.updateLength()

	for name, c := range ss.clocks {
		c.setEndTime(0)
		statemanager.StateUpdateInt64(ss.stateIDs[name+".endTime"], c.endTime)
	}
}
Example #6
0
func (mmn *minMaxNumber) setMin(v int64) error {
	mmn.min = v
	if mmn.min > mmn.max {
		mmn.setMax(mmn.min)
	}
	if mmn.min > mmn.num {
		mmn.setNum(mmn.num)
	}

	statemanager.StateUpdateInt64(mmn.stateIDs["min"], mmn.min)
	return nil
}
Example #7
0
func (c *stateSnapshotClock) setEndTime(v int64) {
	c.endTime = v
	statemanager.StateUpdateInt64(c.base+".EndTime", v)
}
Example #8
0
File: team.go Project: obowersa/crg
func newTeam(sb *Scoreboard, id uint8) *team {
	t := &team{
		sb:       sb,
		base:     fmt.Sprintf("%s.Team(%d)", sb.stateBase(), id),
		id:       id,
		settings: make(map[string]*setting),
		skaters:  make(map[string]*skater),
		stateIDs: make(map[string]string),
	}

	t.stateIDs["id"] = fmt.Sprintf("%s.ID", t.base)
	t.stateIDs["name"] = fmt.Sprintf("%s.Name", t.base)
	t.stateIDs["color"] = fmt.Sprintf("%s.Color", t.base)
	t.stateIDs["score"] = fmt.Sprintf("%s.Score", t.base)
	t.stateIDs["lastScore"] = fmt.Sprintf("%s.LastScore", t.base)
	t.stateIDs["jamScore"] = fmt.Sprintf("%s.JamScore", t.base)
	t.stateIDs["timeouts"] = fmt.Sprintf("%s.Timeouts", t.base)
	t.stateIDs["officialReviews"] = fmt.Sprintf("%s.OfficialReviews", t.base)
	t.stateIDs["officialReviewRetained"] = fmt.Sprintf("%s.OfficialReviewRetained", t.base)
	t.stateIDs["lead"] = fmt.Sprintf("%s.Lead", t.base)
	t.stateIDs["starPass"] = fmt.Sprintf("%s.StarPass", t.base)
	t.stateIDs["jammer"] = fmt.Sprintf("%s.Jammer.ID", t.base)
	t.stateIDs["jammerInBox"] = fmt.Sprintf("%s.Jammer.InBox", t.base)
	t.stateIDs["pivot"] = fmt.Sprintf("%s.Pivot.ID", t.base)
	t.stateIDs["pivotInBox"] = fmt.Sprintf("%s.Pivot.InBox", t.base)

	statemanager.StateUpdateInt64(t.stateIDs["id"], int64(id))

	statemanager.RegisterUpdaterString(t.stateIDs["name"], 0, t.setName)
	statemanager.RegisterUpdaterString(t.stateIDs["color"], 0, t.setColor)
	statemanager.RegisterUpdaterInt64(t.stateIDs["score"], 0, t.setScore)
	statemanager.RegisterUpdaterInt64(t.stateIDs["lastScore"], 0, t.setLastScore)
	statemanager.RegisterUpdaterInt64(t.stateIDs["timeouts"], 0, t.setTimeouts)
	statemanager.RegisterUpdaterInt64(t.stateIDs["officialReviews"], 0, t.setOfficialReviews)
	statemanager.RegisterUpdaterBool(t.stateIDs["officialReviewRetained"], 0, t.setOfficialReviewRetained)
	statemanager.RegisterUpdaterString(t.stateIDs["lead"], 0, t.setLead)
	statemanager.RegisterUpdaterBool(t.stateIDs["starPass"], 0, t.setStarPass)

	statemanager.RegisterUpdaterString(t.stateIDs["jammer"], 1, t.setJammer)         // Must be after skaters are loaded
	statemanager.RegisterUpdaterString(t.stateIDs["pivot"], 1, t.setPivot)           // Must be after skaters are loaded
	statemanager.RegisterUpdaterBool(t.stateIDs["jammerInBox"], 1, t.setJammerInBox) // Must be after skaters are loaded
	statemanager.RegisterUpdaterBool(t.stateIDs["pivotInBox"], 1, t.setPivotInBox)   // Must be after skaters are loaded

	statemanager.RegisterCommand(t.stateIDs["score"]+".Inc", t.incScore)
	statemanager.RegisterCommand(t.stateIDs["score"]+".Dec", t.decScore)
	statemanager.RegisterCommand(t.stateIDs["lastScore"]+".Inc", t.incLastScore)
	statemanager.RegisterCommand(t.stateIDs["lastScore"]+".Dec", t.decLastScore)
	statemanager.RegisterCommand(t.stateIDs["timeouts"]+".Start", t.startTimeout)
	statemanager.RegisterCommand(t.stateIDs["officialReviews"]+".Start", t.startOfficialReview)
	statemanager.RegisterCommand(t.stateIDs["officialReviews"]+".Retained", t.retainOfficialReview)
	statemanager.RegisterCommand(t.base+".DeleteSkater", t.deleteSkater)

	// Setup Updaters for skaters (functions located in skater.go)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).ID", 0, t.sSetID)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).Name", 0, t.sSetName)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).LegalName", 0, t.sSetLegalName)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).InsuranceNumber", 0, t.sSetInsuranceNumber)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).Number", 0, t.sSetNumber)
	statemanager.RegisterPatternUpdaterString(t.base+".Skater(*).Position", 0, t.sSetPosition)
	statemanager.RegisterPatternUpdaterBool(t.base+".Skater(*).IsAlt", 0, t.sSetIsAlt)
	statemanager.RegisterPatternUpdaterBool(t.base+".Skater(*).IsCaptain", 0, t.sSetIsCaptain)
	statemanager.RegisterPatternUpdaterBool(t.base+".Skater(*).IsAltCaptain", 0, t.sSetIsAltCaptain)
	statemanager.RegisterPatternUpdaterBool(t.base+".Skater(*).IsBenchStaff", 0, t.sSetIsBenchStaff)
	statemanager.RegisterPatternUpdaterBool(t.base+".Skater(*).InBox", 0, t.sSetInBox)

	t.reset()
	return t
}
Example #9
0
File: jam.go Project: obowersa/crg
func (j *jam) setPeriod(v int64) error {
	j.period = v
	return statemanager.StateUpdateInt64(j.stateIDs["period"], v)
}
Example #10
0
File: team.go Project: obowersa/crg
func (t *team) setTimeouts(v int64) error {
	t.timeouts = v
	statemanager.StateUpdateInt64(t.stateIDs["timeouts"], v)
	return nil
}
Example #11
0
File: team.go Project: obowersa/crg
func (t *team) setOfficialReviews(v int64) error {
	t.officialReviews = v
	statemanager.StateUpdateInt64(t.stateIDs["officialReviews"], v)
	return nil
}
Example #12
0
func (t *stateSnapshotTeam) setOfficialReviews(v int64) {
	t.officialReviews = v
	statemanager.StateUpdateInt64(t.base+".OfficialReviews", v)
}
Example #13
0
File: jam.go Project: obowersa/crg
func (j *jam) setJam(v int64) error {
	j.jam = v
	return statemanager.StateUpdateInt64(j.stateIDs["jam"], v)
}
Example #14
0
func (t *stateSnapshotTeam) setTimeouts(v int64) {
	t.timeouts = v
	statemanager.StateUpdateInt64(t.base+".Timeouts", v)
}
Example #15
0
func (mc *masterClock) setTicks(v int64) error {
	mc.ticks = v
	statemanager.StateUpdateInt64(mc.stateIDs["ticks"], v)
	return nil
}
Example #16
0
func (c *stateSnapshotClock) setNumber(v int64) {
	c.number = v
	statemanager.StateUpdateInt64(c.base+".Number", v)
}
Example #17
0
func (ss *stateSnapshot) setLength(v int64) {
	ss.length = v
	statemanager.StateUpdateInt64(ss.stateIDs["length"], v)
}
Example #18
0
func (ss *stateSnapshot) setEndTicks(v int64) {
	ss.endTicks = v
	statemanager.StateUpdateInt64(ss.stateIDs["endTicks"], v)
}