This commit is contained in:
wh_zcy 2022-12-31 14:56:59 +08:00
commit 36c72fafb2
6 changed files with 2572 additions and 40 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ package mainline
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
@ -20,6 +21,8 @@ func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.MainlineC
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChallengeReq) (code pb.ErrorCode, data proto.Message) {
var (
curChapter *pb.DBMainline // 当前章节信息
ps int32
psAnt *cfg.Gameatn
)
code = this.ChallengeCheck(session, req)
@ -48,10 +51,43 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
break
}
}
// 消耗
if code = this.module.CheckRes(session, node.PsConsume); code != pb.ErrorCode_Success {
return
if curChapter.Ps != 0 {
if code = this.module.ConsumeRes(session, node.PsMg, true); code != pb.ErrorCode_Success { // 扣1点
return
}
} else {
for _, v := range node.PsConsume {
if v.A == "attr" && v.T == "ps" {
ps += v.N
}
}
for _, v := range node.PsMg {
if v.A == "attr" && v.T == "ps" {
ps += v.N
}
}
psAnt = &cfg.Gameatn{
A: "attr",
T: "ps",
N: ps,
}
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{psAnt}, true); code != pb.ErrorCode_Success {
return
}
curChapter.Ps = ps
update := map[string]interface{}{
"ps": ps,
}
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), curChapter.Id, update)
if err != nil {
code = pb.ErrorCode_DBError
return
}
}
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_mainline,
Title: "",

View File

@ -48,9 +48,11 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
code = pb.ErrorCode_MainlineNotFindChapter
return
}
// 消耗
if code = this.module.ConsumeRes(session, node.PsConsume, true); code != pb.ErrorCode_Success {
return
for _, v := range mainline.BranchID {
if v == int32(req.MainlineId) { // 重复挑战
code = pb.ErrorCode_MainlineNotFindChapter
return
}
}
// 校验通过
code, isWin = this.module.battle.CheckBattleReport(session, req.Report)
@ -58,20 +60,21 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
return
}
if !isWin { // 战斗失败直接返回
// 返还
mainline.Ps = 0
this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, map[string]interface{}{
"ps": 0,
})
if code = this.module.DispenseRes(session, node.PsConsume, true); code != pb.ErrorCode_Success { // 扣1点
return
}
code = pb.ErrorCode_BattleNoWin
return
}
for _, v := range mainline.BranchID {
if v == int32(req.MainlineId) { // 重复挑战
code = pb.ErrorCode_MainlineNotFindChapter
return
}
if v == int32(req.MainlineId) {
break
}
}
res = append(res, node.Award...)
for _, v := range res {
for _, v := range node.Award {
if v.A == comm.HeroType {
hero = append(hero, v.T)
}
@ -87,10 +90,12 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
user = this.module.ModuleUser.GetUser(session.GetUserId())
mainline.MainlineId = int32(req.MainlineId)
mainline.BranchID = append(mainline.BranchID, int32(req.MainlineId))
mainline.Ps = 0 // 重置预扣体力
update := map[string]interface{}{
"mainlineId": req.MainlineId,
"chapterId": mainline.ChapterId,
"branchID": mainline.BranchID,
"ps": 0,
}
if node.Episodetype == comm.MainLineBoss { // 打完boss 设置领奖状态
update["awaredID"] = pb.AwaredType_TypeAvailable
@ -112,12 +117,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
if mainline.Intensity < comm.MaxMainlineIntensity {
_data.Intensity = mainline.Intensity + 1 // 难度+1
_data.ChapterId = 1 // 默认第一章节
} else { // 全部通关 领奖拜拜
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
this.module.Debugf("DispenseRes err:+%v", res)
}
session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: mainline, Newheros: newhero, Olv: user.Lv})
return
}
}
@ -127,6 +126,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data}) // 推送新的章节
}
// 发奖
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {

View File

@ -121,14 +121,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
}
mapData["bossTime"] = viking.BossTime // 更新时间
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
for _, v := range req.Report.Info.Redflist[0].Team {
if !v.Ishelp { // 助战英雄不加经验
addExp, _ := this.module.ModuleHero.AddHeroExp(session, v.Oid, 500) //
changExp[v.Oid] = addExp
}
}
}
// if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
// for _, v := range req.Report.Info.Redflist[0].Team {
// if !v.Ishelp { // 助战英雄不加经验
// addExp, _ := this.module.ModuleHero.AddHeroExp(session, v.Oid, 500) //临时加500 后面等配置
// changExp[v.Oid] = addExp
// }
// }
// }
code = this.module.ModifyVikingData(session.GetUserId(), mapData)
session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{
Data: viking,

View File

@ -81,6 +81,7 @@ type DBMainline struct {
AwaredID AwaredType `protobuf:"varint,5,opt,name=awaredID,proto3,enum=AwaredType" json:"awaredID" bson:"awaredID"` //是否领奖(设置int是考虑后续扩展有多个宝箱情况)
BranchID []int32 `protobuf:"varint,6,rep,packed,name=branchID,proto3" json:"branchID" bson:"branchID"` // 记录所有通关的关卡数据
Intensity int32 `protobuf:"varint,7,opt,name=intensity,proto3" json:"intensity"` // 难度
Ps int32 `protobuf:"varint,8,opt,name=ps,proto3" json:"ps"` // 预扣的体力
}
func (x *DBMainline) Reset() {
@ -164,11 +165,18 @@ func (x *DBMainline) GetIntensity() int32 {
return 0
}
func (x *DBMainline) GetPs() int32 {
if x != nil {
return x.Ps
}
return 0
}
var File_mainline_mainline_db_proto protoreflect.FileDescriptor
var file_mainline_mainline_db_proto_rawDesc = []byte{
0x0a, 0x1a, 0x6d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x2f, 0x6d, 0x61, 0x69, 0x6e, 0x6c,
0x69, 0x6e, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcf, 0x01, 0x0a,
0x69, 0x6e, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdf, 0x01, 0x0a,
0x0a, 0x44, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75,
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a,
@ -181,7 +189,8 @@ var file_mainline_mainline_db_proto_rawDesc = []byte{
0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44,
0x18, 0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44,
0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20,
0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x2a, 0x3e,
0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x12, 0x0e,
0x0a, 0x02, 0x70, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x70, 0x73, 0x2a, 0x3e,
0x0a, 0x0a, 0x41, 0x77, 0x61, 0x72, 0x65, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07,
0x54, 0x79, 0x70, 0x65, 0x4e, 0x69, 0x6c, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x54, 0x79, 0x70,
0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c,

View File

@ -31,6 +31,7 @@ type GameMainlineData struct {
Stroyid []int32
Condition []int32
PsConsume []*Gameatn
PsMg []*Gameatn
}
const TypeId_GameMainlineData = -79093005
@ -130,6 +131,20 @@ func (_v *GameMainlineData)Deserialize(_buf map[string]interface{}) (err error)
}
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["ps_mg"].([]interface{}); !_ok_ { err = errors.New("ps_mg error"); return }
_v.PsMg = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.PsMg = append(_v.PsMg, _list_v_)
}
}
return
}