上传联盟学院代码注册
This commit is contained in:
parent
e6ed62a330
commit
8ae9c6842f
@ -70,7 +70,7 @@ const (
|
|||||||
//ModuleFetter core.M_Modules = "herofetter" //好友模块
|
//ModuleFetter core.M_Modules = "herofetter" //好友模块
|
||||||
ModuleSociaty core.M_Modules = "sociaty" //公会
|
ModuleSociaty core.M_Modules = "sociaty" //公会
|
||||||
ModulePay core.M_Modules = "pay" //支付
|
ModulePay core.M_Modules = "pay" //支付
|
||||||
ModuleAlliance core.M_Modules = "alliance" //联盟学院
|
ModuleAcademy core.M_Modules = "academy" //联盟学院
|
||||||
ModulePrivilege core.M_Modules = "privilege" //特权
|
ModulePrivilege core.M_Modules = "privilege" //特权
|
||||||
ModuleGrowtask core.M_Modules = "growtask" //成长任务
|
ModuleGrowtask core.M_Modules = "growtask" //成长任务
|
||||||
ModuleWorldtask core.M_Modules = "worldtask" //世界任务
|
ModuleWorldtask core.M_Modules = "worldtask" //世界任务
|
||||||
|
@ -6,6 +6,21 @@ func Atoi(b []byte) (int, error) {
|
|||||||
return strconv.Atoi(BytesToString(b))
|
return strconv.Atoi(BytesToString(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StringToInt64(b string) int64 {
|
||||||
|
if i, err := strconv.ParseInt(b, 10, 64); err != nil {
|
||||||
|
return 0
|
||||||
|
} else {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func StringToFloat64(b string) float64 {
|
||||||
|
if i, err := strconv.ParseFloat(b, 64); err != nil {
|
||||||
|
return 0
|
||||||
|
} else {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ParseInt(b []byte, base int, bitSize int) (int64, error) {
|
func ParseInt(b []byte, base int, bitSize int) (int64, error) {
|
||||||
return strconv.ParseInt(BytesToString(b), base, bitSize)
|
return strconv.ParseInt(BytesToString(b), base, bitSize)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type Academy struct {
|
|||||||
|
|
||||||
//模块名
|
//模块名
|
||||||
func (this *Academy) GetType() core.M_Modules {
|
func (this *Academy) GetType() core.M_Modules {
|
||||||
return comm.ModuleForum
|
return comm.ModuleAcademy
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块初始化接口 注册用户创建角色事件
|
//模块初始化接口 注册用户创建角色事件
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/modules/academy"
|
||||||
"go_dreamfactory/modules/arena"
|
"go_dreamfactory/modules/arena"
|
||||||
"go_dreamfactory/modules/battle"
|
"go_dreamfactory/modules/battle"
|
||||||
"go_dreamfactory/modules/chat"
|
"go_dreamfactory/modules/chat"
|
||||||
@ -103,6 +104,7 @@ func main() {
|
|||||||
//privilege.NewModule(),
|
//privilege.NewModule(),
|
||||||
growtask.NewModule(),
|
growtask.NewModule(),
|
||||||
worldtask.NewModule(),
|
worldtask.NewModule(),
|
||||||
|
academy.NewModule(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/lego"
|
"go_dreamfactory/lego"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
"go_dreamfactory/lego/utils/codec"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -43,6 +44,7 @@ type Configure struct {
|
|||||||
clock sync.RWMutex
|
clock sync.RWMutex
|
||||||
configure map[string]interface{}
|
configure map[string]interface{}
|
||||||
fileinfos map[string]*FileInfo
|
fileinfos map[string]*FileInfo
|
||||||
|
offsettime time.Duration //偏移时间
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Configure) Start() (err error) {
|
func (this *Configure) Start() (err error) {
|
||||||
@ -59,7 +61,7 @@ func (this *Configure) Start() (err error) {
|
|||||||
}
|
}
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
}()
|
}()
|
||||||
|
this.readoffsettime()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *Configure) Stop() (err error) {
|
func (this *Configure) Stop() (err error) {
|
||||||
@ -67,6 +69,11 @@ func (this *Configure) Stop() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//服务当前时间
|
||||||
|
func (this *Configure) Now() time.Time {
|
||||||
|
return time.Now().Add(this.offsettime)
|
||||||
|
}
|
||||||
|
|
||||||
//加载配置文件
|
//加载配置文件
|
||||||
func (this *Configure) RegisterConfigure(name string, fn interface{}, callback func()) (err error) {
|
func (this *Configure) RegisterConfigure(name string, fn interface{}, callback func()) (err error) {
|
||||||
this.hlock.RLock()
|
this.hlock.RLock()
|
||||||
@ -209,4 +216,25 @@ func (this *Configure) checkConfigure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.readoffsettime()
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取偏移时间
|
||||||
|
func (this *Configure) readoffsettime() {
|
||||||
|
var (
|
||||||
|
fliepath string
|
||||||
|
file *os.File
|
||||||
|
data []byte
|
||||||
|
offtimeStr string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if file, err = os.Open(fliepath); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
if data, err = ioutil.ReadAll(file); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
offtimeStr = codec.BytesToString(data)
|
||||||
|
this.offsettime = time.Second * time.Duration(codec.StringToInt64(offtimeStr))
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ type (
|
|||||||
Stop() (err error)
|
Stop() (err error)
|
||||||
RegisterConfigure(name string, fn interface{}, callback func()) (err error) //注册配置
|
RegisterConfigure(name string, fn interface{}, callback func()) (err error) //注册配置
|
||||||
GetConfigure(name string) (v interface{}, err error) //获取配置
|
GetConfigure(name string) (v interface{}, err error) //获取配置
|
||||||
|
Now() time.Time //服务器当前时间
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,5 +58,5 @@ func GetConfigure(name string) (v interface{}, err error) {
|
|||||||
|
|
||||||
//当前时间
|
//当前时间
|
||||||
func Now() time.Time {
|
func Now() time.Time {
|
||||||
return time.Now()
|
return defsys.Now()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package configure
|
package configure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/lego/utils/mapstructure"
|
"go_dreamfactory/lego/utils/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -9,6 +10,8 @@ type Options struct {
|
|||||||
ConfigurePath string //配置中心路径
|
ConfigurePath string //配置中心路径
|
||||||
TimestampFile string //时间戳配置文件路径
|
TimestampFile string //时间戳配置文件路径
|
||||||
CheckInterval int //配置文件更新检查间隔时间 单位秒
|
CheckInterval int //配置文件更新检查间隔时间 单位秒
|
||||||
|
Debug bool //日志是否开启
|
||||||
|
Log log.ILogger
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetConfigurePath(v string) Option {
|
func SetConfigurePath(v string) Option {
|
||||||
@ -27,6 +30,18 @@ func SetCheckInterval(v int) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetDebug(v bool) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Debug = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetLog(v log.ILogger) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Log = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) {
|
func newOptions(config map[string]interface{}, opts ...Option) (Options, error) {
|
||||||
options := Options{
|
options := Options{
|
||||||
CheckInterval: 60,
|
CheckInterval: 60,
|
||||||
@ -37,6 +52,9 @@ func newOptions(config map[string]interface{}, opts ...Option) (Options, error)
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
if options.Log == nil {
|
||||||
|
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.rpc", 3))
|
||||||
|
}
|
||||||
return options, nil
|
return options, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +65,9 @@ func newOptionsByOption(opts ...Option) (Options, error) {
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
if options.Log == nil {
|
||||||
|
options.Log = log.NewTurnlog(options.Debug, log.Clone("sys.configure", 3))
|
||||||
|
}
|
||||||
return options, nil
|
return options, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user