本文整理汇总了Golang中code/wolfmud/org/WolfMUD/git/utils/command.Command.Broadcast方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Broadcast方法的具体用法?Golang Command.Broadcast怎么用?Golang Command.Broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/wolfmud/org/WolfMUD/git/utils/command.Command
的用法示例。
在下文中一共展示了Command.Broadcast方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: say
// say implements the 'SAY' command, alias "'". Say sends a message to all
// other responders at the current location.
func (p *Player) say(cmd *command.Command) (handled bool) {
if len(cmd.Nouns) == 0 {
cmd.Respond("[RED]Was there anything in particular you wanted to say?")
} else {
message := strings.Join(cmd.Input[1:], ` `)
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "[CYAN]%s says: %s", cmd.Issuer.Name(), message)
cmd.Respond("[YELLOW]You say: %s", message)
}
return true
}
示例2: get
// get removes an Item from the command issuer's current location and puts it
// into it's own inventory. For this to happen a few conditions must be true:
//
// 1. Issuer must be at some sort of location
// 2. Issuer must implement an inventory
// 3. Issuer's location must contain the requested item
//
func (i *Item) get(cmd *command.Command) (handled bool) {
if m, ok := cmd.Issuer.(location.Locateable); ok {
if inv, ok := cmd.Issuer.(inventory.Interface); ok {
if l := m.Locate(); l.Contains(i) {
l.Remove(i)
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s pick up %s.", cmd.Issuer.Name(), i.Name())
inv.Add(i)
cmd.Respond("You pickup %s.", i.Name())
handled = true
}
}
}
return
}
示例3: quit
// quit implements the 'QUIT' command.
//
// quit extracts a player from the world cleanly. If the player's location is
// not crowded it also announces their departure - in a crowded location their
// departure will go unnoticed.
func (p *Player) quit(cmd *command.Command) (handled bool) {
log.Printf("%s is quiting", p.Name())
p.quitting = true
p.dropInventory(cmd)
l := p.Locate()
if !l.Crowded() {
cmd.Broadcast([]thing.Interface{p}, "%s gives a strangled cry of 'Bye Bye', and then slowly fades away and is gone.", p.Name())
}
cmd.Flush()
l.Remove(p)
PlayerList.Remove(p)
return true
}
示例4: drop
// drop removes an Item from the command issuer's inventory and puts it into
// the inventory of the issuer's current location. For this to happen a few
// conditions must be true:
//
// 1. Issuer must be at some sort of location
// 2. Issuer must implement an inventory
// 3. Inventory must contain the requested item
//
func (i *Item) drop(cmd *command.Command) (handled bool) {
if m, ok := cmd.Issuer.(location.Locateable); ok {
if inv, ok := cmd.Issuer.(inventory.Interface); ok {
if inv.Contains(i) {
inv.Remove(i)
cmd.Respond("You drop %s.", i.Name())
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s drop %s.", cmd.Issuer.Name(), i.Name())
m.Locate().Add(i)
handled = true
}
}
} else {
cmd.Respond("You don't see anywhere to drop %s.", i.Name())
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s try and drop %s.", cmd.Issuer.Name(), i.Name())
handled = true
}
return
}
示例5: who
// who implements the 'WHO' command. This lists all the players currently on
// the server.
func (l *playerList) who(cmd *command.Command) (handled bool) {
b := new(bytes.Buffer)
if l.Length() < 2 {
b.WriteString("You are all alone in this world.")
} else {
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s concentrate.", cmd.Issuer.Name())
for _, p := range PlayerList.nonLockingList(cmd.Issuer) {
b.WriteString(" ")
b.WriteString(p.Name())
b.WriteString("\n")
}
b.WriteString("\nTOTAL PLAYERS: ")
b.WriteString(strconv.Itoa(l.Length()))
}
cmd.Respond(b.String())
return true
}
示例6: sneeze
// sneeze implements the 'SNEEZE' command.
//
// TODO: Remove - for debugging responders and broadcasters
func (p *Player) sneeze(cmd *command.Command) (handled bool) {
cmd.Respond("You sneeze. Aaahhhccchhhooo!")
cmd.Broadcast([]thing.Interface{p}, "You see %s sneeze.", cmd.Issuer.Name())
PlayerList.Broadcast(p.Locate().List(), "You hear a loud sneeze.")
return true
}
示例7: examine
// examine describes the specific item.
func (i *Item) examine(cmd *command.Command) (handled bool) {
cmd.Respond("You examine %s. %s", i.Name(), i.Description())
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s study %s.", cmd.Issuer.Name(), i.Name())
return true
}
示例8: weigh
// weigh estimates the weight of the specified item.
func (i *Item) weigh(cmd *command.Command) (handled bool) {
cmd.Respond("You estimate %s to weigh about %s.", i.Name(), i.weight)
cmd.Broadcast([]thing.Interface{cmd.Issuer}, "You see %s estimate the weight of %s.", cmd.Issuer.Name(), i.Name())
return true
}