Пример #1
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            ++this.CallsCount;

            try
            {
                this.CheckIJoinGameCallInfo(info);
                this.CheckBeforeOnJoin();
            }
            catch (Exception e)
            {
                info.Fail(e.ToString());
                return;
            }

            try
            {
                base.OnJoin(info);
                this.CheckAfterOnJoin();
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
            }
        }
        /// <summary>
        /// Callback for player joining the room
        /// </summary>
        /// <param name="info"></param>
        public override void OnJoin(IJoinGameCallInfo info)
        {
            base.OnJoin(info);

            if (PluginHost.GameActors.Count > NumberOfPlayers)
            {
                PluginHost.RemoveActor(info.ActorNr, 0, "Room is Full");
                PluginHost.LogError("Game is full");
                return;
            }

            if (IsGameStarted)
            {
                if (!joinAfterStart)
                {
                    PluginHost.RemoveActor(info.ActorNr, 0, "Game already started"); return;
                }
                PluginHost.CreateOneTimeTimer(
                    () => SyncPlayer(info),
                    200);
            }
            else
            {
                if ((PluginHost.GameActors.Count >= 2 && joinAfterStart) || (PluginHost.GameActors.Count >= NumberOfPlayers && !joinAfterStart))
                {
                    PluginHost.CreateOneTimeTimer(
                        () => StartGame(),
                        startDuration);
                }
            }
        }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     if (!this.PluginHost.GameId.EndsWith("OnJoinForgotCall"))
     {
         base.OnJoin(info);
     }
 }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     if (!this.PluginHost.GameId.EndsWith("OnJoinForgotCall"))
     {
         base.OnJoin(info);
     }
 }
        /// <summary>
        /// Sync player to current game state
        /// </summary>
        /// <param name="info"></param>
        protected virtual void SyncPlayer(IJoinGameCallInfo info)
        {
            PluginHost.LogError("Sync player" + info.ActorNr);

            PluginHost.BroadcastEvent(new List <int> {
                info.ActorNr
            }, 0, (byte)Event.GameStart, new Dictionary <byte, object>()
            {
                { (byte)0, board.Hight }, { (byte)1, board.Width }, { 2, board.MineCount }
            }, CacheOperations.DoNotCache);

            foreach (Dictionary <byte, object> dic in board.AllReveald())
            {
                PluginHost.BroadcastEvent(new List <int> {
                    info.ActorNr
                }, 0, (byte)Event.SyncFields, dic, CacheOperations.DoNotCache);
            }

            foreach (Dictionary <byte, object> dic in board.AllFlags())
            {
                PluginHost.BroadcastEvent(new List <int> {
                    info.ActorNr
                }, 0, (byte)Event.SyncFlags, dic, CacheOperations.DoNotCache);
            }
        }
Пример #6
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            Loger.LogTagFormat(Loger.TagPlugin, "OnJoin===============BEGIN");
            Loger.LogTagFormat(Loger.TagPlugin, info.ToStr());

            base.OnJoin(info);
            Loger.LogTagFormat(Loger.TagPlugin, "OnJoin---------------END");
        }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     if (this.PluginHost.GameActors.Count == 2)
     {
         PluginHost.SetProperties(0, new Hashtable() { { (byte)254, false }, { (byte)253, false } }, null, true);
     }
     base.OnJoin(info);
 }
Пример #8
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            this.PluginHost.LogInfo("Joined player " + info.ActorNr);

            //set ammo
            SetAmmo(info.ActorNr, 5);

            base.OnJoin(info);
        }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     if (this.PluginHost.GameActors.Count == 2)
     {
         PluginHost.SetProperties(0, new Hashtable()
         {
             { (byte)254, false }, { (byte)253, false }
         }, null, true);
     }
     base.OnJoin(info);
 }
Пример #10
0
        private void CheckIJoinGameCallInfo(IJoinGameCallInfo info)
        {
            this.CheckBaseInfo(info);

            Assert.AreNotEqual(0, info.ActorNr);
            Assert.IsNotNull(info.JoinParams);
            Console.Write(info.JoinParams.PublishCache);
            Console.Write(info.JoinParams.PublishJoinEvents);
            Console.Write(info.JoinParams.ResponseExtraParameters);

            CheckIJoinGameRequest(info.Request);
        }
