Gm指令调整新主线
This commit is contained in:
parent
6f820d168b
commit
516064236d
@ -150,13 +150,18 @@ type (
|
|||||||
}
|
}
|
||||||
IMainline interface {
|
IMainline interface {
|
||||||
ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode)
|
ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode)
|
||||||
// 修改章节信息
|
|
||||||
ModifyMainlineData(uid string, id int32) (code pb.ErrorCode)
|
|
||||||
/// 查询章节ID
|
/// 查询章节ID
|
||||||
GetUsermainLineData(uid string) (mainlineId int32)
|
GetUsermainLineData(uid string) (mainlineId int32)
|
||||||
///红点
|
///红点
|
||||||
IReddot
|
IReddot
|
||||||
}
|
}
|
||||||
|
IMline interface {
|
||||||
|
ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode)
|
||||||
|
/// 查询章节ID
|
||||||
|
GetUsermLineData(uid string, chapterType int32) (chapterId int32)
|
||||||
|
///红点
|
||||||
|
IReddot
|
||||||
|
}
|
||||||
//任务
|
//任务
|
||||||
ITask interface {
|
ITask interface {
|
||||||
//初始化 日常/周常/成就
|
//初始化 日常/周常/成就
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
//bingo:item,10001,1
|
//bingo:item,10001,1
|
||||||
//bingo:attr,gold,1000000
|
//bingo:attr,gold,1000000
|
||||||
//bingo:equi,xxx,1 // xxx 装备id
|
//bingo:equi,xxx,1 // xxx 装备id
|
||||||
2、修改主线关卡进度:bingo:mapid,102(102代表关卡位置)
|
|
||||||
|
|
||||||
3、修改心魔塔进度:bingo:pataid,10(10代表层数)
|
3、修改心魔塔进度:bingo:pataid,10(10代表层数)
|
||||||
|
|
||||||
|
@ -91,23 +91,6 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
|
|||||||
log.Field{Key: "T", Value: datas[1]},
|
log.Field{Key: "T", Value: datas[1]},
|
||||||
log.Field{Key: "N", Value: int32(num)},
|
log.Field{Key: "N", Value: int32(num)},
|
||||||
)
|
)
|
||||||
} else if len(datas) == 2 && (datas[0] == "mapid") {
|
|
||||||
module1, err := this.service.GetModule(comm.ModuleMainline)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
num, err := strconv.Atoi(datas[1])
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_ReqParameterError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
code = module1.(comm.IMainline).ModifyMainlineData(session.GetUserId(), int32(num))
|
|
||||||
|
|
||||||
this.Debug("使用bingo命令",
|
|
||||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
|
||||||
log.Field{Key: "0", Value: datas[0]},
|
|
||||||
log.Field{Key: "N", Value: int32(num)},
|
|
||||||
)
|
|
||||||
} else if len(datas) == 2 && (datas[0] == "pataid") {
|
} else if len(datas) == 2 && (datas[0] == "pataid") {
|
||||||
module1, err := this.service.GetModule(comm.ModulePagoda)
|
module1, err := this.service.GetModule(comm.ModulePagoda)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,42 +40,6 @@ func (this *Mainline) OnInstallComp() {
|
|||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接口信息 给其他模块调用 用来修改主线关卡信息
|
|
||||||
func (this *Mainline) ModifyMainlineData(uid string, id int32) (code pb.ErrorCode) {
|
|
||||||
|
|
||||||
conf := this.configure.GetMainlineConfigData(id, 1)
|
|
||||||
list, err := this.modelMainline.getMainlineList(uid)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, v := range list {
|
|
||||||
if v.ChapterId == conf.Chapter {
|
|
||||||
data := make(map[string]interface{}, 0)
|
|
||||||
data["mainlineId"] = id
|
|
||||||
data["chapterId"] = v.ChapterId
|
|
||||||
this.modelMainline.modifyMainlineData(uid, v.Id, data)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//add
|
|
||||||
_data := &pb.DBMainline{}
|
|
||||||
_data.Id = primitive.NewObjectID().Hex()
|
|
||||||
_data.ChapterId = conf.Chapter
|
|
||||||
_data.MainlineId = conf.Id
|
|
||||||
_mData := make(map[string]interface{}, 0)
|
|
||||||
_data.Uid = uid
|
|
||||||
_data.Intensity = 1 // 难度1
|
|
||||||
_mData[_data.Id] = _data
|
|
||||||
|
|
||||||
this.modelMainline.addNewChapter(uid, _mData)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Mainline) GetUsermainLineData(uid string) (mainlineId int32) {
|
func (this *Mainline) GetUsermainLineData(uid string) (mainlineId int32) {
|
||||||
|
|
||||||
_szData, err := this.modelMainline.getMainlineList(uid)
|
_szData, err := this.modelMainline.getMainlineList(uid)
|
||||||
|
@ -43,16 +43,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge
|
|||||||
}
|
}
|
||||||
if curChapter == nil { // 校验是不是新的数据
|
if curChapter == nil { // 校验是不是新的数据
|
||||||
if stageConf.Previoustage == 0 { // 创建一条新的章节数据
|
if stageConf.Previoustage == 0 { // 创建一条新的章节数据
|
||||||
// 新章节数据校验
|
chapter := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验
|
||||||
chapter := this.module.configure.GetPreMainChapter(req.StageId)
|
|
||||||
bCheck := false
|
bCheck := false
|
||||||
if chapter == 0 {
|
if chapter == 0 {
|
||||||
bCheck = true
|
bCheck = true
|
||||||
} else {
|
} else {
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
if chapter == v.ChapterId { // 有上一章节数据
|
if chapter == v.ChapterId { // 有上一章节数据
|
||||||
// 获取该章节最后一关卡ID
|
|
||||||
//stage := this.module.configure.GetLastStageIDByChapter(chapter)
|
|
||||||
if _, ok := v.Star[stageConf.Previoustage]; ok {
|
if _, ok := v.Star[stageConf.Previoustage]; ok {
|
||||||
bCheck = true
|
bCheck = true
|
||||||
}
|
}
|
||||||
|
@ -36,20 +36,21 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MlineGetListReq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(rsp.Data) == 0 { // 什么数据都没有 创建一条
|
if len(rsp.Data) == 0 { // 什么数据都没有 创建一条
|
||||||
stageConf := this.module.configure.GetFirstStageIDByChapter(req.CType)
|
if chapterConf := this.module.configure.GetFirstChapterIDByType(req.CType); chapterConf != nil { // 配置文件校验
|
||||||
if stageConf != nil { // 配置文件校验
|
if stageConf := this.module.configure.GetFirstStageIDByChapter(chapterConf.Id); stageConf != nil {
|
||||||
newData := &pb.DBMline{
|
newData := &pb.DBMline{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: session.GetUserId(),
|
Uid: session.GetUserId(),
|
||||||
CType: stageConf.Episodetype,
|
CType: stageConf.Episodetype,
|
||||||
ChapterId: stageConf.Chapterid,
|
ChapterId: stageConf.Chapterid,
|
||||||
StageId: stageConf.Id,
|
StageId: stageConf.Id,
|
||||||
Star: map[int32]int32{},
|
Star: map[int32]int32{},
|
||||||
Award: map[int32]bool{},
|
Award: map[int32]bool{},
|
||||||
Ps: map[int32]int32{},
|
Ps: map[int32]int32{},
|
||||||
|
}
|
||||||
|
rsp.Data = append(rsp.Data, newData)
|
||||||
|
this.module.modelMline.addNewChapter(session.GetUserId(), newData)
|
||||||
}
|
}
|
||||||
rsp.Data = append(rsp.Data, newData)
|
|
||||||
this.module.modelMline.addNewChapter(session.GetUserId(), newData)
|
|
||||||
} else {
|
} else {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
|
@ -75,7 +75,6 @@ func (this *configureComp) GetMainStageConf(id int32) (data *cfg.GameMainStageDa
|
|||||||
|
|
||||||
// 获取上一章节信息
|
// 获取上一章节信息
|
||||||
func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) {
|
func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) {
|
||||||
|
|
||||||
if v, err := this.GetConfigure(game_mainchapter); err == nil {
|
if v, err := this.GetConfigure(game_mainchapter); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameMainChapter); ok {
|
if configure, ok := v.(*cfg.GameMainChapter); ok {
|
||||||
for index, v1 := range configure.GetDataList() {
|
for index, v1 := range configure.GetDataList() {
|
||||||
@ -95,12 +94,25 @@ func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (this *configureComp) GetFirstChapterIDByType(iType int32) *cfg.GameMainChapterData {
|
||||||
|
if v, err := this.GetConfigure(game_mainchapter); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameMainChapter); ok {
|
||||||
|
for _, v := range configure.GetDataList() {
|
||||||
|
if v.ChapterType == iType {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
func (this *configureComp) GetFirstStageIDByChapter(iType int32) *cfg.GameMainStageData {
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) GetFirstStageIDByChapter(chapterID int32) *cfg.GameMainStageData {
|
||||||
if v, err := this.GetConfigure(game_mainstage); err == nil {
|
if v, err := this.GetConfigure(game_mainstage); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameMainStage); ok {
|
if configure, ok := v.(*cfg.GameMainStage); ok {
|
||||||
for _, v := range configure.GetDataList() {
|
for _, v := range configure.GetDataList() {
|
||||||
if v.Episodetype == iType {
|
if v.Chapterid == chapterID {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,3 +120,51 @@ func (this *configureComp) GetFirstStageIDByChapter(iType int32) *cfg.GameMainSt
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 红点用 获取所有章节数据
|
||||||
|
func (this *configureComp) GetAllChapterID() (chapter []int32) {
|
||||||
|
if v, err := this.GetConfigure(game_mainchapter); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameMainChapter); ok {
|
||||||
|
for _, v1 := range configure.GetDataList() {
|
||||||
|
chapter = append(chapter, v1.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 红点用 获取所有类型为1 的小关ID
|
||||||
|
func (this *configureComp) GetAllStageByChapterID(chapterID int32) (stage []int32) {
|
||||||
|
if v, err := this.GetConfigure(game_mainstage); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameMainStage); ok {
|
||||||
|
for _, v1 := range configure.GetDataList() {
|
||||||
|
if v1.Episodetype == 1 {
|
||||||
|
stage = append(stage, v1.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// gm 专用
|
||||||
|
func (this *configureComp) GetGMChapter(chapterID, itype int32) (d map[int32][]int32) {
|
||||||
|
// var d map[int32][]int32
|
||||||
|
d = make(map[int32][]int32, 0)
|
||||||
|
if v, err := this.GetConfigure(game_mainstage); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameMainStage); ok {
|
||||||
|
for _, v1 := range configure.GetDataList() {
|
||||||
|
if v1.Episodetype == itype && v1.Id <= chapterID {
|
||||||
|
//chapter = append(chapter, v1.Id)
|
||||||
|
stage := this.GetAllStageByChapterID(v1.Id)
|
||||||
|
if len(stage) > 0 {
|
||||||
|
d[v1.Id] = stage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -62,3 +62,12 @@ func (this *ModelMline) cleanChapter(uId string) (err error) {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清除数据
|
||||||
|
func (this *ModelMline) cleanChapterDataById(uId string, ids ...string) (err error) {
|
||||||
|
if err = this.DelListlds(uId, ids...); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -5,6 +5,9 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Mline struct {
|
type Mline struct {
|
||||||
@ -62,24 +65,78 @@ func (this *Mline) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (re
|
|||||||
|
|
||||||
// 红点检测
|
// 红点检测
|
||||||
func (this *Mline) CheckPoint(uid string) bool {
|
func (this *Mline) CheckPoint(uid string) bool {
|
||||||
// list, err := this.modelMainline.getMainlineList(uid)
|
list, err := this.modelMline.getMainlineList(uid)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
// for _, v := range list {
|
for _, v := range list {
|
||||||
// conf := this.configure.GetMainlineChapter(v.ChapterId)
|
b := false
|
||||||
// if conf == nil {
|
for _, v1 := range this.configure.GetAllChapterID() {
|
||||||
// continue
|
if v.ChapterId == v1 {
|
||||||
// }
|
b = true
|
||||||
// if len(conf.Episode) != len(v.BranchID) {
|
continue
|
||||||
// return true
|
}
|
||||||
// }
|
}
|
||||||
// }
|
if !b {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 查看所有小关是否通关
|
||||||
|
szStage := this.configure.GetAllStageByChapterID(v.ChapterId)
|
||||||
|
if len(szStage) != len(v.Star) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数 难度 + 关卡id
|
// 参数 难度 + 章节id
|
||||||
func (this *Mline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) {
|
func (this *Mline) ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) {
|
||||||
|
var del []string
|
||||||
|
list, err := this.modelMline.getMainlineList(uid)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range list {
|
||||||
|
if v.CType == nandu {
|
||||||
|
del = append(del, v.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 清除
|
||||||
|
this.modelMline.cleanChapterDataById(uid, del...)
|
||||||
|
d := this.configure.GetGMChapter(id, nandu)
|
||||||
|
for k, v := range d {
|
||||||
|
newData := &pb.DBMline{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
Uid: uid,
|
||||||
|
CType: nandu,
|
||||||
|
ChapterId: k,
|
||||||
|
StageId: 0,
|
||||||
|
Star: map[int32]int32{},
|
||||||
|
Award: map[int32]bool{},
|
||||||
|
Ps: map[int32]int32{},
|
||||||
|
}
|
||||||
|
for _, v1 := range v {
|
||||||
|
newData.Star[v1] = 3 // gm 全给3星
|
||||||
|
}
|
||||||
|
this.modelMline.addNewChapter(uid, newData)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (this *Mline) GetUsermLineData(uid string, chapterType int32) (chapterId int32) {
|
||||||
|
var sz []*pb.DBMline
|
||||||
|
_szData, err := this.modelMline.getMainlineList(uid)
|
||||||
|
if err == nil {
|
||||||
|
for _, v := range _szData {
|
||||||
|
if v.ChapterId == chapterId {
|
||||||
|
sz = append(sz, _szData...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.SliceStable(sz, func(i, j int) bool { // 排序
|
||||||
|
return sz[i].ChapterId > sz[j].ChapterId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ func (this *Reddot) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.hunting = module.(comm.IHunting)
|
this.hunting = module.(comm.IHunting)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +127,8 @@ func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ml, y := m.(comm.IMainline); y {
|
if ml, y := m.(comm.IMline); y {
|
||||||
qjId := ml.GetUsermainLineData(uid)
|
qjId := ml.GetUsermLineData(uid, 1)
|
||||||
return soEqual(qjId, cfg.Data1)
|
return soEqual(qjId, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user