```
feat: 更新战斗系统模型结构和Redis消息处理 - 引入gredis依赖用于Redis消息处理 - 将战斗相关的枚举和结构体从info包迁移到model包 - 更新战斗结束原因、攻击值等类型的引用路径 - 添加新的zset工具包到工作区 - 修改Redis消息处理逻辑以正确解析gredis.Message类型 - 在战斗控制器中统一使用model包下的类型定义
This commit is contained in:
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/fight/info"
|
||||
@@ -40,7 +41,7 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
|
||||
go c.FightC.Over(c, model.BattleOverReason.PlayerEscape)
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
|
||||
}
|
||||
|
||||
ai.Prop[0] = 2
|
||||
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
fight.NewFight(p, ai, func(foi model.FightOverInfo) {
|
||||
if mdata.WinBonusID != 0 {
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
p.SptCompletedTask(mdata.WinBonusID, 1)
|
||||
@@ -159,7 +159,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪
|
||||
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
||||
|
||||
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
fight.NewFight(p, ai, func(foi model.FightOverInfo) {
|
||||
//p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil)
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID && p.CanGet() {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight"
|
||||
@@ -17,7 +18,7 @@ func (h Controller) PetMelee(data *fight.StartPetWarInboundInfo, c *player.Playe
|
||||
c.Fightinfo.Status = info.BattleMode.PET_MELEE
|
||||
|
||||
err = c.JoinFight(func(p common.PlayerI) bool {
|
||||
_, err = fight.NewFight(p, c, func(foi info.FightOverInfo) {
|
||||
_, err = fight.NewFight(p, c, func(foi model.FightOverInfo) {
|
||||
if foi.Reason == 0 { //我放获胜
|
||||
|
||||
if foi.WinnerId == c.GetInfo().UserID {
|
||||
@@ -32,7 +33,7 @@ func (h Controller) PetMelee(data *fight.StartPetWarInboundInfo, c *player.Playe
|
||||
}
|
||||
|
||||
}
|
||||
if foi.Reason == info.BattleOverReason.PlayerOffline {
|
||||
if foi.Reason == model.BattleOverReason.PlayerOffline {
|
||||
if foi.WinnerId == c.GetInfo().UserID {
|
||||
|
||||
p.MessWin(false)
|
||||
@@ -71,7 +72,7 @@ func (h Controller) PetKing(data *fight.PetKingJoinInboundInfo, c *player.Player
|
||||
c.Fightinfo.FightType = data.FightType
|
||||
}
|
||||
err = c.JoinFight(func(p common.PlayerI) bool {
|
||||
_, err = fight.NewFight(p, c, func(foi info.FightOverInfo) {
|
||||
_, err = fight.NewFight(p, c, func(foi model.FightOverInfo) {
|
||||
if foi.Reason == 0 { //我放获胜
|
||||
switch data.Type {
|
||||
case 11:
|
||||
|
||||
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
"sync/atomic"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
@@ -54,7 +55,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
|
||||
return
|
||||
}
|
||||
|
||||
_, err = fight.NewFight(v, c, func(foi info.FightOverInfo) {
|
||||
_, err = fight.NewFight(v, c, func(foi model.FightOverInfo) {
|
||||
|
||||
//println("好友对战测试", foi.Reason)
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
}
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
_, err = fight.NewFight(c, ai, func(foi fightinfo.FightOverInfo) {
|
||||
_, err = fight.NewFight(c, ai, func(foi model.FightOverInfo) {
|
||||
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜
|
||||
switch data.Head.CMD {
|
||||
case 2429: //试炼之塔
|
||||
|
||||
@@ -5,11 +5,8 @@ import (
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/fight/top/repo"
|
||||
"blazing/logic/service/player"
|
||||
"context"
|
||||
|
||||
goredis "github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// 表示"宠物王加入"的入站消息数据
|
||||
@@ -20,11 +17,10 @@ type PetTOPLEVELnboundInfo struct {
|
||||
}
|
||||
|
||||
func (h Controller) JoINtop(data *PetTOPLEVELnboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
cool.RedisDo(context.TODO(), "sun:join:2458", data.Head.UserID, data.Mode)
|
||||
client := cool.Redis.Client()
|
||||
cool.RedisDo(context.TODO(), "sun:join:2458", data.Head.UserID)
|
||||
|
||||
// 类型断言为 UniversalClient
|
||||
universalClient, _ := client.(goredis.UniversalClient)
|
||||
repo.NewPlayerRepository(universalClient).AddPlayerToPool(context.TODO(), data.Head.UserID, 1)
|
||||
// // 类型断言为 UniversalClient
|
||||
// universalClient, _ := client.(goredis.UniversalClient)
|
||||
// repo.NewPlayerRepository(universalClient).AddPlayerToPool(context.TODO(), data.Head.UserID, 1)
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
"sync/atomic"
|
||||
|
||||
"blazing/logic/service/fight"
|
||||
@@ -66,7 +67,7 @@ func (h Controller) ArenaFightOwner(data1 *fight.ARENA_FIGHT_OWENR, c *player.Pl
|
||||
c.Fightinfo.Mode = info.BattleMode.SINGLE_MODE
|
||||
c.Fightinfo.Status = info.BattleMode.FIGHT_ARENA
|
||||
|
||||
_, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, func(foi info.FightOverInfo) { //我方邀请擂主挑战,我方先手
|
||||
_, err = fight.NewFight(c, c.GetSpace().Owner.ARENA_Player, func(foi model.FightOverInfo) { //我方邀请擂主挑战,我方先手
|
||||
|
||||
if foi.Reason != 0 && foi.WinnerId == c.GetInfo().UserID { //异常退出
|
||||
|
||||
|
||||
Reference in New Issue
Block a user