2025-11-14 23:09:16 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
2025-12-26 20:38:08 +08:00
|
|
|
"blazing/common/data"
|
2025-11-14 23:09:16 +08:00
|
|
|
"blazing/common/data/xmlres"
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2025-11-16 11:56:57 +08:00
|
|
|
"strings"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
2025-11-14 23:09:16 +08:00
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
"blazing/logic/service/fight/info"
|
2026-03-21 00:57:18 +08:00
|
|
|
"blazing/logic/service/fight/input"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
2025-11-14 23:09:16 +08:00
|
|
|
"blazing/logic/service/player"
|
2026-02-26 17:16:38 +08:00
|
|
|
configmodel "blazing/modules/config/model"
|
2026-02-25 19:05:50 +08:00
|
|
|
"blazing/modules/config/service"
|
2026-01-19 18:51:56 +08:00
|
|
|
"blazing/modules/player/model"
|
2025-11-14 23:09:16 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2025-11-22 22:57:32 +08:00
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
2025-11-14 23:09:16 +08:00
|
|
|
)
|
|
|
|
|
|
2026-02-25 19:05:50 +08:00
|
|
|
// PlayerFightBoss 挑战地图boss
|
|
|
|
|
// data: 包含挑战Boss信息的输入数据
|
|
|
|
|
// player: 当前玩家对象
|
|
|
|
|
// 返回: 战斗结果和错误码
|
2026-02-25 21:16:36 +08:00
|
|
|
func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-02-25 19:05:50 +08:00
|
|
|
r := p.CanFight()
|
|
|
|
|
if p.CanFight() != 0 {
|
|
|
|
|
return nil, r
|
|
|
|
|
}
|
|
|
|
|
var monster *model.PetInfo
|
|
|
|
|
monsterInfo := &model.PlayerInfo{}
|
2025-11-16 11:56:57 +08:00
|
|
|
|
2026-02-25 21:16:36 +08:00
|
|
|
mdata := service.NewMapNodeService().GetDataNode(p.Info.MapID, data1.BossId)
|
2026-02-25 19:05:50 +08:00
|
|
|
if mdata == nil {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
2026-02-26 17:16:38 +08:00
|
|
|
var bosinfo []configmodel.BossConfig
|
|
|
|
|
switch len(mdata.BossIds) {
|
|
|
|
|
case 0:
|
2026-02-26 00:05:43 +08:00
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
2026-02-26 17:16:38 +08:00
|
|
|
case 1:
|
|
|
|
|
bosinfo = service.NewBossService().Get(mdata.BossIds[0])
|
|
|
|
|
default:
|
|
|
|
|
bosinfo = service.NewBossService().Get(mdata.BossIds[grand.Intn(len(mdata.BossIds))])
|
2026-02-26 00:05:43 +08:00
|
|
|
}
|
2026-02-26 17:16:38 +08:00
|
|
|
|
|
|
|
|
if len(bosinfo) == 0 {
|
2026-02-25 19:05:50 +08:00
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
|
|
|
|
dv := 24
|
2026-03-30 21:03:00 +08:00
|
|
|
ger := 0
|
2026-02-25 19:05:50 +08:00
|
|
|
if bosinfo[0].IsCapture == 1 {
|
|
|
|
|
dv = -1
|
2026-03-30 21:03:00 +08:00
|
|
|
ger = -1
|
2026-02-25 19:05:50 +08:00
|
|
|
}
|
|
|
|
|
for i, bm := range bosinfo {
|
|
|
|
|
|
|
|
|
|
monster = model.GenPetInfo(
|
|
|
|
|
gconv.Int(bm.MonID), dv, //24个体
|
|
|
|
|
-1,
|
|
|
|
|
0, //野怪没特性
|
|
|
|
|
|
2026-03-30 21:03:00 +08:00
|
|
|
int(bm.Lv), nil, ger)
|
2026-02-25 19:05:50 +08:00
|
|
|
monster.CatchTime = uint32(i)
|
2026-03-07 11:30:17 +08:00
|
|
|
monster.ConfigBoss(bm.PetBaseConfig)
|
2026-03-07 13:54:42 +08:00
|
|
|
effects := service.NewEffectService().Args(bm.Effect)
|
2026-02-25 21:16:36 +08:00
|
|
|
|
2026-03-07 13:54:42 +08:00
|
|
|
for _, v := range effects {
|
|
|
|
|
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
|
|
|
|
Idx: uint16(v.SeIdx),
|
|
|
|
|
EID: gconv.Uint16(v.Eid),
|
|
|
|
|
Args: gconv.Ints(v.Args),
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-02-25 19:05:50 +08:00
|
|
|
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
|
|
|
|
}
|
|
|
|
|
if bosinfo[0].IsCapture == 1 {
|
2026-02-25 21:16:36 +08:00
|
|
|
monsterInfo.PetList[0].ShinyInfo = make([]data.GlowFilter, 0)
|
2026-02-25 19:05:50 +08:00
|
|
|
if grand.Meet(1, 500) {
|
|
|
|
|
monsterInfo.PetList[0].RandomByWeightShiny()
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
}
|
2026-02-25 19:05:50 +08:00
|
|
|
monsterInfo.Nick = mdata.NodeName //xmlres.PetMAP[int(monster.ID)].DefName
|
2026-02-25 19:46:31 +08:00
|
|
|
|
2026-02-25 19:05:50 +08:00
|
|
|
if len(monsterInfo.PetList) == 0 {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
2025-11-16 11:56:57 +08:00
|
|
|
}
|
2026-02-25 19:05:50 +08:00
|
|
|
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
|
|
|
|
|
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
|
|
|
|
|
|
|
|
|
ai := player.NewAI_player(monsterInfo)
|
2026-02-25 19:46:31 +08:00
|
|
|
ai.CanCapture = bosinfo[0].IsCapture
|
2026-02-26 00:05:43 +08:00
|
|
|
if bosinfo[0].IsCapture != 0 {
|
|
|
|
|
ai.CanCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
|
|
|
|
|
if xmlres.PetMAP[int(monster.ID)].CatchRate == 0 {
|
|
|
|
|
ai.CanCapture = 0
|
|
|
|
|
}
|
2026-02-25 19:46:31 +08:00
|
|
|
}
|
2026-02-26 00:05:43 +08:00
|
|
|
|
2026-02-25 19:05:50 +08:00
|
|
|
ai.Prop[0] = 2
|
2026-03-21 00:57:18 +08:00
|
|
|
var fighc *fight.FightC
|
2026-03-22 23:41:51 +08:00
|
|
|
fighc, _ = fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
2026-02-25 19:46:31 +08:00
|
|
|
if mdata.WinBonusID != 0 {
|
2026-03-21 01:06:59 +08:00
|
|
|
if len(bosinfo[0].Rule) == 0 {
|
2026-03-21 00:57:18 +08:00
|
|
|
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
|
|
|
|
p.SptCompletedTask(mdata.WinBonusID, 1)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//说明是带规则的
|
|
|
|
|
iswin := true
|
2026-03-21 01:06:59 +08:00
|
|
|
for _, v := range service.NewFightRuleService().GetByRuleIdxs(bosinfo[0].Rule) {
|
2026-03-21 00:57:18 +08:00
|
|
|
r := input.GetRule(int64(v.RuleIdx))
|
|
|
|
|
if r != nil {
|
|
|
|
|
r.SetArgs(v.Args...)
|
|
|
|
|
|
|
|
|
|
if !(r.Exec(fighc, &foi)) {
|
|
|
|
|
iswin = false
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if iswin {
|
|
|
|
|
p.SptCompletedTask(mdata.WinBonusID, 1)
|
|
|
|
|
}
|
2026-02-25 19:05:50 +08:00
|
|
|
}
|
2026-03-21 00:57:18 +08:00
|
|
|
|
2026-02-25 19:05:50 +08:00
|
|
|
}
|
2025-11-16 11:56:57 +08:00
|
|
|
|
2026-02-25 19:05:50 +08:00
|
|
|
//p.Done.Exec(model.MilestoneMode.BOSS, []uint32{p.Info.MapID, data.BossId, uint32(foi.Reason)}, nil)
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-11-14 23:09:16 +08:00
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
// OnPlayerFightNpcMonster 战斗野怪
|
2025-12-25 12:26:18 +08:00
|
|
|
// data: 包含战斗野怪信息的输入数据
|
|
|
|
|
// player: 当前玩家对象
|
|
|
|
|
// 返回: 战斗结果和错误码
|
2026-01-25 03:40:29 +08:00
|
|
|
func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-02-25 16:18:10 +08:00
|
|
|
r := p.CanFight()
|
|
|
|
|
if p.CanFight() != 0 {
|
|
|
|
|
return nil, r
|
2025-12-01 23:31:48 +08:00
|
|
|
}
|
2026-02-09 01:29:33 +08:00
|
|
|
if data1.Number > 9 {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSystemError
|
|
|
|
|
}
|
2026-02-23 04:12:12 +08:00
|
|
|
refPet := p.Data[data1.Number]
|
2026-02-08 17:57:42 +08:00
|
|
|
if refPet.ID == 0 {
|
2025-11-14 23:09:16 +08:00
|
|
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
2026-01-01 00:30:09 +08:00
|
|
|
|
2025-12-25 12:26:18 +08:00
|
|
|
monster := model.GenPetInfo(
|
2026-02-26 19:22:04 +08:00
|
|
|
int(refPet.GetID()), -1,
|
2025-11-14 23:09:16 +08:00
|
|
|
-1,
|
|
|
|
|
0, //野怪没特性
|
2025-12-14 19:23:26 +08:00
|
|
|
|
2026-02-26 19:28:02 +08:00
|
|
|
int(refPet.GetLevel()),
|
2026-02-08 17:57:42 +08:00
|
|
|
refPet.ShinyInfo, -1)
|
2026-02-18 22:07:50 +08:00
|
|
|
monster.CatchMap = p.Info.MapID //设置当前地图
|
2026-01-01 00:30:09 +08:00
|
|
|
if refPet.Ext != 0 {
|
2026-02-21 17:32:40 +08:00
|
|
|
if grand.Meet(1, 500) {
|
|
|
|
|
monster.RandomByWeightShiny()
|
|
|
|
|
}
|
2026-01-01 00:30:09 +08:00
|
|
|
}
|
2025-11-14 23:09:16 +08:00
|
|
|
|
2025-12-25 12:26:18 +08:00
|
|
|
monsterInfo := &model.PlayerInfo{}
|
|
|
|
|
monsterInfo.Nick = xmlres.PetMAP[int(monster.ID)].DefName
|
|
|
|
|
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
|
|
|
|
ai := player.NewAI_player(monsterInfo)
|
2026-02-25 16:18:10 +08:00
|
|
|
|
|
|
|
|
ai.CanCapture = refPet.IsCapture //handleNPCFightSpecial(monster.ID)
|
2025-11-19 16:11:02 +08:00
|
|
|
|
2025-12-25 12:26:18 +08:00
|
|
|
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪
|
|
|
|
|
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
2025-11-14 23:09:16 +08:00
|
|
|
|
2026-03-22 23:41:51 +08:00
|
|
|
fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
2026-01-19 18:51:56 +08:00
|
|
|
//p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil)
|
2026-02-27 14:48:10 +08:00
|
|
|
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID && p.CanGet() {
|
2025-11-25 00:55:10 +08:00
|
|
|
|
2025-12-25 12:26:18 +08:00
|
|
|
exp := uint32(xmlres.PetMAP[int(monster.ID)].YieldingExp) * monster.Level / 7
|
2026-02-16 03:02:59 +08:00
|
|
|
addlevel, poolevel := p.CanGetExp()
|
2026-02-16 03:33:41 +08:00
|
|
|
addexp := gconv.Float32(addlevel * gconv.Float32(exp))
|
2026-02-27 14:48:10 +08:00
|
|
|
|
|
|
|
|
poolexp := gconv.Float32(poolevel) * gconv.Float32((exp))
|
|
|
|
|
items := &info.S2C_GET_BOSS_MONSTER{}
|
|
|
|
|
|
|
|
|
|
p.ItemAdd(3, int64(poolexp+addexp))
|
|
|
|
|
items.ADDitem(3, uint32(poolexp))
|
|
|
|
|
|
|
|
|
|
p.AddPetExp(foi.Winpet, int64(addexp))
|
2026-03-01 08:59:39 +08:00
|
|
|
pettype := int64(xmlres.PetMAP[int(refPet.GetID())].Type)
|
2026-02-27 14:48:10 +08:00
|
|
|
|
|
|
|
|
if p.CanGetItem() {
|
|
|
|
|
|
2026-03-03 14:04:41 +08:00
|
|
|
item := p.GetSpace().GetDrop()
|
|
|
|
|
if item != 0 {
|
2026-03-10 09:36:22 +08:00
|
|
|
count := int64(grand.N(1, 2))
|
2026-02-27 14:48:10 +08:00
|
|
|
ok := p.ItemAdd(item, count)
|
2026-02-23 03:56:27 +08:00
|
|
|
if ok {
|
2026-02-27 23:29:16 +08:00
|
|
|
items.ADDitem(uint32(item), uint32(count))
|
2026-02-23 03:56:27 +08:00
|
|
|
}
|
2026-02-19 16:02:23 +08:00
|
|
|
}
|
2026-02-23 03:56:27 +08:00
|
|
|
|
2025-11-22 22:57:32 +08:00
|
|
|
}
|
2026-03-04 12:48:49 +08:00
|
|
|
if monster.IsShiny() && p.CanGetXUAN() && pettype < 16 {
|
|
|
|
|
xuan := 400686 + pettype
|
2026-03-10 09:36:22 +08:00
|
|
|
count := uint32(grand.N(1, 2))
|
|
|
|
|
ok := p.ItemAdd(xuan, int64(count))
|
2026-03-04 12:48:49 +08:00
|
|
|
if ok {
|
2026-03-10 09:36:22 +08:00
|
|
|
items.ADDitem(uint32(xuan), count)
|
2026-03-04 12:48:49 +08:00
|
|
|
}
|
2025-11-15 23:02:46 +00:00
|
|
|
|
2026-03-04 12:48:49 +08:00
|
|
|
}
|
2026-02-27 14:48:10 +08:00
|
|
|
p.SendPackCmd(8004, items)
|
|
|
|
|
|
2026-02-12 04:28:20 +08:00
|
|
|
evs := gconv.Int64s(strings.Split(xmlres.PetMAP[int(monster.ID)].YieldingEV, " "))
|
2026-02-13 03:34:37 +08:00
|
|
|
|
2025-12-01 23:31:48 +08:00
|
|
|
foi.Winpet.AddEV(evs)
|
2026-02-13 22:57:05 +08:00
|
|
|
//取消累计学习力掉落
|
|
|
|
|
// if leve == 8 {
|
|
|
|
|
// items.EV = lo.Sum(evs) - 1
|
|
|
|
|
// p.Info.EVPool += lo.Sum(evs) //给予累计学习力
|
|
|
|
|
// }
|
2025-12-01 23:31:48 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-15 23:02:46 +00:00
|
|
|
})
|
2025-11-14 23:09:16 +08:00
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|