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


Golang Command.Flush方法代码示例

本文整理汇总了Golang中code/wolfmud/org/WolfMUD/git/utils/command.Command.Flush方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Flush方法的具体用法?Golang Command.Flush怎么用?Golang Command.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在code/wolfmud/org/WolfMUD/git/utils/command.Command的用法示例。


在下文中一共展示了Command.Flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: parseStage2

// parseStage2 is called by Parse to take advantage of defer unwinding. By
// splitting the parsing we can easily obtain the locks we want and defer the
// unlocking. This makes both Parse and parseStage2 very simple.
func (p *Player) parseStage2(cmd *command.Command) (retry bool) {
	for _, l := range cmd.Locks {
		l.Lock()
		defer l.Unlock()
	}

	// If player moved before we locked we need to retry
	if !cmd.CanLock(p.Locate()) {
		return true
	}

	handled := p.Process(cmd)
	retry = cmd.LocksModified()

	if !handled && !retry {
		cmd.Respond("[RED]Eh?")
	}

	if !retry {
		cmd.Flush()
	}

	return
}
开发者ID:iaingmackay,项目名称:simplemud,代码行数:27,代码来源:player.go


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