feat: 添加宠物训练加成效果
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -384,10 +384,15 @@ func (pet *PetInfo) RnadEffect() {
|
||||
// 8 :体力提升加成
|
||||
|
||||
const (
|
||||
maxHPUpEffectIdx uint16 = 60000
|
||||
maxHPUpEffectStatus byte = 8
|
||||
maxHPUpEffectEID uint16 = 26
|
||||
maxHPUpEffectCap = 20
|
||||
maxHPUpEffectIdx uint16 = 60000
|
||||
maxHPUpEffectStatus byte = 8
|
||||
maxHPUpEffectEID uint16 = 26
|
||||
maxHPUpEffectCap = 20
|
||||
trainingEffectStatus byte = 5
|
||||
trainingAttrEffectIdx uint16 = 60001
|
||||
trainingPowerEffectIdx uint16 = 60002
|
||||
trainingAttrEffectEID uint16 = 247
|
||||
trainingPowerEffectEID uint16 = 239
|
||||
)
|
||||
|
||||
// 繁殖加成,体力提升加成 ,这里是防止和其他重复所以定义不同类别,但是实际上,能量珠那些事调用不同id的effect实现
|
||||
@@ -400,6 +405,56 @@ func (pet *PetInfo) GetEffect(ptype int) (int, *PetEffectInfo, bool) {
|
||||
|
||||
}
|
||||
|
||||
func (pet *PetInfo) getEffectByStatusAndEID(status byte, eid uint16) (int, *PetEffectInfo, bool) {
|
||||
return utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
return item.Status == status && item.EID == eid
|
||||
})
|
||||
}
|
||||
|
||||
func ensureEffectArgsLen(args []int, size int) []int {
|
||||
if len(args) >= size {
|
||||
return args
|
||||
}
|
||||
next := make([]int, size)
|
||||
copy(next, args)
|
||||
return next
|
||||
}
|
||||
|
||||
func (pet *PetInfo) addTrainingEffectDelta(idx uint16, eid uint16, argsLen int, argIndex int, value int) bool {
|
||||
if pet == nil || value <= 0 || argIndex < 0 || argIndex >= argsLen {
|
||||
return false
|
||||
}
|
||||
|
||||
if _, eff, ok := pet.getEffectByStatusAndEID(trainingEffectStatus, eid); ok {
|
||||
if eff.Idx == 0 {
|
||||
eff.Idx = idx
|
||||
}
|
||||
eff.Status = trainingEffectStatus
|
||||
eff.EID = eid
|
||||
eff.Args = ensureEffectArgsLen(eff.Args, argsLen)
|
||||
eff.Args[argIndex] += value
|
||||
return true
|
||||
}
|
||||
|
||||
args := make([]int, argsLen)
|
||||
args[argIndex] = value
|
||||
pet.EffectInfo = append(pet.EffectInfo, PetEffectInfo{
|
||||
Idx: idx,
|
||||
Status: trainingEffectStatus,
|
||||
EID: eid,
|
||||
Args: args,
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
func (pet *PetInfo) AddTrainingAttrBonus(attr int, value int) bool {
|
||||
return pet.addTrainingEffectDelta(trainingAttrEffectIdx, trainingAttrEffectEID, 6, attr, value)
|
||||
}
|
||||
|
||||
func (pet *PetInfo) AddTrainingPowerBonus(value int) bool {
|
||||
return pet.addTrainingEffectDelta(trainingPowerEffectIdx, trainingPowerEffectEID, 2, 0, value)
|
||||
}
|
||||
|
||||
func (pet *PetInfo) AddMaxHPUpEffect(itemID uint32, value int) bool {
|
||||
if pet == nil || value <= 0 {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user