上传代码

This commit is contained in:
liwei 2023-07-06 16:47:56 +08:00
parent e4a5caccd3
commit 218e97f62b
8 changed files with 50 additions and 5 deletions

View File

@ -88,6 +88,7 @@ const (
ModuleBuried core.M_Modules = "buried" //埋点中心 ModuleBuried core.M_Modules = "buried" //埋点中心
ModuleActivity core.M_Modules = "acrivity" //活动 ModuleActivity core.M_Modules = "acrivity" //活动
ModuleGuidance core.M_Modules = "guidance" //引导 ModuleGuidance core.M_Modules = "guidance" //引导
ModuleWtask core.M_Modules = "wtask" //世界任务
) )
// 数据表名定义处 // 数据表名定义处

View File

@ -533,4 +533,9 @@ type (
//推送红点 //推送红点
PushReddot(session IUserSession, reddot ...*pb.ReddotItem) (errdata *pb.ErrorData) PushReddot(session IUserSession, reddot ...*pb.ReddotItem) (errdata *pb.ErrorData)
} }
//练功房
IPasson interface {
//英雄升级
HeroUpLv(session IUserSession, heroid string, lv int32)
}
) )

View File

@ -50,7 +50,7 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq)
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError, Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(), Title: pb.ErrorCode_ReqParameterError.ToString(),
Message: fmt.Sprintf("no found hero:%d", req.Heroid), Message: fmt.Sprintf("no found hero:%s", req.Heroid),
} }
return return
} }
@ -82,7 +82,9 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq)
return return
} }
hero.Ispasson = true hero.Ispasson = true
if errdata = this.module.ModuleHero.PassonHero(session, map[string]bool{hero.Id: true}); errdata != nil {
session.SendMsg(string(this.module.GetType()), "getlist", &pb.PassonInRoomResp{Heroid: req.Heroid}) return
}
session.SendMsg(string(this.module.GetType()), "inroom", &pb.PassonInRoomResp{Heroid: req.Heroid})
return return
} }

21
modules/passon/core.go Normal file
View File

@ -0,0 +1,21 @@
package passon
import "go_dreamfactory/pb"
type SliceHero []*pb.DBHero
// 实现sort.Interface接口的方法
// 获取数组长度
func (this SliceHero) Len() int {
return len(this)
}
// 比较元素大小
func (this SliceHero) Less(i, j int) bool {
return this[i].Lv < this[j].Lv
}
// 交换元素位置
func (this SliceHero) Swap(i, j int) {
this[i], this[j] = this[j], this[i]
}

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"sort"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -53,6 +54,7 @@ func (this *Passon) Start() (err error) {
func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) { func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) {
var ( var (
passon *pb.DBPasson passon *pb.DBPasson
heros []*pb.DBHero
err error err error
) )
if passon, err = this.modelPasson.getUserPasson(session.GetUserId()); err != nil { if passon, err = this.modelPasson.getUserPasson(session.GetUserId()); err != nil {
@ -69,4 +71,15 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32)
} }
} }
heros = this.ModuleHero.GetHeroList(session.GetUserId())
if len(heros) < 5 {
return
}
// 使用sort.Slice进行排序
sort.Slice(heros, func(i, j int) bool {
return heros[i].Lv < heros[j].Lv
})
} }

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
@ -36,7 +37,7 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options
func (this *Worldtask) OnInstallComp() { func (this *Worldtask) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
// event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)

View File

@ -28,7 +28,7 @@ func NewModule() core.IModule {
} }
func (this *WTask) GetType() core.M_Modules { func (this *WTask) GetType() core.M_Modules {
return comm.ModuleWorldtask return comm.ModuleWtask
} }
func (this *WTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *WTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {

View File

@ -49,6 +49,7 @@ import (
"go_dreamfactory/modules/user" "go_dreamfactory/modules/user"
"go_dreamfactory/modules/viking" "go_dreamfactory/modules/viking"
"go_dreamfactory/modules/worldtask" "go_dreamfactory/modules/worldtask"
"go_dreamfactory/modules/wtask"
"go_dreamfactory/services" "go_dreamfactory/services"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"go_dreamfactory/sys/wordfilter" "go_dreamfactory/sys/wordfilter"
@ -126,6 +127,7 @@ func main() {
buried.NewModule(), buried.NewModule(),
activity.NewModule(), activity.NewModule(),
guidance.NewModule(), guidance.NewModule(),
wtask.NewModule(),
) )
} }