From 3b4862e7a6eb3cafb3da6e8f77a642d7f55092cc Mon Sep 17 00:00:00 2001 From: xinian Date: Thu, 12 Mar 2026 10:07:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20effe?= =?UTF-8?q?ct=5F413.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/effect/effect_413.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/service/fight/effect/effect_413.go b/logic/service/fight/effect/effect_413.go index 6d96887d..db3228ea 100644 --- a/logic/service/fight/effect/effect_413.go +++ b/logic/service/fight/effect/effect_413.go @@ -29,7 +29,7 @@ func (e *Effect413) OnSkill() bool { if isprop { e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ Type: info.DamageType.Fixed, - Damage: e.Ctx().Opp.CurrentPet.GetHP().Div(e.Args()[0]), + Damage: e.Args()[0], }) } From 77201382901ab5f09874ac0f05908c1683a7840d Mon Sep 17 00:00:00 2001 From: xinian Date: Thu, 12 Mar 2026 11:11:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=A0=E7=89=A9?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7ID?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/player/service/pet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/player/service/pet.go b/modules/player/service/pet.go index e7cd7ff6..bb55524e 100644 --- a/modules/player/service/pet.go +++ b/modules/player/service/pet.go @@ -101,7 +101,7 @@ func (s *PetService) BuyPet(pid uint32) error { useglod := int64(tt.SalePrice)*102 + int64(tt.SaleCount)*5 var res1 basemodel.BaseSysUser - tx.Model(basemodel.BaseSysUser{}).Where("id", tt.PlayerID).Fields("free_gold").Scan(&res1) + tx.Model(basemodel.BaseSysUser{}).Where("id", s.userid).Fields("free_gold").Scan(&res1) if res1.FreeGold < useglod { return fmt.Errorf("余额不足") } From af09d1ae864c724ebb81712ae1784f47c46ed7cb Mon Sep 17 00:00:00 2001 From: xinian Date: Thu, 12 Mar 2026 14:35:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96RPC=E5=AF=B9?= =?UTF-8?q?=E6=88=98=E5=8A=A0=E5=85=A5=E4=B8=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/rpc/func.go | 3 +- common/rpc/user.go | 51 ++++++++++---------------------- logic/service/fight/info/info.go | 10 +++++++ logic/service/player/player.go | 1 + 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/common/rpc/func.go b/common/rpc/func.go index c4bbaf61..3fc6d480 100644 --- a/common/rpc/func.go +++ b/common/rpc/func.go @@ -82,8 +82,7 @@ func ListenFunc(ctx g.Ctx) { continue } cool.Logger.Info(ctx, "成功订阅 Redis 主题", "topic", subscribeTopic) - _, err = conn.Do(ctx, "subscribe", "sun:join") //加入队列 - _, err = conn.Do(ctx, "subscribe", "sun:cancel") //退出队列 + _, err = conn.Do(ctx, "subscribe", "sun:join") //加入队列 // 4. 循环接收消息 connError := false diff --git a/common/rpc/user.go b/common/rpc/user.go index 0de32417..db541cbb 100644 --- a/common/rpc/user.go +++ b/common/rpc/user.go @@ -17,42 +17,10 @@ type RPCfight struct { zs *zset.ZSet[uint32, *model.PVP] } -// // ExtractBetweenBrackets 提取字符串中第一个 [] 中间的文本 -// // 返回值:中间文本、是否成功、错误信息 -// func ExtractBetweenBrackets(s string) (string, bool, error) { -// // 1. 找到第一个 [ 的索引 -// leftIdx := strings.Index(s, "[") -// if leftIdx == -1 { -// return "", false, errors.New("未找到左中括号 [") -// } +func (r *RPCfight) join(pvp info.RPCFightinfo) { -// // 2. 找到第一个 [ 之后的第一个 ] 的索引 -// rightIdx := strings.Index(s[leftIdx+1:], "]") -// if rightIdx == -1 { -// return "", false, errors.New("找到左中括号 [ 但未找到对应的右中括号 ]") -// } - -// // 3. 计算实际的右中括号索引(加上 leftIdx+1) -// rightIdx += leftIdx + 1 - -// // 4. 提取中间文本(去除前后空格,可选) -// result := strings.TrimSpace(s[leftIdx+1 : rightIdx]) - -// // 5. 检查是否为空 -// if result == "" { -// return "", true, errors.New("中括号中间无文本") -// } - -// return result, true, nil -// } - -func (r *RPCfight) ADD(s string) { - println("收到sun:join", s) - var pvp info.RPCFightinfo - json.Unmarshal([]byte(s), &pvp) - //t, _, _ := ExtractBetweenBrackets(s) ret := service.NewPVPService(pvp.PlayerID).Get(pvp.PlayerID) - score := 1000 + score := 800 if ret != nil { score = int(ret.RankInfo.Score) } @@ -73,8 +41,19 @@ func (r *RPCfight) ADD(s string) { } } -func (r *RPCfight) Cancel(s string) { - // r.zs.Remove() +func (r *RPCfight) ADD(s string) { + println("收到sun:join", s) + var pvp info.RPCFightinfo + json.Unmarshal([]byte(s), &pvp) + if pvp.Type == 1 { + r.join(pvp) + } else { //==0 退出 + r.cancel(pvp) + } + +} +func (r *RPCfight) cancel(pvp info.RPCFightinfo) { + r.zs.Remove(pvp.PlayerID) } ///定义map,存储用户对战斗容器的映射,便于外部传入时候进行直接操作 diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index 9361137f..20d93f95 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -52,6 +52,7 @@ type Fightinfo struct { FightType uint32 } type RPCFightinfo struct { + Type int PlayerID uint32 // 战斗模式 1 = 1v1 2 = 6v6 3大乱斗 0 什么都不做 Mode uint32 @@ -60,6 +61,15 @@ type RPCFightinfo struct { Status uint32 // FightType uint32 } +type RPCFightStartinfo struct { + Servierid int // 非0表示rpc跨服 + PlayerID uint32 + // 战斗模式 1 = 1v1 2 = 6v6 3大乱斗 0 什么都不做 + Mode uint32 + //Type uint32 //战斗类型 + + Status uint32 +} // FightPetInfo 战斗精灵信息结构体,FightPetInfo类 type FightPetInfo struct { diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 3e3b8cb3..9dfe6d49 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -93,6 +93,7 @@ type Player struct { MainConn gnet.Conn baseplayer IsLogin bool //是否登录 + IsJoin bool //是否加入RPC对局 用重连函数写临时缓存join,重连后统一join Done MapNPC *time.Timer