Example #1
0
func handle_client_context_infos(ctx frontend.Service, client frontend.Client, m *msg.ContextInfosReq) {
	// todo send current map actors
	client.Send(&msg.SetMapLoaded{})
	client.Send(&msg.SetNumberOfFights{
		Fights: 0,
	})
}
Example #2
0
func handle_client_create_player(ctx frontend.Service, client frontend.Client, m *msg.CreatePlayerReq) {
	player := ctx.Players().NewPlayer(uint(client.UserInfos().Id), m.Name, m.Breed, m.Gender, m.Colors.First, m.Colors.Second, m.Colors.Third)

	if inserted, success := ctx.Players().Persist(player); inserted && success {
		client_send_player_list(ctx, client)
	} else {
		client.Send(&msg.CreatePlayerErrorResp{})
	}
}
Example #3
0
func handle_client_game_context_create(ctx frontend.Service, client frontend.Client, m *msg.GameContextCreateReq) {
	switch m.Type {
	case msg.SoloContextType:
		client.Send(&msg.GameContextCreateResp{msg.SoloContextType})

		p := client.Player()
		client.Send(&msg.SetPlayerStats{
			Experience:            p.Experience.Experience,
			LowerExperienceLevel:  0,
			HigherExperienceLevel: 1,

			Kamas: 0,

			BoostStatsPts:  0,
			BoostSpellsPts: 0,

			AlignId:    0,
			AlignLevel: 0,
			AlignGrade: 0,
			Honor:      0,
			Dishonor:   0,
			EnabledPvp: false,

			Life:    0,
			MaxLife: 1,

			Energy:    0,
			MaxEnergy: 1,

			Stats: p.Stats,
		})

		m := client.Player().Position.Map
		client.Send(&msg.SetCurrentMapData{
			Id:   m.Id,
			Date: m.Date,
			Key:  m.Key,
		})

	case msg.FightContextType:
		fallthrough
	default:
		log.Print("context type %d is not implemented yet", m.Type)
	}
}
Example #4
0
func HandleClientDisconnection(ctx frontend.Service, client frontend.Client) {
	log.Printf("[frontend-net-client-%04d] DCONN", client.Id())

	if client.UserInfos() != nil {
		ctx.Backend().NotifyUserConnection(client.UserInfos().Id, false)
	}
}
Example #5
0
func handle_client_player_selection(ctx frontend.Service, client frontend.Client, m *msg.PlayerSelectionReq) {
	player, ok := ctx.Players().GetById(m.PlayerId)
	if !ok {
		client.CloseWith(&msg.PlayerSelectionErrorResp{})
		return
	}

	client.SetPlayer(player)
	client.Send(&msg.PlayerSelectionResp{player})
}
Example #6
0
func handle_client_login(ctx frontend.Service, client frontend.Client, m *msg.RealmLoginReq) {
	if infos, ok := ctx.Backend().GetUserInfos(m.Ticket); ok {
		client.SetUserInfos(*infos)
		ctx.Backend().NotifyUserConnection(infos.Id, true)

		client.Send(&msg.RealmLoginSuccess{ctx.Config().CommunityId})
	} else {
		client.CloseWith(&msg.RealmLoginError{})
	}
}
Example #7
0
func client_send_player_list(ctx frontend.Service, client frontend.Client) {
	var players []*db.Player
	var ok bool
	if players, ok = ctx.Players().GetByOwnerId(uint(client.UserInfos().Id)); !ok {
		players = make([]*db.Player, 0, 0)
	}

	client.Send(&msg.PlayersResp{
		ServerId:        ctx.Config().ServerId,
		SubscriptionEnd: client.UserInfos().SubscriptionEnd,
		Players:         players,
	})
}
Example #8
0
func handle_client_current_date(ctx frontend.Service, client frontend.Client, m *msg.CurrentDateReq) {
	client.Send(&msg.CurrentDateResp{
		Current: time.Now(),
	})
}
Example #9
0
func HandleClientConnection(ctx frontend.Service, client frontend.Client) {
	log.Printf("[frontend-net-client-%04d] CONN", client.Id())

	client.Send(&msg.HelloGame{})
}
Example #10
0
func handle_client_rand_name(ctx frontend.Service, client frontend.Client, m *msg.RandNameReq) {
	client.Send(&msg.RandNameResp{Name: "Gofus"})
}
Example #11
0
func handle_client_regional_version(ctx frontend.Service, client frontend.Client, m *msg.RegionalVersionReq) {
	client.Send(&msg.RegionalVersionResp{ctx.Config().CommunityId})
}