예제 #1
0
파일: handler.go 프로젝트: Emudofus/gofus
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,
	})
}
예제 #2
0
파일: realm.go 프로젝트: Emudofus/gofus
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{})
	}
}
예제 #3
0
파일: handler.go 프로젝트: Emudofus/gofus
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)
	}
}
예제 #4
0
파일: handler.go 프로젝트: Emudofus/gofus
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)
	}
}
예제 #5
0
파일: realm.go 프로젝트: Emudofus/gofus
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})
}
예제 #6
0
파일: realm.go 프로젝트: Emudofus/gofus
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{})
	}
}
예제 #7
0
파일: realm.go 프로젝트: Emudofus/gofus
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,
	})
}
예제 #8
0
파일: handler.go 프로젝트: Emudofus/gofus
func handle_client_current_date(ctx frontend.Service, client frontend.Client, m *msg.CurrentDateReq) {
	client.Send(&msg.CurrentDateResp{
		Current: time.Now(),
	})
}
예제 #9
0
파일: handler.go 프로젝트: Emudofus/gofus
func HandleClientConnection(ctx frontend.Service, client frontend.Client) {
	log.Printf("[frontend-net-client-%04d] CONN", client.Id())

	client.Send(&msg.HelloGame{})
}
예제 #10
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_rand_name(ctx frontend.Service, client frontend.Client, m *msg.RandNameReq) {
	client.Send(&msg.RandNameResp{Name: "Gofus"})
}
예제 #11
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_regional_version(ctx frontend.Service, client frontend.Client, m *msg.RegionalVersionReq) {
	client.Send(&msg.RegionalVersionResp{ctx.Config().CommunityId})
}