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