Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
f5a202bfea
@ -24,7 +24,9 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
var (
|
||||
awakenData *cfg.Game_heroAwakenData
|
||||
_hero *pb.DBHero
|
||||
chanegCard []*pb.DBHero // change
|
||||
)
|
||||
chanegCard = make([]*pb.DBHero, 0)
|
||||
code = this.AwakenCheck(session, req) // check
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
@ -59,6 +61,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if _hero.SameCount > 1 { //有堆叠的情况
|
||||
// 克隆一个新的
|
||||
_hero.SameCount -= 1
|
||||
newHero := this.module.modelHero.CloneNewHero(_hero)
|
||||
chanegCard = append(chanegCard, newHero)
|
||||
}
|
||||
_hero.SameCount = 1
|
||||
|
||||
// 加属性 awakenData
|
||||
_value, ok := strconv.Atoi(awakenData.Phasebonus[0])
|
||||
if ok == nil { // 升级技能
|
||||
@ -72,6 +82,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
}
|
||||
_heroMap := map[string]interface{}{
|
||||
"normalSkill": _hero.NormalSkill,
|
||||
"sameCount": 1,
|
||||
"isOverlying": false,
|
||||
}
|
||||
// 保存数据
|
||||
@ -106,8 +117,8 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
if err1 != nil {
|
||||
this.module.Errorf("ChangeHeroProperty err!")
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
|
||||
chanegCard = append(chanegCard, _hero)
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
|
||||
session.SendMsg(string(this.module.GetType()), Awaken, &pb.HeroAwakenResp{Hero: _hero})
|
||||
return
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
config5Count int32 // 配置表中5星保底次数
|
||||
race int32
|
||||
upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加
|
||||
cardW map[string]int32 // 当前卡牌对应的权重
|
||||
cardW map[string]int32 // 当前卡牌卡池卡牌对应的权重
|
||||
)
|
||||
upDraw = make([]*cfg.Game_drawUpdrawData, 0)
|
||||
szCards = make([]string, 0)
|
||||
@ -46,6 +46,9 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
for _, v := range cfgData.GetDataList() {
|
||||
if time.Now().Unix() > int64(v.TimeOn) && time.Now().Unix() < int64(v.TimeOff) { // 在这个时间范围之内
|
||||
upDraw = append(upDraw, v) // 记录下在这活动范围之内的数据
|
||||
for index, v1 := range v.UpHero {
|
||||
cardW[v1] += v.UpWeight[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,6 +85,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
for _, v := range _conf {
|
||||
cardW[v.Id] += v.Weight
|
||||
}
|
||||
|
||||
_costConf, err := this.module.configure.GetDrawCostConfigByID(req.DrawType) // 抽卡消耗
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
@ -103,30 +107,15 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
}
|
||||
|
||||
drawTimes = _costConf.Count // 抽卡次数
|
||||
for k, v := range cardW { // k是heroid v 权重
|
||||
|
||||
for _, v1 := range upDraw {
|
||||
for _, v2 := range v1.UpHero {
|
||||
if v2 == k {
|
||||
cardW[k] += v
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
// if !updraw {
|
||||
// totalWeight += int64(v.Weight) // 统计所有权重
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
drawTimes = 1
|
||||
for i := 0; i < int(drawTimes); i++ {
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(totalWeight)) // [0,totalWeight)
|
||||
for _, v := range _conf {
|
||||
curWeigth += int64(v.Weight)
|
||||
for k, v := range cardW {
|
||||
curWeigth += int64(v)
|
||||
if curWeigth < n.Int64() { // 命中
|
||||
// 获取当前星级
|
||||
_getCardCfg := this.module.configure.GetHero(v.Id) //获取的英雄信息
|
||||
_getCardCfg := this.module.configure.GetHero(k) //获取的英雄信息
|
||||
if _getCardCfg != nil {
|
||||
continue
|
||||
}
|
||||
@ -183,7 +172,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
}
|
||||
}
|
||||
if !bGet {
|
||||
szCards = append(szCards, v.Id)
|
||||
szCards = append(szCards, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user