当前位置: 首页>>代码示例>>Golang>>正文


Golang Command.Broadcast方法代码示例

本文整理汇总了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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:15,代码来源:player.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:23,代码来源:item.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:23,代码来源:player.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:28,代码来源:item.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:25,代码来源:playerList.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:9,代码来源:player.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:6,代码来源:item.go

示例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
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:6,代码来源:item.go


注:本文中的code/wolfmud/org/WolfMUD/git/utils/command.Command.Broadcast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。