feat(xmlres): 实装性格重塑,实装性格指定
fix(fight): 使用模型层方法生成精灵信息 refactor(controller): 移除冗余变量与内联XML读取逻辑 refactor(pet): 重构经验更新与进化逻辑 refactor(item): 校验并扣减使用道具数量 feat(item): 新增金豆购买商品协议结构体 feat(user): 迁移角色服装变更逻辑至user控制器 feat(pet): 增加技能排序协议定义 refactor(utils): 移除未使用的工具函数引用 chore(config): 更新地图怪物配置信息 详细变更内容包括: - 在`xmlres/file.go`中初始化`GoldProductMap`并加载相关配置。 - 将`GenPetInfo`方法从玩家服务迁移至`model`包以统一管理。 - 合并部分不必要的局部变量声明,并优化XML资源加载方式。 - 拆分精灵升级与进化方法,明确调用职责。 - 在战斗和治疗等操作前增加货币校验及扣除逻辑。 - 补充金豆购买相关的客户端/服务端通信结构体。 - 调整技能选择逻辑避免潜在索引越界问题。 - 更新部分注释说明和代码结构以提升可维护性。
This commit is contained in:
@@ -3,7 +3,6 @@ package controller
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
@@ -11,7 +10,6 @@ import (
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// 获取精灵信息
|
||||
@@ -128,8 +126,13 @@ func (h *Controller) PetRelease(
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
|
||||
index, _, ok := c.FindPet(data.CatchTime)
|
||||
index, v, ok := c.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
c.Service.Pet.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
||||
t.Data = *v
|
||||
//t.InBag = 0
|
||||
|
||||
})
|
||||
c.Info.PetList = append(c.Info.PetList[:index], c.Info.PetList[index+1:]...)
|
||||
}
|
||||
|
||||
@@ -182,6 +185,10 @@ func (h *Controller) PetOneCure(
|
||||
if c.GetSpace().Owner.UserID == c.Info.UserID {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotHeal
|
||||
}
|
||||
|
||||
if !c.UseCoins(20) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
_, onpet, ok := c.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
onpet.Cure()
|
||||
@@ -229,23 +236,6 @@ func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, c *player.Player)
|
||||
Exp: c.Info.ExpPool,
|
||||
}, 0
|
||||
}
|
||||
func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (result *pet.ChangeSkillOutInfo, err errorcode.ErrorCode) {
|
||||
_, onpet, ok := c.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
_, HasSkill, ok := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool { //已经存在技能
|
||||
return item.ID == data.ReplaceSkill
|
||||
})
|
||||
if !ok {
|
||||
HasSkill.ID = data.ReplaceSkill
|
||||
HasSkill.PP = uint32(xmlres.SkillMap[int(HasSkill.ID)].MaxPP)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return &pet.ChangeSkillOutInfo{
|
||||
CatchTime: data.CatchTime,
|
||||
}, 0
|
||||
}
|
||||
|
||||
func (h Controller) PetBargeList(data *pet.PetBargeListInboundInfo, c *player.Player) (result *pet.PetBargeListOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
@@ -253,37 +243,3 @@ func (h Controller) PetBargeList(data *pet.PetBargeListInboundInfo, c *player.Pl
|
||||
PetBargeList: make([]pet.PetBargeListInfo, 0),
|
||||
}, 0
|
||||
}
|
||||
func (h Controller) PetEVdiy(data *pet.PetEV, c *player.Player) (result *pet.S2C_50001, err errorcode.ErrorCode) {
|
||||
_, onpet, ok := c.FindPet(data.CacthTime)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
//分配超过510的数据
|
||||
if lo.Sum(data.EVs[:]) > 510 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
for _, v := range data.EVs {
|
||||
|
||||
//分配超过255的数据
|
||||
if v > 255 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
}
|
||||
if lo.Sum(data.EVs[:]) < lo.Sum(onpet.Ev[:]) {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
USEEV1 := lo.Sum(data.EVs[:]) - lo.Sum(onpet.Ev[:])
|
||||
//加的比池子还多
|
||||
if USEEV1 > c.Info.EVPool {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
onpet.Ev = data.EVs
|
||||
c.Info.EVPool -= USEEV1
|
||||
|
||||
result = &pet.S2C_50001{}
|
||||
result.UseEV = USEEV1
|
||||
return result, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user