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

Method onPlayerSpawn

modules/elections/elections.go:690–717  ·  view source on GitHub ↗

onPlayerSpawn sends the election reminder to a newly spawned player.

(e events.Event)

Source from the content-addressed store, hash-verified

688
689// onPlayerSpawn sends the election reminder to a newly spawned player.
690func (m *ElectionsModule) onPlayerSpawn(e events.Event) events.ListenerReturn {
691 evt, ok := e.(events.PlayerSpawn)
692 if !ok {
693 return events.Continue
694 }
695
696 if m.state.ActiveElection == nil {
697 return events.Continue
698 }
699
700 el := m.state.ActiveElection
701 daysLeft := m.daysRemaining()
702
703 u := users.GetByUserId(evt.UserId)
704 if u == nil {
705 return events.Continue
706 }
707
708 msg := electionAlert(
709 fmt.Sprintf(`An election is ongoing for <ansi fg="white-bold">"%s."</ansi>`, el.Title),
710 `Type <ansi fg="command">help elections</ansi> to find out more about it.`,
711 `Cast your vote at the nearest polling location.`,
712 fmt.Sprintf(`The election ends in <ansi fg="white-bold">%s</ansi>!`, daysLeft),
713 )
714 u.SendText(msg)
715
716 return events.Continue
717}
718
719// onNewRound checks whether the election duration has elapsed and auto-ends if so.
720// When no election is active, it checks whether any zone's election cycle period

Callers

nothing calls this directly

Calls 4

daysRemainingMethod · 0.95
GetByUserIdFunction · 0.92
electionAlertFunction · 0.85
SendTextMethod · 0.45

Tested by

no test coverage detected