Exemplo n.º 1
0
        public static void SetReturnVariableIndexTest()
        {
            var instance            = new CommonEvent();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var commonVarAddress = (CommonEventReturnVariableIndex)10;

            var errorOccured = false;

            try
            {
                instance.SetReturnVariableIndex(commonVarAddress);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 意図したとおりプロパティ変更通知が発火していること
            Assert.AreEqual(changedPropertyList.Count, 2);
            Assert.IsTrue(changedPropertyList[0].Equals(nameof(CommonEvent.ReturnVariableIndex)));
            Assert.IsTrue(changedPropertyList[1].Equals(nameof(CommonEvent.IsReturnValue)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 返戻セルフ変数インデックス
        /// </summary>
        /// <param name="readStatus">読み込み経過状態</param>
        /// <param name="commonEvent">結果格納インスタンス</param>
        private void ReadReturnVariableIndex(BinaryReadStatus readStatus, CommonEvent commonEvent)
        {
            var index = readStatus.ReadInt();

            readStatus.IncreaseIntOffset();

            commonEvent.SetReturnVariableIndex(index);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 返戻セルフ変数インデックス
        /// </summary>
        /// <param name="status">読み込み経過状態</param>
        /// <param name="commonEvent">結果格納インスタンス</param>
        private void ReadReturnVariableIndex(FileReadStatus status, CommonEvent commonEvent)
        {
            var index = status.ReadInt();

            status.IncreaseIntOffset();

            commonEvent.SetReturnVariableIndex(index);

            Logger.Debug(FileIOMessage.SuccessRead(typeof(CommonEventReader),
                                                   "返戻セルフ変数インデックス", index));
        }
            public static CommonEvent GenerateCommonEvent002()
            {
                var result = new CommonEvent
                {
                    Id            = 2,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.OnlyCall,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 0,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント002",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString(
                            "[300][10,1]<0>(0,68,128,2,127,255,1600005,1600005,1600005,1600005)(\"コモンイベント001\")"),
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()")
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    /* 画面では見えないが、一度設定したことがあるためデータ内に存在する。*/
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "テスト",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.Normal, null);
                    return(desc);
                }))());

                result.SelfVariableNameList[0] = "テスト";

                result.SetReturnVariableIndex(0);
                result.ReturnValueDescription = "";

                return(result);
            }
            public static CommonEvent GenerateCommonEvent007()
            {
                var result = new CommonEvent
                {
                    Id            = 7,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.ParallelAlways,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 1,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント007",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        EventCommandFactory.CreateCommandString("[0][0,0]<0>()()"),
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "",
                        InitValue = 0
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, null);
                    desc.SetDatabaseRefer(DBKind.System, 0);
                    desc.SetDatabaseUseAdditionalItemsFlag(false);
                    return(desc);
                }))());

                result.SetReturnVariableIndex(41);
                result.ReturnValueDescription = "Return";

                return(result);
            }
            public static CommonEvent GenerateCommonEvent000()
            {
                var result = new CommonEvent
                {
                    Id            = 0,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.OnlyCall,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 0,
                    StrArgsLength    = 0,
                    Name             = "コモンイベント000",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        new Message
                        {
                            Indent = 0,
                            Text   = "イベントコマンド"
                        },
                        new Blank
                        {
                            Indent = 0
                        }
                    }),
                    Description  = "",
                    Memo         = "",
                    LabelColor   = CommonEventLabelColor.Black,
                    FooterString = "",
                };

                result.SelfVariableNameList[0]  = "cself0";
                result.SelfVariableNameList[99] = "cself99";

                result.SetReturnVariableIndex(99);
                result.ReturnValueDescription = "てすと";

                return(result);
            }
            public static CommonEvent GenerateCommonEvent001()
            {
                var result = new CommonEvent
                {
                    Id            = 1,
                    BootCondition = new CommonEventBootCondition
                    {
                        CommonEventBootType = CommonEventBootType.OnlyCall,
                        LeftSide            = 2000000,
                        Operation           = CriteriaOperator.Equal,
                        RightSide           = 0
                    },
                    NumberArgsLength = 3,
                    StrArgsLength    = 4,
                    Name             = "コモンイベント001",
                    EventCommands    = new EventCommandList(
                        new List <IEventCommand>
                    {
                        new Message
                        {
                            Indent = 0,
                            Text   = "イベントコマンド"
                        },
                        new Blank
                        {
                            Indent = 0
                        }
                    }),
                    Description  = "",
                    Memo         = "Memo",
                    LabelColor   = CommonEventLabelColor.Blue,
                    FooterString = "",
                };

                /* ---------- セルフ変数名 ---------- */
                result.SelfVariableNameList[0]  = "cself0";
                result.SelfVariableNameList[1]  = "数値変数2";
                result.SelfVariableNameList[2]  = "数値変数3";
                result.SelfVariableNameList[3]  = "数値変数4";
                result.SelfVariableNameList[5]  = "文字列変数1";
                result.SelfVariableNameList[6]  = "文字列変数2";
                result.SelfVariableNameList[7]  = "文字列変数3";
                result.SelfVariableNameList[8]  = "文字列変数4";
                result.SelfVariableNameList[89] = "返戻";
                result.SelfVariableNameList[90] = "CSelf90";
                result.SelfVariableNameList[99] = "cself99";

                /* ---------- 数値引数 ---------- */
                result.UpdateSpecialNumberArgDesc(0,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "数値変数1",
                        InitValue = 128
                    };
                    desc.ChangeArgType(CommonEventArgType.Manual, new List <CommonEventSpecialArgCase>
                    {
                        new CommonEventSpecialArgCase(128, "DDD"),
                        new CommonEventSpecialArgCase(-1, "AAA"),
                        new CommonEventSpecialArgCase(127, "BBB")
                    });
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(1,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "数値変数2",
                        InitValue = 2
                    };
                    desc.ChangeArgType(CommonEventArgType.Manual, new List <CommonEventSpecialArgCase>
                    {
                        new CommonEventSpecialArgCase(0, ""),
                        new CommonEventSpecialArgCase(128, ""),
                        new CommonEventSpecialArgCase(65535, "")
                    });
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(2,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "数値変数3",
                        InitValue = 127
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, null);
                    desc.SetDatabaseRefer(DBKind.Changeable, 5);
                    desc.SetDatabaseUseAdditionalItemsFlag(false);
                    return(desc);
                }))());
                result.UpdateSpecialNumberArgDesc(3,
                                                  ((Func <CommonEventSpecialNumberArgDesc>)(() =>
                {
                    /* 数値変数4は実際には設定されていないが、一度でも設定されたことがある場合そのデータが残っている。 */
                    var desc = new CommonEventSpecialNumberArgDesc
                    {
                        ArgName = "数値変数4",
                        InitValue = 255
                    };
                    desc.ChangeArgType(CommonEventArgType.ReferDatabase, new[]
                    {
                        new CommonEventSpecialArgCase(-1, ""),
                        new CommonEventSpecialArgCase(-2, ""),
                        new CommonEventSpecialArgCase(-3, "End"),
                    });
                    desc.SetDatabaseRefer(DBKind.System, 0);
                    desc.SetDatabaseUseAdditionalItemsFlag(true);
                    return(desc);
                }))());

                /* ---------- 文字列引数1 ---------- */
                result.UpdateSpecialStringArgDesc(0,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "文字列引数1"
                });
                /* ---------- 文字列引数2 ---------- */
                result.UpdateSpecialStringArgDesc(1,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "文字列引数2"
                });
                /* ---------- 文字列引数3 ---------- */
                result.UpdateSpecialStringArgDesc(2,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "文字列引数3"
                });
                /* ---------- 文字列引数4 ---------- */
                result.UpdateSpecialStringArgDesc(3,
                                                  new CommonEventSpecialStringArgDesc
                {
                    ArgName = "文字列引数4"
                });

                result.SetReturnVariableIndex(90);
                result.ReturnValueDescription = "返戻";

                return(result);
            }