Пример #11
0
 public void OnJoin(IJoinGameCallInfo info)
 {
     try
     {
         this.Plugin.OnJoin(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         this.ExceptionHanlder(info, e);
     }
 }
Пример #12
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeJoin"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnJoin(IJoinGameCallInfo info)
 {
     try
     {
         this.OnJoin(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }
Пример #13
0
        public static string ToStr(this IJoinGameCallInfo info)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("IJoinGameCallInfo =========== BEGIN");
            builder.AppendLine(string.Format("ICreateGameCallInfo.ActorNr={0}", info.ActorNr));
            builder.AppendLine(info.JoinParams.ToStr());
            builder.AppendLine(((ITypedCallInfo <IJoinGameRequest>)info).ToStr <IJoinGameRequest>());
            builder.AppendLine(((ICallInfo)info).ToStr());

            builder.AppendLine("IJoinGameCallInfo ----------- END");
            return(builder.ToString());
        }
        public override void OnJoin(IJoinGameCallInfo info)
        {
            PluginHost.LogDebug(string.Format("OnJoin {0}", info));

            base.OnJoin(info);

            Dictionary <byte, object> locateInfos = new Dictionary <byte, object>(PluginHost.GameActors.Count);

            foreach (var actor in PluginHost.GameActors)
            {
                locateInfos.Add((byte)actor.ActorNr, RandomLocate.GetRandomLocate());
            }

            BroadcastEvent((byte)EventCode.FirstLocate, locateInfos);
        }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     if (this.PluginHost.GameId.Contains("SetOnJoinBeforeContinue"))
     {
         this.PluginHost.SetProperties(info.ActorNr, new Hashtable {
             { "xxx", true }
         }, null, true);
     }
     base.OnJoin(info);
     if (this.PluginHost.GameId.Contains("SetOnJoinAfterContinue"))
     {
         this.PluginHost.SetProperties(info.ActorNr, new Hashtable {
             { "xxx", true }
         }, null, true);
     }
 }
Пример #16
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            var res = this.CheckBeforeOnJoin();

            if (!string.IsNullOrEmpty(res))
            {
                info.Fail(res);

                if (this.PluginHost.GameActors.Count != 1)
                {
                    this.PluginHost.BroadcastErrorInfoEvent("this.PluginHost.GameActors.Count != 1", info);
                }
                return;
            }

            try
            {
                // this part is not used anymore

                //if (this.PluginHost.GameProperties.ContainsKey("BlockJoinEvents"))
                //{
                //    info.JoinParams.PublishJoinEvents = false;
                //    info.JoinParams.ResponseExtraParameters = new Dictionary<byte, object>{{0, "Value0"}};
                //}

                //var actor2 = this.PluginHost.GameActors[1];
                //if(actor2.Properties.GetProperty("DoNotPublishCache") != null)
                //{
                //    info.JoinParams.PublishCache = false;
                //}

                base.OnJoin(info);
                this.CheckAfterOnJoin();
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
            }
        }
        public override void OnJoin(IJoinGameCallInfo info)
        {
            var res = this.CheckBeforeOnJoin();
            if (!string.IsNullOrEmpty(res))
            {
                info.Fail(res);

                if (this.PluginHost.GameActors.Count != 1)
                {
                    this.PluginHost.BroadcastErrorInfoEvent("this.PluginHost.GameActors.Count != 1", info);
                }
                return;
            }

            try
            {
                // this part is not used anymore

                //if (this.PluginHost.GameProperties.ContainsKey("BlockJoinEvents"))
                //{
                //    info.JoinParams.PublishJoinEvents = false;
                //    info.JoinParams.ResponseExtraParameters = new Dictionary<byte, object>{{0, "Value0"}};
                //}

                //var actor2 = this.PluginHost.GameActors[1];
                //if(actor2.Properties.GetProperty("DoNotPublishCache") != null)
                //{
                //    info.JoinParams.PublishCache = false;
                //}

                base.OnJoin(info);
                this.CheckAfterOnJoin();
            }
            catch (Exception e)
            {
                this.PluginHost.BroadcastErrorInfoEvent(e.ToString(), info);
            }
        }
Пример #18
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            // no sync OnJoin support for now - since we already changed the room state when we get here.
            // to allow a clean sync (cancelable OnJoin) we need to
            // a. run all the pre-checks
            // b. call OnJoin with the expected new actornr
            // c. on continue - add peer to room

            if (!string.IsNullOrEmpty(this.gameJoinUrl))
            {
                // remove for callAsync=false
                info.Continue();

                this.PostJsonRequest(
                    this.gameJoinUrl,
                    new WebhooksRequest
                {
                    Type       = "Join",
                    GameId     = this.PluginHost.GameId,
                    AppId      = this.AppId,
                    AppVersion = this.AppVersion,
                    Region     = this.Region,
                    UserId     = info.UserId,
                    Nickname   = info.Nickname,
                    ActorNr    = info.ActorNr,
                    AuthCookie = info.AuthCookie,
                },
                    this.LogIfFailedCallback,
                    info,
                    callAsync: true);
            }
            else
            {
                info.Continue();
            }
        }
