上传代码

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" //埋点中心
ModuleActivity core.M_Modules = "acrivity" //活动
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)
}
//练功房
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{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
Message: fmt.Sprintf("no found hero:%d", req.Heroid),
Message: fmt.Sprintf("no found hero:%s", req.Heroid),
}
return
}
@ -82,7 +82,9 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq)
return
}
hero.Ispasson = true
session.SendMsg(string(this.module.GetType()), "getlist", &pb.PassonInRoomResp{Heroid: req.Heroid})
if errdata = this.module.ModuleHero.PassonHero(session, map[string]bool{hero.Id: true}); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "inroom", &pb.PassonInRoomResp{Heroid: req.Heroid})
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/modules"
"go_dreamfactory/pb"
"sort"
"go_dreamfactory/lego/base"
"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) {
var (
passon *pb.DBPasson
heros []*pb.DBHero
err error
)
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/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
@ -36,7 +37,7 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options
func (this *Worldtask) OnInstallComp() {
this.ModuleBase.OnInstallComp()
// event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)

View File

@ -28,7 +28,7 @@ func NewModule() core.IModule {
}
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) {

View File

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