示例#1
0
文件: server.go 项目: Cristofori/kmud
func (self *connectionHandler) deleteMenu() {
	utils.ExecMenu(
		"Delete character",
		self.user,
		func(menu *utils.Menu) {
			// TODO: Sort character list
			chars := model.GetUserCharacters(self.user.GetId())
			for i, char := range chars {
				c := char
				menu.AddAction(strconv.Itoa(i+1), char.GetName(), func() bool {
					// TODO: Delete confirmation
					model.DeleteCharacter(c.GetId())
					return true
				})
			}
		})
}
示例#2
0
文件: server.go 项目: Cristofori/kmud
func (self *connectionHandler) userMenu() {
	utils.ExecMenu(
		self.user.GetName(),
		self.user,
		func(menu *utils.Menu) {
			menu.OnExit(func() {
				self.user.SetOnline(false)
				self.user = nil
			})

			if self.user.IsAdmin() {
				menu.AddAction("a", "Admin", func() bool {
					self.adminMenu()
					return true
				})
			}

			menu.AddAction("n", "New character", func() bool {
				self.pc = self.newPlayer()
				return true
			})

			// TODO: Sort character list
			chars := model.GetUserCharacters(self.user.GetId())

			if len(chars) > 0 {
				menu.AddAction("d", "Delete character", func() bool {
					self.deleteMenu()
					return true
				})
			}

			for i, char := range chars {
				c := char
				menu.AddAction(strconv.Itoa(i+1), char.GetName(), func() bool {
					self.pc = c
					return false
				})
			}
		})
}