上传测试服
This commit is contained in:
parent
4139e2e36c
commit
125fc9cddd
@ -114,6 +114,7 @@ const (
|
||||
ModuleJielong core.M_Modules = "jielong" //接龙
|
||||
ModuleEntertainment core.M_Modules = "entertain" //消消乐
|
||||
ModuleDcolor core.M_Modules = "dcolor" //猜颜色
|
||||
ModuleMaincity core.M_Modules = "maincity" //主城同屏
|
||||
)
|
||||
|
||||
// 数据表名定义处
|
||||
|
@ -106,7 +106,7 @@ func (this *TimeWheel) Add(delay time.Duration, handler func(*Task, ...interface
|
||||
|
||||
// AddCron add interval task
|
||||
func (this *TimeWheel) AddCron(delay time.Duration, handler func(*Task, ...interface{}), args ...interface{}) *Task {
|
||||
return this.addAny(delay, modeIsCircle, modeIsAsync, handler, args...)
|
||||
return this.addAny(delay, true, modeIsAsync, handler, args...)
|
||||
}
|
||||
|
||||
func (this *TimeWheel) Remove(task *Task) error {
|
||||
|
@ -31,17 +31,19 @@ func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleO
|
||||
}
|
||||
return
|
||||
}
|
||||
if conf, err = this.module.configure.getGameGColorGetfractionData(int32(req.Difficulty), req.Repeat, len(req.Handles)); err != nil {
|
||||
if conf, err = this.module.configure.getGameGColorGetfractionData(int32(req.Difficulty)+1, req.Repeat, len(req.Handles)-1); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if tconf, err = this.module.configure.getGameGColortTmedecayData(req.Time); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
info.Integral += int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000)))
|
||||
|
@ -84,7 +84,7 @@ func (this *configureComp) getGameGColorGetfractionData(dif int32, repeat bool,
|
||||
}
|
||||
|
||||
if _, ok = confs[dif]; ok {
|
||||
if len(confs[dif]) < index {
|
||||
if len(confs[dif]) > index {
|
||||
conf = confs[dif][index]
|
||||
return
|
||||
}
|
||||
|
@ -12,29 +12,26 @@ func RandomColor(difficulty pb.DBDColorDifficulty, Repeat bool) (temcolors []int
|
||||
colorNum int
|
||||
colors []int32 = []int32{1, 2, 3, 4, 5, 6, 7, 8}
|
||||
)
|
||||
|
||||
temcolors = make([]int32, 4)
|
||||
switch difficulty {
|
||||
case pb.DBDColorDifficulty_Simple:
|
||||
colorNum = 4
|
||||
temcolors = make([]int32, 4)
|
||||
break
|
||||
case pb.DBDColorDifficulty_Difficulty:
|
||||
colorNum = 6
|
||||
temcolors = make([]int32, 6)
|
||||
break
|
||||
case pb.DBDColorDifficulty_Hell:
|
||||
colorNum = 8
|
||||
temcolors = make([]int32, 7)
|
||||
break
|
||||
}
|
||||
if Repeat {
|
||||
for i := 0; i < colorNum; i++ {
|
||||
for i := 0; i < 4; i++ {
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(colorNum)))
|
||||
temcolors[i] = colors[n.Int64()]
|
||||
}
|
||||
} else {
|
||||
colors = colors[0:colorNum]
|
||||
for i := 0; i < colorNum; i++ {
|
||||
for i := 0; i < 4; i++ {
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(colors))))
|
||||
index := n.Int64()
|
||||
temcolors[i] = colors[index]
|
||||
|
@ -38,6 +38,7 @@ func (this *DColor) Init(service core.IService, module core.IModule, options cor
|
||||
func (this *DColor) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
||||
this.modelQiecuo = this.RegisterComp(new(modelQiecuoComp)).(*modelQiecuoComp)
|
||||
this.rooms = this.RegisterComp(new(roomsComp)).(*roomsComp)
|
||||
|
@ -22,7 +22,7 @@ func (this *modelComp) Init(service core.IService, module core.IModule, comp cor
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = comm.Tablekftask
|
||||
this.module = module.(*MainCity)
|
||||
|
||||
this.onlines = make(map[string][]*pb.BaseUserInfo)
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
|
@ -28,7 +28,7 @@ func NewModule() core.IModule {
|
||||
}
|
||||
|
||||
func (this *MainCity) GetType() core.M_Modules {
|
||||
return comm.ModuleKFTask
|
||||
return comm.ModuleMaincity
|
||||
}
|
||||
|
||||
func (this *MainCity) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
@ -92,8 +92,8 @@ func (this *MainCity) EventUserLogin(session comm.IUserSession) {
|
||||
}
|
||||
|
||||
// 用户登录
|
||||
func (this *MainCity) EventUserOffline(session comm.IUserSession) {
|
||||
this.model.removelayerPos(session.GetUserId())
|
||||
func (this *MainCity) EventUserOffline(uid string, sessionid string) {
|
||||
this.model.removelayerPos(uid)
|
||||
}
|
||||
|
||||
// 向多个用户发送消息
|
||||
|
@ -5,11 +5,10 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
"go_dreamfactory/lego/sys/timewheel"
|
||||
"go_dreamfactory/lego/sys/cron"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -42,7 +41,8 @@ func (this *aiComp) Start() (err error) {
|
||||
if this.shotConf, err = this.module.configure.getGameBuzkashiQteLvs(); err != nil {
|
||||
return
|
||||
}
|
||||
timewheel.AddCron(time.Second, this.run)
|
||||
cron.AddFunc("*/1 * * * * ?", this.run)
|
||||
// timewheel.AddCron(time.Second, this.run)
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func (this *aiComp) removeAi(battleid string) {
|
||||
this.lock.Unlock()
|
||||
}
|
||||
|
||||
func (this *aiComp) run(task *timewheel.Task, args ...interface{}) {
|
||||
func (this *aiComp) run() {
|
||||
var (
|
||||
ais []*AI
|
||||
)
|
||||
@ -121,7 +121,7 @@ func (this *aiComp) ExceAi(_ai *AI) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(handle) > 0 {
|
||||
if len(handle) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,14 @@ func (this *apiComp) ChangeMts(session comm.IUserSession, req *pb.ParkourChangeM
|
||||
return
|
||||
}
|
||||
info.Defmts = dragon.Id
|
||||
info.Property = dragon.Property
|
||||
info.Mount = dragon.Dragonid
|
||||
info.Mlv = dragon.Lv
|
||||
if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{
|
||||
"defmts": info.Defmts,
|
||||
"property": info.Property,
|
||||
"mount": info.Mount,
|
||||
"mlv": info.Mlv,
|
||||
}); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
@ -42,10 +42,22 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
|
||||
}
|
||||
return
|
||||
}
|
||||
if team.Captainid == "" { //为组队情况
|
||||
// if team.Captainid == "" { //为组队情况
|
||||
team.Captainid = team.Uid
|
||||
team.State = pb.RaceTeamState_teaming
|
||||
team.Member = append(team.Member, &pb.DBRaceMember{
|
||||
// team.Member = append(team.Member, &pb.DBRaceMember{
|
||||
// Uid: team.Uid,
|
||||
// Name: team.Name,
|
||||
// Skin: team.Skin,
|
||||
// Sex: team.Sex,
|
||||
// Lv: team.Lv,
|
||||
// Dan: team.Dan,
|
||||
// Mount: team.Mount,
|
||||
// Property: team.Property,
|
||||
// Currhp: team.Property[comm.Dhp],
|
||||
// })
|
||||
team.Member = []*pb.DBRaceMember{
|
||||
{
|
||||
Uid: team.Uid,
|
||||
Name: team.Name,
|
||||
Skin: team.Skin,
|
||||
@ -55,7 +67,8 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
|
||||
Mount: team.Mount,
|
||||
Property: team.Property,
|
||||
Currhp: team.Property[comm.Dhp],
|
||||
})
|
||||
},
|
||||
}
|
||||
if err = this.module.parkourComp.Change(team.Captainid, map[string]interface{}{
|
||||
"state": team.State,
|
||||
"captainid": team.Captainid,
|
||||
@ -68,7 +81,7 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
// }
|
||||
if ais, err = this.module.parkourComp.matcheAI(team.Dan, 5); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
|
@ -80,6 +80,7 @@ import (
|
||||
"go_dreamfactory/lego"
|
||||
"go_dreamfactory/lego/base/rpcx"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/cron"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/sys/timewheel"
|
||||
)
|
||||
@ -196,6 +197,12 @@ func (this *Service) InitSys() {
|
||||
log.Infof("init sys.wordfilter success!")
|
||||
}
|
||||
//定时系统 秒级时间轮
|
||||
if err := cron.OnInit(nil); err != nil {
|
||||
panic(fmt.Sprintf("init sys.cron err: %s", err.Error()))
|
||||
} else {
|
||||
log.Infof("init sys.cron success!")
|
||||
}
|
||||
//定时系统 秒级时间轮
|
||||
if err := timewheel.OnInit(nil, timewheel.SetTick(time.Second)); err != nil {
|
||||
panic(fmt.Sprintf("init sys.timewheel err: %s", err.Error()))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user