``` feat(pet): 重构宠物繁殖系统,添加蛋孵化功能

This commit is contained in:
1
2026-01-20 22:08:36 +00:00
parent cf4660fbe0
commit 5ef922278a
68 changed files with 4467 additions and 584 deletions

View File

@@ -41,7 +41,7 @@ func (h Controller) GetServerOnline(data *user.SidInfo, c gnet.Conn) (result *rp
ser := playerservice.NewUserService(data.Head.UserID)
f, b := ser.Friend.Get()
for _, v := range f {
result.FriendInfo = append(result.FriendInfo, rpc.FriendInfo{v, 1})
result.FriendInfo = append(result.FriendInfo, rpc.FriendInfo{Userid: v, TimePoke: 1})
}
result.BlackInfo = b
defer func() {

View File

@@ -5,22 +5,20 @@ import (
"blazing/logic/service/fight"
"blazing/logic/service/pet"
"blazing/logic/service/player"
"blazing/modules/player/model"
)
// GetBreedInfo 获取繁殖信息协议
// 前端到后端无数据 请求协议
func (ctl Controller) GetBreedInfo(
data *pet.C2S_GET_BREED_INFO, playerObj *player.Player) (result *pet.S2C_GET_BREED_INFO, err errorcode.ErrorCode) { //这个时候player应该是空的
data *pet.C2S_GET_BREED_INFO, player *player.Player) (result *model.S2C_GET_BREED_INFO, err errorcode.ErrorCode) { //这个时候player应该是空的
result = &pet.S2C_GET_BREED_INFO{}
result.BreedLeftTime = 5000
result.HatchLeftTime = 5000
result.HatchState = 1
result.BreedState = 1
result.EggID = 1
result.Intimacy = 1
result.FeMalePetID = 1
result.MalePetID = 3
result = &model.S2C_GET_BREED_INFO{}
r := player.Service.Egg.Get()
if r == nil {
return
}
result = &r.Data
// TODO: 实现获取繁殖信息的具体逻辑
return result, 0
@@ -45,10 +43,21 @@ func (ctl Controller) GetBreedPet(
// StartBreed 开始繁殖协议
// 前端到后端
func (ctl Controller) StartBreed(
data *pet.C2S_START_BREED, playerObj *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
data *pet.C2S_START_BREED, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
_, MalePet, found := player.FindPet(data.Male)
if !found {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
_, Female, found := player.FindPet(data.Female)
if !found {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
// TODO: 实现开始繁殖的具体逻辑
result = &fight.NullOutboundInfo{}
r := player.Service.Egg.StartBreed(MalePet, Female)
if !r {
return nil, errorcode.ErrorCodes.ErrCannotPerformAction
}
return result, 0
}
@@ -56,15 +65,20 @@ func (ctl Controller) StartBreed(
// GetEggList 获取精灵蛋数组
// 前端到后端无数据 请求协议
func (ctl Controller) GetEggList(
data *pet.C2S_GET_EGG_LIST, playerObj *player.Player) (result *pet.S2C_GET_EGG_LIST, err errorcode.ErrorCode) { //这个时候player应该是空的
data *pet.C2S_GET_EGG_LIST, player *player.Player) (result *pet.S2C_GET_EGG_LIST, err errorcode.ErrorCode) { //这个时候player应该是空的
result = &pet.S2C_GET_EGG_LIST{}
// TODO: 实现获取精灵蛋列表的逻辑
// 示例数据,实际应从玩家数据中获取
result.EggList = append(result.EggList, pet.EggInfo{EggID: 1, OwnerID: 10001, EggCatchTime: 122123,
MalePetID: 1,
FeMalePetID: 3,
})
r := player.Service.Egg.Get()
if r == nil {
return
}
for _, v := range r.EggList {
result.EggList = append(result.EggList, v)
}
return result, 0
}

View File

@@ -16,7 +16,7 @@ import (
func (h Controller) GetUserSimInfo(data *user.SimUserInfoInboundInfo, player *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) {
result = &user.SimUserInfoOutboundInfo{}
copier.Copy(result, player.Service.Info.Person(data.UserId))
copier.Copy(result, player.Service.Info.Person(data.UserId).Data)
return result, 0
}
@@ -27,7 +27,7 @@ func (h Controller) GetUserSimInfo(data *user.SimUserInfoInboundInfo, player *pl
func (h Controller) GetUserMoreInfo(data *user.MoreUserInfoInboundInfo, player *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) {
result = &user.MoreUserInfoOutboundInfo{}
info := player.Service.Info.Person(data.UserId)
copier.CopyWithOption(result, info, copier.Option{IgnoreEmpty: true, DeepCopy: true})
copier.CopyWithOption(result, info.Data, copier.Option{IgnoreEmpty: true, DeepCopy: true})
//todo 待实现
return result, 0
@@ -56,4 +56,4 @@ func (h Controller) GetPlayerExp(data *item.ExpTotalRemainInboundInfo, player *p
TotalExp: uint32(player.Info.ExpPool),
}, 0
}
}