public PlayerBehaviour(string handle)
    {
        dummyManager = DummyManager.dummyManager;

        switch (handle)
        {
        case "rep":
            try
            {
                dummyManager.ReputationHandler.Subscribe(this);
            }
            catch (NullReferenceException)
            {
                Debug.LogWarning("System manager not found!");
            }
            break;

        case "susp":
            Debug.Log("NOT SUPPORTED"); break;

        case "days":
            Debug.Log("NOT SUPPORTED"); break;

        default:
            break;
        }
    }
Beispiel #2
0
        public override async Task <bool> TaskAsync(Dummy dummy, TestConfig config)
        {
            bool IsSuccess = false;

            config.ScenarioName = "OnlyConnect";

            var testStartTime = DateTime.Now;

            dummy.StartScenario();

            var result = await dummy.ConnectAsyncAndReTry();

            if (result.Result == false)
            {
                dummy.SetScenarioResult(false, "Fail");
            }
            else
            {
                IsSuccess = true;
                dummy.Connected();
                dummy.SetScenarioResult(true, "Success");

                DummyManager.AddDummyIteration();
            }

            return(IsSuccess);
        }
    void Awake()
    {
        StaticIngameData.dummyManager = this;
        DummyManager.dummyManager     = this;

        antiAfkPoints = AFKPointsDec;
    }
