主线评星
This commit is contained in:
parent
32fe177428
commit
f4b274ef93
@ -698,3 +698,8 @@ const (
|
||||
PrivilegeType9 //武馆每日最大练功时间
|
||||
PrivilegeType10 //铁匠铺每日最大锻造时间
|
||||
)
|
||||
const (
|
||||
MainStarType1 = 1 //成功通关
|
||||
MainStarType2 = 1 //死亡人数不超过{0}人
|
||||
MainStarType3 = 1 //不超过{0}回合通关
|
||||
)
|
||||
|
@ -28,6 +28,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall
|
||||
first bool // 判断是否是首通
|
||||
update map[string]interface{}
|
||||
rsp *pb.MlineChallengeOverResp
|
||||
star int32 // 评星
|
||||
)
|
||||
rsp = &pb.MlineChallengeOverResp{}
|
||||
update = make(map[string]interface{})
|
||||
@ -53,7 +54,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall
|
||||
return
|
||||
}
|
||||
// 校验通过
|
||||
|
||||
code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
@ -71,10 +71,33 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall
|
||||
code = pb.ErrorCode_BattleNoWin
|
||||
return
|
||||
}
|
||||
// 评星规则
|
||||
if len(stageConf.Star) != len(stageConf.StarType) || len(stageConf.Star) != len(stageConf.StarValue) || len(stageConf.StarValue) != len(stageConf.StarType) {
|
||||
this.module.Errorf("配置错误, 参数数量不一致,StageId: %d", req.StageId)
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
for i, v := range stageConf.StarType {
|
||||
if v == comm.MainStarType1 {
|
||||
star += stageConf.Star[i]
|
||||
} else if v == comm.MainStarType2 {
|
||||
if req.Report.Death <= stageConf.StarValue[i] {
|
||||
star += stageConf.Star[i]
|
||||
}
|
||||
} else if v == comm.MainStarType3 {
|
||||
if req.Report.Round <= stageConf.StarValue[i] {
|
||||
star += stageConf.Star[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断是不是首通
|
||||
if _, ok := curChapter.Star[req.StageId]; !ok {
|
||||
first = true
|
||||
curChapter.Star[req.StageId] = 1
|
||||
curChapter.Star[req.StageId] = star // 星级赋值
|
||||
update["star"] = curChapter.Star
|
||||
}
|
||||
if curChapter.Star[req.StageId] > star { // 给最高星
|
||||
curChapter.Star[req.StageId] = star
|
||||
update["star"] = curChapter.Star
|
||||
}
|
||||
curChapter.Ps[req.StageId] = 0 // 清空预扣体力值
|
||||
|
Loading…
Reference in New Issue
Block a user