This commit is contained in:
liwei 2022-07-22 22:06:16 +08:00
commit d520420919
3 changed files with 53 additions and 9 deletions

View File

@ -5,7 +5,7 @@
{ {
"a": "hero", "a": "hero",
"t": "25001", "t": "25001",
"n": 1 "n": 5
} }
] ]
}, },
@ -15,7 +15,7 @@
{ {
"a": "attr", "a": "attr",
"t": "gold", "t": "gold",
"n": 50000 "n": 5000000
} }
] ]
}, },
@ -25,7 +25,7 @@
{ {
"a": "hero", "a": "hero",
"t": "24003", "t": "24003",
"n": 1 "n": 5
} }
] ]
}, },
@ -35,7 +35,7 @@
{ {
"a": "hero", "a": "hero",
"t": "25004", "t": "25004",
"n": 1 "n": 5
} }
] ]
}, },
@ -45,7 +45,7 @@
{ {
"a": "hero", "a": "hero",
"t": "35002", "t": "35002",
"n": 1 "n": 5
} }
] ]
}, },
@ -118,5 +118,45 @@
"n": 1 "n": 1
} }
] ]
},
{
"index": "13",
"var": [
{
"a": "hero",
"t": "42911",
"n": 10
}
]
},
{
"index": "14",
"var": [
{
"a": "hero",
"t": "43911",
"n": 10
}
]
},
{
"index": "15",
"var": [
{
"a": "hero",
"t": "44911",
"n": 10
}
]
},
{
"index": "16",
"var": [
{
"a": "hero",
"t": "43901",
"n": 10
}
]
} }
] ]

View File

@ -258,6 +258,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Game_at
func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) { func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) {
var ( var (
resID int resID int
hero []*pb.DBHero
) )
source := &comm.ModuleCallSource{ source := &comm.ModuleCallSource{
Module: string(this.module.GetType()), Module: string(this.module.GetType()),
@ -275,18 +276,21 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Game_a
code = this.ModuleItems.AddItem(source, session, int32(resID), v.N, bPush) code = this.ModuleItems.AddItem(source, session, int32(resID), v.N, bPush)
} else if v.A == comm.HeroType { //卡片资源 } else if v.A == comm.HeroType { //卡片资源
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
hero, err := this.ModuleHero.CreateRepeatHero(session.GetUserId(), int32(resID), v.N) _hero, err := this.ModuleHero.CreateRepeatHero(session.GetUserId(), int32(resID), v.N)
if err != nil { if err != nil {
code = pb.ErrorCode_HeroMaxCount code = pb.ErrorCode_HeroMaxCount
return return
} }
hero = append(hero, _hero)
session.SendMsg("hero", "change", &pb.HeroChangePush{List: []*pb.DBHero{hero}})
} else if v.A == comm.EquipmentType { } else if v.A == comm.EquipmentType {
resID, _ = strconv.Atoi(v.T) resID, _ = strconv.Atoi(v.T)
code = this.ModuleEquipment.AddNewEquipments(source, session, map[int32]uint32{int32(resID): uint32(v.N)}, bPush) code = this.ModuleEquipment.AddNewEquipments(source, session, map[int32]uint32{int32(resID): uint32(v.N)}, bPush)
} }
} }
if len(hero) > 0 {
session.SendMsg("hero", "change", &pb.HeroChangePush{List: hero})
}
return return
} }

View File

@ -71,7 +71,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
if val, err := this.module.configure.GetGlobalInitConf(); err == nil { if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
for _, v := range val.GetDataList() { for _, v := range val.GetDataList() {
code = this.module.DispenseRes(session, v.Var, false) code = this.module.DispenseRes(session, v.Var, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
this.module.Errorf("资源发放失败,%v", code) this.module.Errorf("资源发放失败,%v", code)
} }