Beispiel #4
0
        static void DoLog()
        {
            Console.WriteLine("Doing Log!");

              if (_log.IsErrorEnabled)
            _log.Error("This is an Error...");

              if (_log.IsDebugEnabled)
            for (int i = 0; i < 10; i++)
              _log.Debug("This is a simple log!");

              if (_log.IsErrorEnabled)
            _log.Error("This is an Error...");

              if (_log.IsInfoEnabled)
            _log.Info("This is an Info...");

              _log.Warn("This is a Warning...");
              _log.Fatal("This is a Fatal...");

              _log.Error("This is an error with an exception.", new Exception("The message exception here."));

              _log.Warn("This is a message on many lines...\nlines...\nlines...\nlines...");
              _log.Warn("This is a message on many lines...\r\nlines...\r\nlines...\r\nlines...");

              var dm = new DummyManager();
              dm.DoIt();

              var dt = new DummyTester();
              dt.DoIt();
        }
        void UpdateUI(object sender, EventArgs e)
        {
            try
            {
                if (DummyManager.InProgress)
                {
                    var config = DummyManager.Config;
                    var curAllDummyIterationCount = DummyManager.CurAllDummyIterationCount();

                    textBox1.Text = DummyManager.ConnectedDummyCount().ToString();

                    if (DummyManager.Config.MaxRepeatCount > 0)
                    {
                        var 목표수 = DummyManager.DummyCount * config.MaxRepeatCount;
                        textBoxStatus.Text = $"[CurAllDummyIterationCount: {curAllDummyIterationCount}] [평균완료율: {curAllDummyIterationCount}/{목표수} ]";
                    }
                    else
                    {
                        var dt = DateTime.Now - DummyMgr.TestStartTime;
                        textBoxStatus.Text = $"[CurAllDummyIterationCount: {curAllDummyIterationCount}] [진행율: {dt.TotalSeconds}/{config.MaxRepeatTimeSec}초]";
                    }
                }
                else
                {
                    textBox1.Text      = "0";
                    textBoxStatus.Text = "";
                }
            }
            catch (Exception ex)
            {
                AddLog(ex.Message);
            }
        }
        public override async Task <bool> TaskAsync(Dummy dummy, TestConfig config)
        {
            bool isSuccess = false;

            config.ScenarioName = "Repeat Echo";

            var testStartTime = DateTime.Now;

            dummy.StartScenario();

            var roomNumber = EnterRoomNumber(RoomBaseInfo.MaxUserCount, dummy.Number);
            var enterRet   = await RequestAndPacketProcess.MTConnetToRoomEnter(dummy, roomNumber);

            if (enterRet.Ret == false)
            {
                dummy.SetScenarioResult(false, $"Fail - [MTConnetToRoomEnter] {enterRet.ErrStr}");
                return(isSuccess);
            }


            while (DummyManager.InProgress)
            {
                if (dummy.IsRun == false)
                {
                    return(isSuccess);
                }

                dummy.SetScenariActionMaxWaitTime(Utils.CurrentTimeSec() + 8);


                var chatRet = await RequestAndPacketProcess.RoomChatAsync(dummy);

                if (chatRet.Ret == false)
                {
                    dummy.SetScenarioResult(false, $"Fail - [RoomChat] {chatRet.ErrStr}");
                    break;
                }

                DummyManager.AddDummyIteration();

                var elapsedTime = DateTime.Now - testStartTime;
                if (Utils.IsCompletedRepeatTask(ref dummy.CurActionRepeatCount, config, elapsedTime.TotalSeconds))
                {
                    isSuccess = true;
                    break;
                }
            }


            dummy.DisConnect();

            if (isSuccess)
            {
                dummy.SetScenarioResult(true, "Success");
            }

            return(isSuccess);
        }
        public override async Task <bool> TaskAsync(Dummy dummy, TestConfig config)
        {
            bool isSuccess = false;

            config.ScenarioName = "Repeat Echo";

            var testStartTime = DateTime.Now;

            dummy.StartScenario();

            while (DummyManager.InProgress)
            {
                if (dummy.IsRun == false)
                {
                    return(isSuccess);
                }

                // 1 루프 사이에 최대 대기 시간을 걸어 놓도록 한다. 외부에서 이 대기 시간을 넘으면 자동 취소 시킨다
                dummy.SetScenariActionMaxWaitTime(Utils.CurrentTimeSec() + 8);


                var connRet = await dummy.ConnectAsyncAndReTry();

                if (connRet.Result == false)
                {
                    dummy.SetScenarioResult(false, $"Fail - [Connect] Code({connRet.ErrorCode}), {connRet.ErrorStr}");
                    return(isSuccess);
                }

                var loginRet = await RequestAndPacketProcess.LoginAsync(dummy);

                if (loginRet.Ret == false)
                {
                    dummy.SetScenarioResult(false, $"Fail - [Login] {loginRet.ErrStr}");
                    return(isSuccess);
                }

                dummy.DisConnect();

                DummyManager.AddDummyIteration();

                var elapsedTime = DateTime.Now - testStartTime;
                if (Utils.IsCompletedRepeatTask(ref dummy.CurActionRepeatCount, config, elapsedTime.TotalSeconds))
                {
                    isSuccess = true;
                    break;
                }
            }

            if (isSuccess)
            {
                dummy.SetScenarioResult(true, "Success");
            }

            return(isSuccess);
        }
Beispiel #8
0
        public override async Task <bool> TaskAsync(Dummy dummy, TestConfig config)
        {
            bool IsSuccess = false;

            config.ScenarioName = "Repeat Connect-DiscConnect";

            var testStartTime = DateTime.Now;

            dummy.StartScenario();

            while (DummyManager.InProgress)
            {
                var ret = await dummy.ConnectAsyncAndReTry();

                if (ret.Result == false)
                {
                    IsSuccess = false;
                    dummy.SetScenarioResult(false, $"Fail - ErrCode:{ret.ErrorCode}, {ret.ErrorStr}");
                    break;
                }
                else
                {
                    IsSuccess = true;
                    dummy.Connected();

                    dummy.DisConnect();
                }

                DummyManager.AddDummyIteration();

                var waitTimeMilli = dummy.NextConnectWaitTimeMilliSec(32, 640);
                await Task.Delay(waitTimeMilli);
            }


            if (IsSuccess)
            {
                dummy.SetScenarioResult(true, "Success");
            }
            return(IsSuccess);
        }
