Merge branch 'main' of github.com:72wo/blazing
This commit is contained in:
@@ -48,8 +48,10 @@ func (s *Server) OnClose(c gnet.Conn, _ error) (action gnet.Action) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
atomic.AddInt64(&s.connected, -1)
|
atomic.AddInt64(&s.connected, -1)
|
||||||
|
|
||||||
//logging.Infof("conn[%v] disconnected", c.RemoteAddr().String())
|
//logging.Infof("conn[%v] disconnected", c.RemoteAddr().String())
|
||||||
v, _ := c.Context().(*player.ClientData)
|
v, _ := c.Context().(*player.ClientData)
|
||||||
|
v.LF.Close()
|
||||||
if v.Player != nil {
|
if v.Player != nil {
|
||||||
v.SaveL.Do(func() { //使用保存锁,确保在踢人和掉线的时候只保存一次
|
v.SaveL.Do(func() { //使用保存锁,确保在踢人和掉线的时候只保存一次
|
||||||
//cool.Loger.Info(context.TODO(), "准备保存", v.Player.Info.UserID)
|
//cool.Loger.Info(context.TODO(), "准备保存", v.Player.Info.UserID)
|
||||||
@@ -140,7 +142,8 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
|||||||
//client := conn.RemoteAddr().String()
|
//client := conn.RemoteAddr().String()
|
||||||
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||||
for _, msg := range messages {
|
for _, msg := range messages {
|
||||||
t.OnEvent(msg.Payload)
|
t.LF.Producer().Write(msg.Payload)
|
||||||
|
//t.OnEvent(msg.Payload)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -164,8 +167,8 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||||
conn.Context().(*player.ClientData).OnEvent(data)
|
//conn.Context().(*player.ClientData).OnEvent(data)
|
||||||
|
conn.Context().(*player.ClientData).LF.Producer().Write(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
if conn.InboundBuffered() > 0 {
|
if conn.InboundBuffered() > 0 {
|
||||||
|
|||||||
@@ -126,9 +126,7 @@ func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *playe
|
|||||||
|
|
||||||
// 接收战斗或者取消战斗的包
|
// 接收战斗或者取消战斗的包
|
||||||
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||||
if !c.CanFight() {
|
|
||||||
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
|
|
||||||
}
|
|
||||||
if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok {
|
if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok {
|
||||||
fight.NewFight(data.Mode, info.BattleStatus.FIGHT_WITH_PLAYER, c, p1) ///开始对战,房主方以及被邀请方
|
fight.NewFight(data.Mode, info.BattleStatus.FIGHT_WITH_PLAYER, c, p1) ///开始对战,房主方以及被邀请方
|
||||||
}
|
}
|
||||||
@@ -164,15 +162,23 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu
|
|||||||
|
|
||||||
// 战斗逃跑
|
// 战斗逃跑
|
||||||
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||||
|
if c.FightC == nil {
|
||||||
|
|
||||||
|
return nil, 0
|
||||||
|
}
|
||||||
|
if !c.FightC.CanEscape() {
|
||||||
|
|
||||||
|
return nil, 0
|
||||||
|
}
|
||||||
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
|
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换精灵
|
// 切换精灵
|
||||||
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||||
|
if c.FightC != nil {
|
||||||
c.FightC.ChangePet(c, data.CatchTime)
|
c.FightC.ChangePet(c, data.CatchTime)
|
||||||
|
}
|
||||||
return nil, -1
|
return nil, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,24 +69,23 @@ func (h *Controller) PetRelease(
|
|||||||
|
|
||||||
switch data.Flag {
|
switch data.Flag {
|
||||||
case 0:
|
case 0:
|
||||||
|
var temp []model.PetInfo
|
||||||
|
|
||||||
removeIndex := -1
|
for _, v := range c.Info.PetList {
|
||||||
for i, v := range c.Info.PetList {
|
|
||||||
if v.CatchTime == uint32(data.CatchTime) {
|
if v.CatchTime == uint32(data.CatchTime) {
|
||||||
removeIndex = i
|
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
||||||
break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
|
t.Data = v
|
||||||
|
t.InBag = 0
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
temp = append(temp, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if removeIndex != -1 {
|
c.Info.PetList = temp
|
||||||
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
// break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
|
||||||
t.Data = c.Info.PetList[removeIndex]
|
|
||||||
t.InBag = 0
|
|
||||||
|
|
||||||
})
|
|
||||||
c.Info.PetList = append(c.Info.PetList[:removeIndex], c.Info.PetList[removeIndex+1:]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
//todo 背包
|
//todo 背包
|
||||||
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *player.Playe
|
|||||||
// if data.Head.CMD != 2204 { //判断是每日任务
|
// if data.Head.CMD != 2204 { //判断是每日任务
|
||||||
// isdaliy = true
|
// isdaliy = true
|
||||||
// }
|
// }
|
||||||
result = &task.AddTaskBufOutboundInfo{}
|
|
||||||
|
|
||||||
c.Service.Task(data.TaskId, func(te *model.TaskEX) bool {
|
c.Service.Task(data.TaskId, func(te *model.TaskEX) bool {
|
||||||
te.Data = data.TaskList
|
te.Data = data.TaskList
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
return &task.AddTaskBufOutboundInfo{}, 0
|
return result, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||||
github.com/antlabs/stl v0.0.2 // indirect
|
github.com/antlabs/stl v0.0.2 // indirect
|
||||||
github.com/bits-and-blooms/bitset v1.5.0 // indirect
|
github.com/bits-and-blooms/bitset v1.5.0 // indirect
|
||||||
|
github.com/bruceshao/lockfree v1.1.2 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLo
|
|||||||
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM=
|
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM=
|
||||||
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
|
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
|
||||||
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||||
|
github.com/bruceshao/lockfree v1.1.2 h1:V3j7bZWS+yDjazffbobpR+ZCVq98DNJcZMvO8vWFLmc=
|
||||||
|
github.com/bruceshao/lockfree v1.1.2/go.mod h1:zkhImea4VTfzWvFF1Lleo1esCZeJLGgrYN+mUuqNrMA=
|
||||||
github.com/brunoga/deep v1.2.5 h1:bigq4eooqbeJXfvTfZBn3AH3B1iW+rtetxVeh0GiLrg=
|
github.com/brunoga/deep v1.2.5 h1:bigq4eooqbeJXfvTfZBn3AH3B1iW+rtetxVeh0GiLrg=
|
||||||
github.com/brunoga/deep v1.2.5/go.mod h1:GDV6dnXqn80ezsLSZ5Wlv1PdKAWAO4L5PnKYtv2dgaI=
|
github.com/brunoga/deep v1.2.5/go.mod h1:GDV6dnXqn80ezsLSZ5Wlv1PdKAWAO4L5PnKYtv2dgaI=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ type FightI interface {
|
|||||||
Capture(c PlayerI, id uint32)
|
Capture(c PlayerI, id uint32)
|
||||||
GetRand() *rand.Rand
|
GetRand() *rand.Rand
|
||||||
LoadPercent(c PlayerI, percent int32)
|
LoadPercent(c PlayerI, percent int32)
|
||||||
|
CanEscape() bool
|
||||||
IsFirst(c PlayerI) bool
|
IsFirst(c PlayerI) bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ type FightC struct {
|
|||||||
closefight bool
|
closefight bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FightC) CanEscape() bool {
|
||||||
|
|
||||||
|
return f.Info.Status != info.BattleStatus.FIGHT_WITH_PLAYER
|
||||||
|
}
|
||||||
func (f *FightC) Ownerid() uint32 {
|
func (f *FightC) Ownerid() uint32 {
|
||||||
|
|
||||||
return f.ownerID
|
return f.ownerID
|
||||||
@@ -260,7 +264,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S
|
|||||||
attacker.Exec(func(t input.Effect) bool { //计算命中 miss改命中
|
attacker.Exec(func(t input.Effect) bool { //计算命中 miss改命中
|
||||||
|
|
||||||
t.Skill_Hit(input.Ctx{ //计算变威力
|
t.Skill_Hit(input.Ctx{ //计算变威力
|
||||||
Input: attacker,
|
Input: defender,
|
||||||
SelectSkillAction: a,
|
SelectSkillAction: a,
|
||||||
}) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
|
}) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
|
||||||
|
|
||||||
@@ -295,9 +299,10 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S
|
|||||||
|
|
||||||
if attacker.AttackValue.IsCritical == 1 {
|
if attacker.AttackValue.IsCritical == 1 {
|
||||||
//暴击破防
|
//暴击破防
|
||||||
if a.SkillEntity.Category() == info.Category.PHYSICAL {
|
if a.SkillEntity.Category() == info.Category.PHYSICAL && defender.Prop[1] > 0 {
|
||||||
|
|
||||||
defender.Prop[1] = 0
|
defender.Prop[1] = 0
|
||||||
} else if a.SkillEntity.Category() == info.Category.SPECIAL {
|
} else if a.SkillEntity.Category() == info.Category.SPECIAL && defender.Prop[3] > 0 {
|
||||||
defender.Prop[3] = 0
|
defender.Prop[3] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,11 +570,13 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
|||||||
t := f.First.GetEffect(input.EffectType.Status, i)
|
t := f.First.GetEffect(input.EffectType.Status, i)
|
||||||
|
|
||||||
if t != nil { //状态都是叠层类的
|
if t != nil { //状态都是叠层类的
|
||||||
ret.FAttack.Status[i] = int8(t.Duration())
|
|
||||||
|
ret.FAttack.Status[i] = int8(t.Duration()) + 1
|
||||||
|
|
||||||
}
|
}
|
||||||
t = f.Second.GetEffect(input.EffectType.Status, i)
|
t = f.Second.GetEffect(input.EffectType.Status, i)
|
||||||
if t != nil {
|
if t != nil {
|
||||||
ret.SAttack.Status[i] = int8(t.Duration())
|
ret.SAttack.Status[i] = int8(t.Duration()) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ func (i *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.
|
|||||||
Add(decimal.NewFromInt(2))
|
Add(decimal.NewFromInt(2))
|
||||||
|
|
||||||
var typeRate decimal.Decimal
|
var typeRate decimal.Decimal
|
||||||
fmt.Println(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
//fmt.Println(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
||||||
t, _ := element.NewElementCalculator().GetOffensiveMultiplier(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
t, _ := element.NewElementCalculator().GetOffensiveMultiplier(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
||||||
|
|
||||||
typeRate = decimal.NewFromFloat(t)
|
typeRate = decimal.NewFromFloat(t)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ func (i *Input) GetPetInfo() *info.BattlePetEntity {
|
|||||||
}
|
}
|
||||||
func (i *Input) ResetAttackValue() {
|
func (i *Input) ResetAttackValue() {
|
||||||
i.AttackValue.SkillID = 0
|
i.AttackValue.SkillID = 0
|
||||||
|
i.AttackValue.IsCritical = 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (c *Input) GetProp(id int, istue bool) int {
|
|||||||
func (c *Input) GetEffect(etype EnumEffectType, id int) Effect {
|
func (c *Input) GetEffect(etype EnumEffectType, id int) Effect {
|
||||||
var ret []Effect
|
var ret []Effect
|
||||||
for _, v := range c.Effects {
|
for _, v := range c.Effects {
|
||||||
if v.ID() == id {
|
if v.ID() == id &&v.Alive(){
|
||||||
ret = append(ret, v)
|
ret = append(ret, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ func (f *FightC) UseSkill(c common.PlayerI, id int32) {
|
|||||||
ret := &action.SelectSkillAction{
|
ret := &action.SelectSkillAction{
|
||||||
BaseAction: action.NewBaseAction(c.GetInfo().UserID),
|
BaseAction: action.NewBaseAction(c.GetInfo().UserID),
|
||||||
}
|
}
|
||||||
//ret.PetInfo = f.GetInputByPlayer(c, false).CurrentPet
|
|
||||||
|
|
||||||
for _, v := range f.GetInputByPlayer(c, false).CurrentPet.Skills {
|
for _, v := range f.GetInputByPlayer(c, false).CurrentPet.Skills {
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"blazing/common/utils/bytearray"
|
"blazing/common/utils/bytearray"
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/bruceshao/lockfree"
|
||||||
"github.com/gobwas/ws"
|
"github.com/gobwas/ws"
|
||||||
"github.com/gobwas/ws/wsutil"
|
"github.com/gobwas/ws/wsutil"
|
||||||
"github.com/gogf/gf/v2/os/glog"
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
@@ -205,19 +207,29 @@ type ClientData struct {
|
|||||||
Wsmsg *WsCodec
|
Wsmsg *WsCodec
|
||||||
Conn gnet.Conn
|
Conn gnet.Conn
|
||||||
SaveL sync.Once //保存锁
|
SaveL sync.Once //保存锁
|
||||||
SaveDone chan struct{}
|
LF *lockfree.Lockfree[[]byte]
|
||||||
|
//SaveDone chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientData(c gnet.Conn) *ClientData {
|
func NewClientData(c gnet.Conn) *ClientData {
|
||||||
// 创建事件处理器
|
// 创建事件处理器
|
||||||
|
// 创建消费端串行处理的Lockfree
|
||||||
|
|
||||||
cd := ClientData{
|
cd := &ClientData{
|
||||||
|
|
||||||
Player: nil,
|
Conn: c,
|
||||||
Conn: c,
|
Wsmsg: &WsCodec{},
|
||||||
Wsmsg: &WsCodec{},
|
|
||||||
}
|
}
|
||||||
return &cd
|
cd.LF = lockfree.NewLockfree[[]byte](
|
||||||
|
1024*1024,
|
||||||
|
cd,
|
||||||
|
lockfree.NewSleepBlockStrategy(time.Millisecond),
|
||||||
|
)
|
||||||
|
// 启动Lockfree
|
||||||
|
if err := cd.LF.Start(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return cd
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +256,14 @@ func XORDecrypt(encryptedData []byte, keyStr string) []byte {
|
|||||||
return decrypted
|
return decrypted
|
||||||
}
|
}
|
||||||
func (h *ClientData) OnEvent(v []byte) {
|
func (h *ClientData) OnEvent(v []byte) {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||||
|
// 1. 打印错误信息
|
||||||
|
|
||||||
|
cool.Loger.Error(context.TODO(), "panic 错误:", err)
|
||||||
|
|
||||||
|
}
|
||||||
|
}()
|
||||||
header := TomeeHeader{}
|
header := TomeeHeader{}
|
||||||
|
|
||||||
tempdata := bytearray.CreateByteArray(v)
|
tempdata := bytearray.CreateByteArray(v)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func (lw *Player) AgreeBattle(userid, flag uint32, mode info.EnumBattleMode) (bo
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if v.Info.UserID == userid && v.PVPinfo.Mode == mode { //成功找到,同意对战
|
if v.Info.UserID == userid && v.PVPinfo.Mode == mode { //成功找到,同意对战
|
||||||
if lw.CanFight() {
|
if lw.CanFight() &&v.CanFight(){
|
||||||
ret.Result = 1
|
ret.Result = 1
|
||||||
|
|
||||||
v.SendPack(t1.Pack(ret))
|
v.SendPack(t1.Pack(ret))
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||||
|
|
||||||
_ "blazing/contrib/drivers/pgsql"
|
_ "blazing/contrib/drivers/pgsql"
|
||||||
"blazing/modules/base/service"
|
|
||||||
|
|
||||||
_ "blazing/contrib/files/local"
|
_ "blazing/contrib/files/local"
|
||||||
|
|
||||||
@@ -27,11 +22,10 @@ import (
|
|||||||
"blazing/login/internal/cmd"
|
"blazing/login/internal/cmd"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/os/gctx"
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
"github.com/gogf/gf/v2/util/gconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
service.TestSendVerificationCode()
|
//service.TestSendVerificationCode()
|
||||||
cmd.Main.Run(gctx.New())
|
cmd.Main.Run(gctx.New())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,23 +41,3 @@ func kick(id int) {
|
|||||||
// fmt.Println(err)
|
// fmt.Println(err)
|
||||||
// }()
|
// }()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ssss struct {
|
|
||||||
ttt int `cmd:"111|222"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_kick() {
|
|
||||||
value := reflect.ValueOf(ssss{})
|
|
||||||
|
|
||||||
// 获取类型
|
|
||||||
typ := value.Type()
|
|
||||||
// 遍历结构体字段
|
|
||||||
// fmt.Printf("结构体 %s 的字段信息:\n", t.Name())
|
|
||||||
for i := 0; i < typ.NumField(); i++ {
|
|
||||||
field := typ.Field(i)
|
|
||||||
t := field.Tag.Get("cmd")
|
|
||||||
//t1 := strings.Split(t, "|")
|
|
||||||
t2 := gconv.SliceUint32(strings.Split(t, "|"))
|
|
||||||
fmt.Println(t2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user