예제 #1
0
func (c *Command) Execute(message []byte) {

	session := c.connection.GetSession()

	if session == nil || !session.IsAuth {
		return
	}

	var commandDetector CommandDetector
	json.Unmarshal(message, &commandDetector)

	answer := model.Fields{
		"command_id": commandDetector.CommandId,
	}

	func() {

		user, _ := model_user.Get(session.UserUUID)
		if user == nil {
			return
		}

		// answer["user"] = true

		player, _ := model_player.Get(*user.PlayerUUID)

		if player == nil {
			return
		}

		// answer["player"] = true

		planet, _ := model_live_planet.Get(player.CapitalPlanetUUID)
		if planet == nil {
			return
		}

		planet.Connection = c.connection

		// answer["planet"] = true

		answer["planet_info"] = planet.MakeClientInfo()
	}()

	b, _ := json.Marshal(answer)

	c.connection.Send(string(b))
}
예제 #2
0
func (c *Command) Execute(message []byte) {

	session := c.connection.GetSession()

	if session == nil || !session.IsAuth {
		return
	}

	var commandDetector CommandDetector
	json.Unmarshal(message, &commandDetector)

	/*
		answer := model2.Fields{
			"command_id": commandDetector.CommandId,
		}
	*/

	func() {

		user, _ := model_user.Get(session.UserUUID)
		if user == nil {
			return
		}

		player, _ := model_player.Get(*user.PlayerUUID)
		if player == nil {
			return
		}

		planet, _ := model_live_planet.Get(player.CapitalPlanetUUID)
		if planet == nil {
			return
		}

		c.ctx.BDispatcher.Build(&planet.UUID, commandDetector.Building, int(commandDetector.X), int(commandDetector.Y))

	}()

}