Beispiel #9
0
        static bool TestSwitchCaseCondition(string spelling, double value)
        {
            var dialect = new DefaultDialect();
            var manager = new DummyManager();

            var sc = dialect.GetSwitchConditionEvaluator(new Expression
            {
                Parts =
                    new List <ExpressionPart> {
                    new Text {
                        Spelling = spelling
                    }
                }
            }, manager);

            var success = sc.Evaluate(ParameterValue.Wrap(value), CreateContext(null, new LanguageInfo {
                Key = "en-US"
            }, null));

            Console.Out.WriteLine(value + " matches " + spelling + ": " + success);

            return(success);
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            //TestSwitchCaseCondition("@Test", 1);


            TestSwitchCaseCondition("% 10 = 2 or (1 and < 1)", 1);
            TestSwitchCaseCondition("% 10 = 2 or (1 and < 1)", 12);
            TestSwitchCaseCondition("% 10 = 2 or 5, 6, 7, 8, 9", 7);
            TestSwitchCaseCondition("% 10 = 2 or 5, 6, 7, 8, 9", 15);


            TestSwitchCaseCondition(" +1 % 10 = 1", 10);

            TestSwitchCaseCondition(" + 1 % 10 = 1", 10);

            TestSwitchCaseCondition("%10=1", 1);
            TestSwitchCaseCondition("%10=1", 10);
            TestSwitchCaseCondition("%10=1", 25);
            TestSwitchCaseCondition("%10=1", 11);



            var dialect = new DefaultDialect();
            var manager = new DummyManager();


            var test = "Hej {P1: Format spec} <F1:   {Moo:tahr}> {Abe:kat} #Fisso{1:  Foo 10 #Nested{Boo:Hawrh!} | 10} #Moo{{ab}} #Foo{|?Gok}";

            var p = new DefaultExpressionParser();
            var e = p.Parse(test, null);

            e.Accept(new Printer());

            var eval = new PatternEvaluator(e);

            Console.Out.WriteLine();
            Console.Out.WriteLine(e.ToString());

            Console.Out.WriteLine("Custom expression part");
            var customTest = "Hej {Name}";

            e = p.Parse(customTest, null);
            e.Parts.Add(new TestPart());
            e.Accept(new PatternDecorator(manager, dialect));

            eval = new PatternEvaluator(e);


            e.Accept(new Printer());
            Console.Out.WriteLine();
            Console.Out.WriteLine(eval.Evaluate(
                                      CreateContext(null, manager.CurrentLanguage, new Dictionary <string, object> {
                { "Name", "John" }
            })));
            Console.Out.WriteLine();
            Console.Out.WriteLine(e.ToString());

            var ptest = @"The values are {Name} and <Bold: <Bold:{Test}> <Bold:{Test}>><Bold: {Number:N2} (roman: {Number:roman})>. #Number{1: Singularis: 1 ({#}) | Pluralis\: n ({#})}.
            
                Boolean Expression: #Number{2 or 5: Yes | No}

                ModuloTest: #Number{% 2 = 0: Yes | No}
            
                {Name} has {Name.Length:N2} characters

                Let's enumerate 
                Enum test 1: #EnumTest1{0:{#}|, {#}|-1:"" and {#}""}
                Enum test 2: #EnumTest2{0:{#}|, {#}|-1:"" and {#}""}";

            Console.Out.WriteLine();

            var evaluator = dialect.GetEvaluator(ptest, manager);

            Console.Out.WriteLine(evaluator.Evaluate(
                                      CreateContext(null, manager.CurrentLanguage, new Dictionary <string, object> {
                { "Name", "John Doe" },
                { "Number", 5 },
                { "Bold", "<b>{#}</b>" },
                { "EnumTest1", new string[] { "A", "B", "C", "D" } },
                { "EnumTest2", new string[] { "A" } },
                { "EnumTest3", new string[] { "A", "B" } },
                { "Test", true }
            })));


            var texts = new List <LocalizedText>
            {
                new LocalizedText {
                    Key = "LookupCondition", Pattern = "% 10 <= 2", Language = "en-US", PatternDialect = "Text"
                },

                new LocalizedText {
                    Key = "Plural1", Pattern = "1", Language = "en-US", PatternDialect = "Text"
                },
                new LocalizedText {
                    Key = "Plural2", Pattern = "<20", Language = "en-US", PatternDialect = "Text"
                },

                new LocalizedText {
                    Key = "ShortPlural", Pattern = "The number is #Plural(Number){Not plural|Plural|More plural}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "PluralFun", Pattern = "The number is #Number{@LookupCondition: Plural|Not plural}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "Arithmetic", Pattern = "Test #Number{% 10 = 1: Module | + 1 * 2 > 10: Combined}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "Text one", Pattern = "Test one", Language = "en-US"
                },
                new LocalizedText {
                    Key = "Text two", Pattern = "Hello {UserName}", Language = "en-US"
                },
                new LocalizedText {
                    Key = "Text two", Pattern = "Hej {UserName}", Language = "da-DK"
                },
                new LocalizedText {
                    Key = "Enum", Pattern = @"#0{0: {#Index:roman}: {#}|, {#Index:roman}\: {#}|-1: "" {1} {#Index:roman}\: {#}""}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "Reffed", Pattern = "Test {0} String literal {1}", Language = "en-US"
                },
                new LocalizedText {
                    Key = "Ref test 1", Pattern = "Ref 1: {@Reffed} and Another namespace {@Another__Reffed}", Language = "en-US"
                },
                new LocalizedText {
                    Key = "Ref test 2", Pattern = @"Ref 2: {@Reffed(UserName, ""Moo"")}", Language = "en-US"
                },
                //This one makes sense, and shows why pattern references are neat
                new LocalizedText {
                    Key = "Ref test 3", Pattern = @"You have selected {@Enum(List, 'and')}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "Ref test 3", Namespace = "Another", Pattern = "Test one {@Reffed} and {@__Reffed}", Language = "en-US"
                },

                new LocalizedText {
                    Key = "Reffed", Namespace = "Another", Pattern = "I'm another", Language = "en-US"
                },

                new LocalizedText {
                    Key = "FormattedSwitch", Pattern = "Two decimals #Count:N2{1: One - ({#}) | More - {#}}", Language = "en-US"
                },
            };

            var xml = new XmlTextSource();

            xml.Put(texts.Select(x => new LocalizedTextState {
                Text = x, Status = LocalizedTextStatus.Unchanged
            }), TextMergeOptions.KeepUnused);

            xml.Document.Save("Texts.xml");


            xml          = new XmlTextSource();
            xml.Document = XDocument.Load("Texts.xml");


            manager.Texts.Sources.Add(new PrioritizedTextSource(xml));


            Console.Out.WriteLine(manager.Get("LookupCondition"));
            Console.Out.WriteLine(manager.Get("PluralFun", new { Number = 1 }));

            Console.Out.WriteLine("Shorthand:");
            Console.Out.WriteLine(manager.Get("ShortPlural", new { Number = 30 }));

            Console.Out.WriteLine(manager.Get("Text two", new { UserName = "******" }));

            Console.Out.WriteLine("Debug:");
            Console.Out.WriteLine(manager.Get("Text two", new { UserName = "******" }, debug: true));
            Console.Out.WriteLine();

            Console.Out.WriteLine(manager.Get("FormattedSwitch", new { Count = 7 }));

            Console.Out.WriteLine(manager.Get("Ref test 1", new { UserName = "******" }));
            Console.Out.WriteLine(manager.Get("Ref test 2", new { UserName = "******" }));

            Console.Out.WriteLine(manager.Get("Ref test 3", new { List = new[] { "Item 1", "Item 2", "Item 7", "Item 17" } }));
            Console.Out.WriteLine(manager.Get("Ref test 3", new { UserName = "******" }, ns: "Another"));

            string a = "Key";   /* @L10n @da-DK Foo @en-US Bar */
            string b = "Key 2"; // @L10n @da-DK Foo 2

            string.Format("Key 3" /* @L10n @da-DK Foo 3 */);



            string g = "Key"; /* @L10n @da-DK */


            string m = "Key" /* @L10n @en-US Goo */;

            //var extractor = new CStyleLanguageTextExtractor();
            //extractor.SourceFiles =
            //    new SourceFileList(@"C:\Users\niels.kuhnel\Stuff\Rebel\Rebel 5\I18n\i18n\Sandboxes\Localization\Sandbox.Localization.Tryout",
            //        new[] { "cs" }, new[] { "obj" }).GetFiles();

            //xml.Document = null;
            //xml.Put(extractor.Get().Select(x => new LocalizedTextState { Text = x }), TextMergeOptions.KeepUnused);
            //xml.Document.Save("Extracted.xml");


            Console.Out.WriteLine("Arithmetic");
            Console.Out.WriteLine(manager.Get("Arithmetic", new { Number = 11 }));

            Console.In.Read();
        }
