| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package cherryApp
- import (
- cfacade "github.com/cherry-game/cherry/facade"
- "github.com/urfave/cli/v2"
- )
- var (
- _app cfacade.IApplication
- )
- var (
- isBattleValidation bool // 是否战斗验证
- )
- const (
- sourcePath = ".system"
- )
- func Init(app cfacade.IApplication) {
- _app = app
- // 服务器启动时,从配置文件中读取战斗验证开关
- isBattleValidation = app.Settings().GetBool("battle_validation", true)
- }
- func GetParameters(c *cli.Context) (path, node string) {
- path = c.String("path")
- node = c.String("node")
- return path, node
- }
- func GetFlag() []cli.Flag {
- return []cli.Flag{
- &cli.StringFlag{
- Name: "path,p",
- Usage: "profile file path",
- Required: false,
- Value: "./config",
- },
- &cli.StringFlag{
- Name: "node,n",
- Usage: "node id",
- Required: true,
- Value: "",
- },
- }
- }
- func App() cfacade.IApplication {
- return _app
- }
- func Serializer() cfacade.ISerializer {
- return _app.Serializer()
- }
- func Discovery() cfacade.IDiscovery {
- return _app.Discovery()
- }
- func ActorSystem() cfacade.IActorSystem {
- return _app.ActorSystem()
- }
- func GetNodeType(nodeID string) (string, bool) {
- member, found := _app.Discovery().GetMember(nodeID)
- if !found {
- return "", false
- }
- return member.GetNodeType(), true
- }
- func Call(target, funcName string, arg any) int32 {
- return ActorSystem().Call(sourcePath, target, funcName, arg)
- }
- func CallType(nodeType, actorID, funcName string, arg any) int32 {
- return ActorSystem().CallType(nodeType, actorID, funcName, arg)
- }
- func CallWait(target, funcName string, arg any, reply any) int32 {
- return ActorSystem().CallWait(sourcePath, target, funcName, arg, reply)
- }
- func PostEvent(data cfacade.IEventData) {
- ActorSystem().PostEvent(data)
- }
- func IsBattleValidation() bool {
- return isBattleValidation
- }
- // SetBattleValidation 探险PVE战斗验证开关
- func SetBattleValidation(value bool) {
- isBattleValidation = value
- }
|