Пример #19
0
 /// <summary>
 /// Calls info.Fail
 /// </summary>
 /// <param name="info"></param>
 public void OnJoin(IJoinGameCallInfo info)
 {
     info.Fail(this.errorMsg);
 }
Пример #20
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     this.onJoinEvent.Set();
     info.Continue();
 }
Пример #21
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeJoin"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnJoin(IJoinGameCallInfo info)
 {
     try
     {
         this.OnJoin(info);
         this.StrictModeCheck(info);
     }
     catch (Exception e)
     {
         ((IGamePlugin)this).ReportError(ErrorCodes.UnhandledException, e);
         CallFailSafe(info, e.ToString());
     }
 }
Пример #22
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     base.OnJoin(info);
 }
Пример #23
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     this.MethodBody(info, MethodBase.GetCurrentMethod().Name);
 }
Пример #24
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     this.onJoinEvent.Set();
     info.Continue();
 }
Пример #25
0
 private void OnJoinBeforeContinueFail(IJoinGameCallInfo info)
 {
     this.GenerateExceptionIf(info.Nickname, "OnJoinBeforeContinueFail");
 }
 protected override void SyncPlayer(IJoinGameCallInfo info)
 {
     base.SyncPlayer(info);
 }
Пример #27
0
 /// <summary>
 /// Plugin callback called when info.Continue() is called inside <see cref="IGamePlugin.BeforeJoin"/>.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 void IGamePlugin.OnJoin(IJoinGameCallInfo info)
 {
     this.OnJoin(info);
 }
Пример #28
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     this.OnJoinBeforeContinueFail(info);
     base.OnJoin(info);
     this.OnJoinAfterContinueFail(info);
 }
Пример #29
0
        public override void OnJoin(IJoinGameCallInfo info)
        {
            // no sync OnJoin support for now - since we already changed the room state when we get here.
            // to allow a clean sync (cancelable OnJoin) we need to
            // a. run all the pre-checks
            // b. call OnJoin with the expected new actornr
            // c. on continue - add peer to room

            if (!string.IsNullOrEmpty(this.gameJoinUrl))
            {
                // remove for callAsync=false
                info.Continue();

                this.PostJsonRequest(
                    this.gameJoinUrl,
                    new WebhooksRequest
                    {
                        Type = "Join",
                        GameId = this.PluginHost.GameId,
                        AppId = this.AppId,
                        AppVersion = this.AppVersion,
                        Region = this.Region,
                        UserId = info.UserId,
                        Nickname = info.Nickname,
                        ActorNr = info.ActorNr,
                        AuthCookie = info.AuthCookie,
                    },
                    this.LogIfFailedCallback,
                    info,
                    callAsync: true);
            }
            else
            {
                info.Continue();
            }
        }
 /// <summary>
 /// Called when player needs to be syncronized
 /// </summary>
 /// <param name="info"></param>
 protected override void SyncPlayer(IJoinGameCallInfo info)
 {
     scoreManager.AddPlayer(info.ActorNr, 0);
     turnManager.AddActor(PluginHost.GameActors.ToList().Find(a => a.ActorNr == info.ActorNr));
     base.SyncPlayer(info);
 }
Пример #31
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     _stateController.OnJoin(info);
 }
Пример #32
0
 /// <summary>
 /// Calls info.Continue(). Override to change.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 public virtual void OnJoin(IJoinGameCallInfo info)
 {
     System.Diagnostics.Debug.Assert(this.PluginHost != null);
     info.Continue();
 }
Пример #33
0
 /// <summary>
 /// Calls info.Continue(). Override to change.
 /// </summary>
 /// <param name="info">Data passed in the callback call.</param>
 public virtual void OnJoin(IJoinGameCallInfo info)
 {
     System.Diagnostics.Debug.Assert(this.PluginHost != null);
     info.Continue();
 }
 public override void OnJoin(IJoinGameCallInfo info)
 {
     this.OnJoinBeforeContinueFail(info);
     base.OnJoin(info);
     this.OnJoinAfterContinueFail(info);
 }
Пример #35
0
 /// <summary>
 /// Calls info.Fail
 /// </summary>
 /// <param name="info"></param>
 public void OnJoin(IJoinGameCallInfo info)
 {
     info.Fail(this.errorMsg);
 }
Пример #36
0
 public override void OnJoin(IJoinGameCallInfo info)
 {
     base.OnJoin(info);
     m_InfoRoom.I_NumberOfPlayers++;
 }
 private void OnJoinAfterContinueFail(IJoinGameCallInfo info)
 {
     this.GenerateExceptionIf(info.Nickname, "OnJoinAfterContinueFail");
 }