Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2023-01-29 10:05:23 +08:00
commit 9d49e58a2e
4 changed files with 33 additions and 11 deletions

View File

@ -48,8 +48,6 @@ type (
//查询用户卡片数量
QueryHeroAmount(uId string, heroCfgId string) (amount uint32)
//创建指定数量
CreateRepeatHero(session IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode)
// 批量创建英雄
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode)
// 获取英雄

View File

@ -276,12 +276,33 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
update["totalcount"] = heroRecord.Totalcount
update["daycount"] = heroRecord.Daycount
this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update)
szNewCards := make([]*cfg.Gameatn, 0)
for _, heroId := range szCards {
bFind := false
_mapAddHero[heroId]++
for _, v := range szNewCards {
if v.T == heroId {
v.N++
bFind = true
break
}
_, code = this.module.CreateRepeatHeros(session, _mapAddHero, true)
}
if !bFind {
res := &cfg.Gameatn{
A: "hero",
T: heroId,
N: 1,
}
szNewCards = append(szNewCards, res)
}
}
// 获得新卡
if code = this.module.DispenseRes(session, szNewCards, true); code != pb.ErrorCode_Success {
this.module.Errorf("err:%v,create heros:%v,uid,%s", code, szNewCards, session.GetUserId())
code = pb.ErrorCode_HeroCreate // 创建新英雄失败
}
///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
this.module.SendChatMsg(session, _mapAddHero, szCards)

View File

@ -3,6 +3,7 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto"
@ -74,12 +75,14 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c
}
// 获得新卡
var new map[string]int32
new = make(map[string]int32)
new[conf.Hero] = 1
if _, err := this.module.CreateRepeatHeros(session, new, false); err != pb.ErrorCode_Success {
res := &cfg.Gameatn{
A: "hero",
T: conf.Hero,
N: 1,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, false); code != pb.ErrorCode_Success {
this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId())
this.module.Errorf("err:%v,create hero:%s,uid,%ss", code, conf.Hero, session.GetUserId())
code = pb.ErrorCode_HeroCreate // 创建新英雄失败
}
session.SendMsg(string(this.module.GetType()), HeroFusionResp, &pb.HeroFusionResp{Heroid: conf.Hero})

View File

@ -76,7 +76,7 @@ func (this *Hero) Start() (err error) {
}
//创建单个叠加英雄
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) {
func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) {
var err error
hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
if err == nil {
@ -272,7 +272,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
if num == 0 { // 数量为0 不做处理
continue
}
if hero, code = this.CreateRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success {
if hero, code = this.createRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success {
this.Errorf("create hero %s failed", heroCfgId)
return
}