2025-11-14 23:09:16 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2026-03-22 23:41:51 +08:00
|
|
|
"blazing/modules/config/service"
|
2026-03-04 22:47:21 +08:00
|
|
|
"blazing/modules/player/model"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
2025-11-19 16:11:02 +08:00
|
|
|
"blazing/logic/service/common"
|
2025-11-14 23:09:16 +08:00
|
|
|
"blazing/logic/service/fight"
|
2025-11-15 01:53:51 +08:00
|
|
|
"blazing/logic/service/fight/info"
|
2025-11-14 23:09:16 +08:00
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
)
|
|
|
|
|
|
2025-11-15 01:53:51 +08:00
|
|
|
//大乱斗
|
2025-11-14 23:09:16 +08:00
|
|
|
|
2026-04-05 07:24:36 +08:00
|
|
|
func (h Controller) PetMelee(data *StartPetWarInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-11-15 01:53:51 +08:00
|
|
|
|
2025-11-19 00:09:12 +00:00
|
|
|
c.Fightinfo.Mode = info.BattleMode.PET_MELEE
|
2025-11-21 02:40:27 +08:00
|
|
|
c.Fightinfo.Status = info.BattleMode.PET_MELEE
|
2026-03-22 23:41:51 +08:00
|
|
|
var mepet []model.PetInfo
|
2025-11-20 15:19:13 +08:00
|
|
|
|
2026-03-22 23:41:51 +08:00
|
|
|
for i, v := range service.NewMELEEService().Def() {
|
|
|
|
|
|
|
|
|
|
if v.Lv == 0 {
|
|
|
|
|
v.Lv = 100
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pet := model.GenPetInfo(int(v.MonID), 24, int(v.Nature), int(v.Effect[0]), int(v.Lv), nil, 0)
|
|
|
|
|
|
|
|
|
|
pet.ConfigBoss(v)
|
|
|
|
|
pet.CatchTime = c.GetInfo().UserID + uint32(i)*1000000
|
|
|
|
|
pet.Cure()
|
|
|
|
|
mepet = append(mepet, *pet)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if len(mepet) < 6 {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSystemError
|
|
|
|
|
}
|
2025-11-20 05:57:29 +08:00
|
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
2026-03-22 23:41:51 +08:00
|
|
|
_, err = fight.NewFight(p, c, mepet[:3], mepet[3:], func(foi model.FightOverInfo) {
|
2025-11-20 15:19:13 +08:00
|
|
|
if foi.Reason == 0 { //我放获胜
|
2025-11-20 05:57:29 +08:00
|
|
|
|
2025-11-20 15:19:13 +08:00
|
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
|
|
|
c.Info.MessWin += 1
|
2026-02-14 04:27:57 +08:00
|
|
|
c.MessWin(true)
|
|
|
|
|
p.MessWin(false)
|
|
|
|
|
|
2025-11-20 15:19:13 +08:00
|
|
|
} else {
|
|
|
|
|
p.GetInfo().MessWin += 1
|
2026-02-14 04:27:57 +08:00
|
|
|
p.MessWin(true)
|
|
|
|
|
c.MessWin(false)
|
2025-11-20 15:19:13 +08:00
|
|
|
}
|
2025-11-20 05:57:29 +08:00
|
|
|
|
|
|
|
|
}
|
2026-03-04 22:47:21 +08:00
|
|
|
if foi.Reason == model.BattleOverReason.PlayerOffline {
|
2026-02-16 02:45:48 +08:00
|
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
|
|
|
|
|
|
|
|
p.MessWin(false)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
c.MessWin(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-15 23:02:46 +00:00
|
|
|
|
|
|
|
|
}) ///开始对战,房主方以及被邀请方
|
2025-12-23 10:46:17 +08:00
|
|
|
return err <= 0
|
2025-11-19 16:11:02 +08:00
|
|
|
})
|
2025-11-15 15:22:58 +08:00
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-04-05 23:13:06 +08:00
|
|
|
|
|
|
|
|
// PetKing 处理控制器请求。
|
2026-04-05 07:24:36 +08:00
|
|
|
func (h Controller) PetKing(data *PetKingJoinInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-11-15 15:22:58 +08:00
|
|
|
|
2025-11-21 02:40:27 +08:00
|
|
|
c.Fightinfo.Status = info.BattleMode.PET_TOPLEVEL
|
2026-04-05 23:13:06 +08:00
|
|
|
// ElementTypeNumbers 是控制器层共享变量。
|
2026-03-05 13:34:06 +08:00
|
|
|
var ElementTypeNumbers = []int{1, 2, 3, 5, 11, 4, 6, 7, 9}
|
2025-11-20 15:19:13 +08:00
|
|
|
|
2025-11-15 15:22:58 +08:00
|
|
|
switch data.Type {
|
|
|
|
|
case 5:
|
2025-11-18 22:16:55 +00:00
|
|
|
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
2025-11-15 15:22:58 +08:00
|
|
|
case 6:
|
2025-11-18 22:16:55 +00:00
|
|
|
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
2026-03-04 20:21:02 +08:00
|
|
|
case 11:
|
2026-03-04 20:52:39 +08:00
|
|
|
//草","水","火","电","战斗","飞行","机械","地面","冰"
|
|
|
|
|
// 按顺序:草、水、火、电、战斗、飞行、机械、地面、冰
|
|
|
|
|
|
2026-03-06 23:49:20 +08:00
|
|
|
//println("11", c.GetPetInfo()[0].Type(), ElementTypeNumbers[data.FightType-1])
|
2026-03-22 23:41:51 +08:00
|
|
|
if c.GetPetInfo(0)[0].Type() != int(ElementTypeNumbers[data.FightType-1]) {
|
2026-03-04 20:21:02 +08:00
|
|
|
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrVictoryConditionNotMet)
|
|
|
|
|
}
|
2026-03-04 20:52:39 +08:00
|
|
|
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
2026-03-04 20:21:02 +08:00
|
|
|
c.Fightinfo.FightType = data.FightType
|
2025-11-15 15:22:58 +08:00
|
|
|
}
|
2026-03-22 23:41:51 +08:00
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
err = c.JoinFight(func(p common.PlayerI) bool {
|
2026-03-24 01:38:02 +08:00
|
|
|
|
|
|
|
|
_, err = fight.NewFight(p, c, p.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) {
|
2025-11-20 15:19:13 +08:00
|
|
|
if foi.Reason == 0 { //我放获胜
|
2026-03-04 20:21:02 +08:00
|
|
|
switch data.Type {
|
|
|
|
|
case 11:
|
|
|
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
2026-03-05 13:34:06 +08:00
|
|
|
c.ItemAdd(80000000+int64(ElementTypeNumbers[data.FightType-1]), 1)
|
2026-03-04 20:21:02 +08:00
|
|
|
} else {
|
2026-03-05 13:34:06 +08:00
|
|
|
p.ItemAdd(80000000+int64(ElementTypeNumbers[data.FightType-1]), 1)
|
2026-03-04 20:21:02 +08:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
if foi.WinnerId == c.GetInfo().UserID {
|
|
|
|
|
c.Info.MonKingWin += 1
|
|
|
|
|
} else {
|
|
|
|
|
p.GetInfo().MonKingWin += 1
|
|
|
|
|
}
|
2025-11-20 15:19:13 +08:00
|
|
|
}
|
2025-11-15 23:02:46 +00:00
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
}
|
2025-11-19 16:11:02 +08:00
|
|
|
}) ///开始对战,房主方以及被邀请方
|
2025-12-23 10:46:17 +08:00
|
|
|
return err <= 0
|
2025-11-19 16:11:02 +08:00
|
|
|
})
|
2025-11-15 01:53:51 +08:00
|
|
|
|
2025-11-14 23:09:16 +08:00
|
|
|
return
|
|
|
|
|
}
|