MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / daysRemaining

Method daysRemaining

modules/elections/elections.go:201–222  ·  view source on GitHub ↗

daysRemaining returns a human-readable days-remaining string for an election.

()

Source from the content-addressed store, hash-verified

199
200// daysRemaining returns a human-readable days-remaining string for an election.
201func (m *ElectionsModule) daysRemaining() string {
202 if m.state.ActiveElection == nil {
203 return `0 days`
204 }
205 gd := gametime.GetDate(m.state.ActiveElection.StartRound)
206 endRound := gd.AddPeriod(m.electionDuration())
207 now := util.GetRoundCount()
208 if endRound <= now {
209 return `0 days`
210 }
211 remaining := endRound - now
212 // Use config rounds-per-day for conversion.
213 roundsPerDay := gd.RoundsPerDay
214 if roundsPerDay < 1 {
215 roundsPerDay = 480
216 }
217 days := (int(remaining) + roundsPerDay - 1) / roundsPerDay
218 if days == 1 {
219 return `1 day`
220 }
221 return fmt.Sprintf(`%d days`, days)
222}
223
224// endElection tallies votes, saves the winner, and broadcasts the result.
225// adminUser may be nil for auto-end.

Callers 3

electionAdminCommandMethod · 0.95
onPlayerSpawnMethod · 0.95
onNewRoundMethod · 0.95

Calls 4

electionDurationMethod · 0.95
GetDateFunction · 0.92
GetRoundCountFunction · 0.92
AddPeriodMethod · 0.80

Tested by

no test coverage detected