Beispiel #11
0
        public override async Task <bool> TaskAsync(Dummy dummy, TestConfig config)
        {
            bool isSuccess = false;

            config.ScenarioName = "Repeat Echo";


            var testStartTime = DateTime.Now;

            dummy.StartScenario();

            var result = await dummy.ConnectAsyncAndReTry();

            if (result.Result == false)
            {
                dummy.SetScenarioResult(false, $"Fail - [Connect] ErrCode:{result.ErrorCode}, {result.ErrorStr}");
                return(isSuccess);
            }


            var sendPacketInfo = new SendEchoPacketInfo();

            sendPacketInfo.Init(DummyManager.Config.PacketSizeMax);

            while (DummyManager.InProgress)
            {
                // 스레드 잘 사용하는지 알기 위해 스레드 번호찍기
                //Utils.Logger.Debug($"Echo-Send. ClientIndex: {dummy.Index}");
                sendPacketInfo.SetData(config.EchoPacketSizeMin, config.EchoPacketSizeMax);

                var sendError = dummy.SendPacket(sendPacketInfo.BufferSize, sendPacketInfo.BufferData);
                if (sendError != "")
                {
                    dummy.SetScenarioResult(false, $"Fail - [Send] sendError");
                    return(isSuccess);
                }


                // 스레드 잘 사용하는지 알기 위해 스레드 번호찍기
                //Utils.Logger.Debug($"Echo-Recv. ClientIndex: {dummy.Index}");

                var waitUntilTime = DateTime.Now.AddSeconds(2);
                var(recvCount, recvError, packetList) = await dummy.ReceivePacketAsync(waitUntilTime, 1, CSBaseLib.PACKETID.PACKET_ID_ECHO);

                if (recvError != "" || packetList.Count == 0)
                {
                    dummy.SetScenarioResult(false, $"Fail - [Receive] {recvError}");
                    return(isSuccess);
                }


                if (sendPacketInfo.BodyData() != System.Text.Encoding.UTF8.GetString(packetList[0].Body))
                {
                    dummy.SetScenarioResult(false, $"Fail - [Receive] Data received is different from sent");
                    return(isSuccess);
                }

                DummyManager.AddDummyIteration();

                var elapsedTime = DateTime.Now - testStartTime;
                if (Utils.IsCompletedRepeatTask(ref dummy.CurActionRepeatCount, config, elapsedTime.TotalSeconds))
                {
                    isSuccess = true;
                    break;
                }
            }


            if (isSuccess)
            {
                dummy.SetScenarioResult(true, "Success");
            }
            return(isSuccess);
        }