Exemplo n.º 1
0
func (self *Server) Bootstrap() {
	// Create the world object if necessary
	model.GetWorld()

	// If there are no rooms at all create one
	rooms := model.GetRooms()
	if len(rooms) == 0 {
		zones := model.GetZones()

		var zone types.Zone

		if len(zones) == 0 {
			zone, _ = model.CreateZone("Default")
		} else {
			zone = zones[0]
		}

		model.CreateRoom(zone, types.Coordinate{X: 0, Y: 0, Z: 0})
	}
}
Exemplo n.º 2
0
func (self *connectionHandler) newPlayer() types.PC {
	// TODO: character slot limit
	const SizeLimit = 12
	for {
		name := self.user.GetInput("Desired character name: ")

		if name == "" {
			return nil
		}

		char := model.GetCharacterByName(name)

		if char != nil {
			self.user.WriteLine("That name is unavailable")
		} else if err := utils.ValidateName(name); err != nil {
			self.user.WriteLine(err.Error())
		} else {
			room := model.GetRooms()[0] // TODO: Better way to pick an initial character location
			return model.CreatePlayerCharacter(name, self.user.GetId(), room)
		}
	}
}