refactor(model): 重构 GenPetInfo 函数参数处理逻辑
- 将 GenPetInfo 函数的参数从单个值改为切片,以支持更灵活的配置 - 新增 RandomInRange 函数,用于从切片表示的范围内随机选择值 - 更新了 fight 控制器和 task 控制器中调用 GenPetInfo 函数的代码 - 此重构提高了代码的可读性和可维护性,同时保留了原有的功能
This commit is contained in:
@@ -3,9 +3,6 @@ package controller
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"blazing/logic/service"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/fight/info"
|
||||
@@ -35,8 +32,12 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
|
||||
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
|
||||
refpet := c.OgreInfo.Data[data.Number]
|
||||
|
||||
dv := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(32)
|
||||
mo := model.GenPetInfo(refpet.Id, uint32(dv), 0, 1006, refpet.Shiny, refpet.Lv)
|
||||
mo := model.GenPetInfo(
|
||||
int(refpet.Id), []int{0, 31},
|
||||
[]int{0, 24},
|
||||
[]int{0}, //野怪没特性
|
||||
[]int{int(refpet.Shiny)},
|
||||
[]int{int(refpet.Lv)})
|
||||
ttt.OpponentPetList = make([]info.ReadyFightPetInfo, 1)
|
||||
|
||||
err1 := copier.CopyWithOption(&ttt.OpponentPetList[0], &mo, copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
||||
|
||||
Reference in New Issue
Block a user