Example #1
0
func NewNPC(u *mud.Universe) *NPC {
	npc := new(NPC)
	npc.universe = u
	npc.localCommands = make(map[string]mud.Command)
	npc.supportedStimuli = make(map[string]SimpleStimulusHandler)
	npc.stimuli = make(chan mud.Stimulus, 5)
	npc.Meta = make(map[string]interface{})
	go mud.StimuliLoop(npc)
	return npc
}
Example #2
0
func NewPuritan(universe *mud.Universe) *simple.NPC {
	puritan := simple.NewNPC(universe)
	puritan.AddStimHandler("say", puritanHandleSay)
	puritan.SetVisible(true)
	puritan.SetDescription("Penelope Proper")
	puritan.SetCarryable(false)
	puritan.AddCommand("buy", buy)
	go mud.StimuliLoop(puritan)
	return puritan
}
Example #3
0
func (n *NamePrompt) Respond(c *mud.UserConnection) bool {
	playerName := <-c.FromUser
	c.Data["playerName"] = playerName

	newP := n.universe.PlayerFromUserConn(c)
	mud.PlacePlayerInRoom(n.StartRoom, newP)
	mud.Look(newP, []string{})

	go newP.ReadLoop(n.PlayerRemoveChan)
	go newP.ExecCommandLoop()
	go mud.StimuliLoop(newP)

	return false
}
Example #4
0
func NewFlipFlop(u *mud.Universe) *simple.NPC {
	ff := simple.NewNPC(u)
	persister := new(flipFlopPersister)

	persister.npc = ff
	persister.universe = u

	ff.SetUniverse(u)
	ff.AddStimHandler("say", ffHandleSay)
	ff.Meta["lastText"] = "Unchanged."
	ff.SetDescription(ff.Meta["lastText"].(string))
	ff.SetVisible(true)

	u.Add(ff)
	u.Add(persister)

	go mud.StimuliLoop(ff)

	return ff
}