diff --git a/logic/controller/pet.go b/logic/controller/pet.go index bc243f471..d924ddf01 100644 --- a/logic/controller/pet.go +++ b/logic/controller/pet.go @@ -125,15 +125,7 @@ func (h *Controller) PetOneCure( return item.CatchTime == data.CatchTime }) if ok { - onpet.Hp = onpet.MaxHp - for i := 0; i < 4; i++ { - maxPP, ok := xmlres.SkillMap[int(onpet.SkillList[i].ID)] - // 恢复至最大PP值(从配置表获取) - if onpet.SkillList[i].ID != 0 && ok { - onpet.SkillList[i].PP = uint32(maxPP.MaxPP) - - } - } + onpet.Cure() } return &pet.PetOneCureOutboundInfo{ @@ -178,11 +170,13 @@ func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, c *player.Player) return item.CatchTime == data.CatchTime }) if ok { - c.AddPetExp(onpet, data.Exp) + c.AddPetExp(onpet, data.Exp) } - return &pet.PetSetExpOutboundInfo{}, 0 + return &pet.PetSetExpOutboundInfo{ + c.Info.ExpPool, + }, 0 } func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (result *pet.ChangeSkillOutInfo, err errorcode.ErrorCode) { _, onpet, ok := FindWithIndex(c.Info.PetList, func(item model.PetInfo) bool { diff --git a/logic/controller/task.go b/logic/controller/task.go index 2a855d6cb..2345198b9 100644 --- a/logic/controller/task.go +++ b/logic/controller/task.go @@ -88,7 +88,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // log.Printf("任务86未知分支out_id=%d,默认奖励布布种子", data.OutState) } // 生成宠物(pet_dv=31,锁个体) - r := model.GenPetInfo(petType, 31, -1, 0, 0, 5) + r := c.GenPetInfo(petType, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -154,7 +154,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 遗迹中的精灵信号(奖励奇塔) case 28: // out_id=1,宠物类型102(奇塔) - r := model.GenPetInfo(102, 31, -1, 0, 0, 5) // pet_dv默认-1(随机个体) + r := c.GenPetInfo(102, 31, -1, 0, 0, 5) // pet_dv默认-1(随机个体) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -173,7 +173,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 时空之门(奖励迪卢卡) case 40: // out_id=1,宠物类型139(迪卢卡) - r := model.GenPetInfo(139, 31, -1, 0, 0, 5) + r := c.GenPetInfo(139, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -197,7 +197,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 密林中的托尼(奖励托尼+物品) case 49: // 1. 奖励宠物:托尼(类型158) - r := model.GenPetInfo(158, 31, -1, 0, 0, 5) + r := c.GenPetInfo(158, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -289,7 +289,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 赛尔号大整修(奖励TOE+物品) case 71: // 1. 奖励宠物:TOE(类型213) - r := model.GenPetInfo(213, 31, -1, 0, 0, 5) + r := c.GenPetInfo(213, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -380,7 +380,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 站长归来(奖励尼布+物品) case 92: // 1. 奖励宠物:尼布(类型95) - r := model.GenPetInfo(95, 31, -1, 0, 0, 5) + r := c.GenPetInfo(95, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) @@ -462,7 +462,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. // 寻找迷失的心(奖励史空+物品) case 133: // 1. 奖励宠物:史空(类型381) - r := model.GenPetInfo(381, 31, -1, 0, 0, 5) + r := c.GenPetInfo(381, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) diff --git a/logic/service/player/pet.go b/logic/service/player/pet.go index a76cc9328..c2d571f3b 100644 --- a/logic/service/player/pet.go +++ b/logic/service/player/pet.go @@ -46,11 +46,18 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32) { basic.Spd + uint32(basic.HP) needExp := calculateExperience(petinfo.Level, ba) - + needExp -= petinfo.Exp if addExp >= needExp { addExp -= needExp + p.Info.ExpPool -= needExp //减去已使用的经验 petinfo.Level++ + if originalLevel < 100 && petinfo.Level == 100 { //升到100了 + petinfo.Cure() + petinfo.NextLvExp = calculateExperience(petinfo.Level, ba) + break //停止升级 + } + // 检查是否可以进化 if basic.EvolvesTo != 0 && // 有明确的进化 int(petinfo.Level) >= basic.EvolvingLv && // 有明确的进化等级 @@ -61,13 +68,15 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32) { } } else { + p.Info.ExpPool -= addExp //减去已使用的经验 + petinfo.Exp = addExp //零头添到这里 petinfo.NextLvExp = calculateExperience(petinfo.Level, ba) break } } - petinfo.Exp = addExp + //petinfo.Exp = addExp petinfo.LvExp = petinfo.NextLvExp - petinfo.Exp // 处理进化逻辑 @@ -119,6 +128,7 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32) { // }) // return exp + } func LastFourElements[T any](s []T) []T { diff --git a/modules/blazing/controller/admin/monster_get.go b/modules/blazing/controller/admin/monster_get.go index bc9f6b927..f147ea8ce 100644 --- a/modules/blazing/controller/admin/monster_get.go +++ b/modules/blazing/controller/admin/monster_get.go @@ -2,10 +2,8 @@ package admin import ( "blazing/cool" - "blazing/modules/blazing/model" "blazing/modules/blazing/service" "context" - "fmt" "github.com/gogf/gf/v2/frame/g" ) @@ -37,14 +35,14 @@ func init() { } func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res *cool.BaseRes, err error) { - fmt.Println(req) - var ( - admin = cool.GetAdmin(ctx) - //r = g.RequestFromCtx(ctx) - ) - t := model.GenPetInfo( - req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.IsShiny, req.Level) - service.NewUserService(uint32(admin.UserId)).PetAdd(*t) + // fmt.Println(req) + // var ( + // admin = cool.GetAdmin(ctx) + // //r = g.RequestFromCtx(ctx) + // ) + // t := model.GenPetInfo( + // req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.IsShiny, req.Level) + // service.NewUserService(uint32(admin.UserId)).PetAdd(*t) return } diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 88c88d840..4a127fb7e 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -1,6 +1,7 @@ package model import ( + "blazing/common/data/xmlres" "blazing/cool" ) @@ -121,6 +122,18 @@ type PetInfo struct { // AbilityType uint32 `struc:"skip"` //特性 } +func (pet *PetInfo) Cure() { + pet.Hp = pet.MaxHp + for i := 0; i < 4; i++ { + maxPP, ok := xmlres.SkillMap[int(pet.SkillList[i].ID)] + // 恢复至最大PP值(从配置表获取) + if pet.SkillList[i].ID != 0 && ok { + pet.SkillList[i].PP = uint32(maxPP.MaxPP) + + } + } +} + // PetEffectInfo 精灵特性信息结构 // //