public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            dispatcher.Register("存档").Then(
                PresetNodes.Literal <DMEnv>("保存")

                .Executes((env, args, dict) => SaveScenario(env, env.Sce))
                .Then(
                    PresetNodes.String <DMEnv>("团名")
                    .Executes((env, args, dict) => SaveScenario(env, args.GetStr("团名")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("读取")
                .Executes((env, args, dict) => LoadScenario(env, env.GroupId))
                .Then(
                    PresetNodes.String <DMEnv>("团名")
                    .Executes((env, args, dict) => LoadScenario(env, env.GroupId, args.GetStr("团名")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("开始")
                .Then(
                    PresetNodes.String <DMEnv>("团名")
                    .Executes((env, args, dict) => StartScenario(env, env.GroupId, env.SelfId, args.GetStr("团名")))
                    //.Then(
                    //    PresetNodes.Literal<DMEnv>("强制")
                    //    .Executes((env, args, dict) => StartScenario(env.GroupId, args.GetStr("团名")))
                    //)
                    )
                );

            dispatcher.SetAlias("读团", "存档 读取");
            dispatcher.SetAlias("存团", "存档 保存");
            dispatcher.SetAlias("开团", "存档 开始");
        }
示例#2
0
        /// <summary>
        /// 注册以字面量打头的指令
        /// </summary>
        /// <param name="head">指令头</param>
        /// <returns>注册的第一个节点</returns>
        public CommandNode <TEnv> Register(string head)
        {
            CommandNode <TEnv> n = PresetNodes.Literal <TEnv>(head);

            Root.AddChild(n);
            return(n);
        }
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            DictMapper <DMEnv> mapper = new DictMapper <DMEnv>()
                                        .Then("年龄", new IntParser <DMEnv>())
                                        .Then("含幸运", new BoolParser <DMEnv>("是", "否"));

            dispatcher.Register("coc7")
            .MapDict(mapper)
            .Executes((env, args, dict) => DrawProperties(env, 5, dict.Get("年龄", -1)))
            .Then(
                PresetNodes.Int <DMEnv>("数量")
                .MapDict(mapper)
                .Executes((env, args, dict) => DrawProperties(env, args.GetInt("数量"), dict.Get("年龄", -1)))
                ).Then(
                PresetNodes.Literal <DMEnv>("购点")
                .Then(
                    PresetNodes.Int <DMEnv>("总点数")
                    .MapDict(mapper)
                    .Executes((env, args, dict) => env.Append("该功能还未实行"))
                    )
                );

            dispatcher.SetAlias("COC7", "coc7");
            dispatcher.SetAlias("COC", "coc7");
            dispatcher.SetAlias("coc", "coc7");
        }
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            IDictionary <object, object> hardnessMap = new Dictionary <object, object> {
                ["普通"] = CheckResult.NormalSuccess,
                ["困难"] = CheckResult.HardSuccess,
                ["极难"] = CheckResult.ExtremeSuccess,
            };
            IDictionary <object, object> twiceMap = new Dictionary <object, object> {
                ["奖励"] = true,
                ["惩罚"] = false,
            };

            dispatcher.Register("检定").Then(
                MainAction = PresetNodes.String <DMEnv>("数值名")
                             .Handles(Extensions.ExistSelfValue)
                             .Executes((DMEnv env, Args args, Args dict) => SimpleCheck(env, env.Inv, args.GetStr("数值名"), CheckResult.NormalSuccess))
                             .Then(
                    PresetNodes.Or <DMEnv>("难度", "普通", "困难", "极难")
                    .Handles(PreProcesses.MapArg <DMEnv>(hardnessMap))
                    .Executes((DMEnv env, Args args, Args dict) => SimpleCheck(env, env.Inv, args.GetStr("数值名"), args.GetInt("难度")))
                    .Then(
                        PresetNodes.Or <DMEnv>("奖惩", "奖励", "惩罚")
                        .Handles(PreProcesses.MapArg <DMEnv>(twiceMap))
                        .Executes((DMEnv env, Args args, Args dict) => TwiceCheck(env, env.Inv, args.GetStr("数值名"), args.GetBool("奖惩"), args.GetInt("难度")))
                        )
                    ).Then(
                    PresetNodes.Or <DMEnv>("奖惩", "奖励", "惩罚")
                    .Handles(PreProcesses.MapArg <DMEnv>(twiceMap))
                    .Executes((DMEnv env, Args args, Args dict) => TwiceCheck(env, env.Inv, args.GetStr("数值名"), args.GetBool("奖惩"), CheckResult.NormalSuccess))
                    ).Then(
                    PresetNodes.Literal <DMEnv>("对抗").Then(
                        PresetNodes.String <DMEnv>("对手名")
                        .Handles(Extensions.ExistInv)
                        .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("数值名"), false))
                        .Then(
                            PresetNodes.String <DMEnv>("对抗数值名")
                            .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("对抗数值名"), false))
                            )
                        )
                    ).Then(
                    PresetNodes.Literal <DMEnv>("等级对抗").Then(
                        PresetNodes.String <DMEnv>("对手名")
                        .Handles(Extensions.ExistInv)
                        .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("数值名"), true))
                        .Then(
                            PresetNodes.String <DMEnv>("对抗数值名")
                            .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("对抗数值名"), true))
                            )
                        )
                    ).Then(
                    PresetNodes.String <DMEnv>("目标")
                    .Executes((DMEnv env, Args args, Args dict) => SimpleCheckTo(env, env.Inv, args.GetStr("数值名"), args.GetStr("目标")))
                    )
                );

            dispatcher.SetAlias("ch", "检定");
        }
示例#5
0
        public void OnRegister(CmdDispatcher <TestEnv> dispatcher)
        {
            CommandNode <TestEnv> root = PresetNodes.Literal <TestEnv>("物品");

            DictMapper mapper = new DictMapper()
                                .Then("前缀", new StringParser())
                                .Then("后缀", new StringParser())
            ;

            Console.WriteLine(string.Join("\n", root.GetHelp()));
            dispatcher.Register("物品",
                                PresetNodes.Literal <TestEnv>("创造")
                                .Then(PresetNodes.String <TestEnv>("物品名")
                                      .MapDict(mapper)
                                      .Executes((env, args, dict) => CreateItem(
                                                    env.Items,
                                                    args.Get <string>("物品名"),
                                                    dict.Get <string>("前缀"),
                                                    dict.Get <string>("后缀")
                                                    ))),
                                PresetNodes.Literal <TestEnv>("销毁")
                                .Then(PresetNodes.String <TestEnv>("物品名")
                                      .Executes((env, args, dict) => DestoryItem(
                                                    env.Items,
                                                    args.Get <string>("物品名")
                                                    ))),
                                PresetNodes.Literal <TestEnv>("编辑")
                                .Then(PresetNodes.String <TestEnv>("物品名")
                                      .Then(PresetNodes.String <TestEnv>("新名字")
                                            .MapDict(mapper)
                                            .Executes((env, args, dict) => EditItem(
                                                          env.Items,
                                                          args.Get <string>("物品名"),
                                                          args.Get <string>("新名字"),
                                                          dict.Get <string>("前缀"),
                                                          dict.Get <string>("后缀")
                                                          )))),
                                PresetNodes.Literal <TestEnv>("显示")
                                .Executes((env, args, dict) => ListItems(env.Items))
                                );

            dispatcher.SetAlias("创造", "物品 创造");
            dispatcher.SetAlias("销毁", "物品 销毁");
        }
示例#6
0
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            dispatcher.Register("控制")
            .Then(
                PresetNodes.Literal <DMEnv>("关联")
                .Executes((env, args, dict) => Relate(env))
                )
            .Then(
                PresetNodes.String <DMEnv>("卡名")
                .Handles(Extensions.ExistInv)
                .Executes((env, args, dict) => Control(env, env.SelfId, env.Sce, args.GetInv("卡名")))
                .Then(
                    PresetNodes.Cmd <DMEnv>("行动").Executes((env, args, dict) => ControlAndAct(env, args.GetInv("卡名"), args.GetCmd("行动")))
                    )
                );

            dispatcher.SetAlias("ct", "控制");
            dispatcher.SetAlias("关联到此", "控制 关联");
        }
示例#7
0
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            dispatcher.Register("全局").Then(
                PresetNodes.Literal <DMEnv>("配置").Then(
                    PresetNodes.Literal <DMEnv>("载入")
                    .Executes((env, args, dict) => ("载入" + (SaveUtil.LoadGlobal() ? "成功" : "失败")))
                    ).Then(
                    PresetNodes.Literal <DMEnv>("保存")
                    .Executes((env, args, dict) => ("保存" + (SaveUtil.SaveGlobal() ? "成功" : "失败")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("调试").Then(
                    PresetNodes.Bool <DMEnv>("开关", "开", "关")
                    .Executes((env, args, dict) => {
                Global.Debug = args.GetBool("开关");
                env.Next     = "调试模式:" + (Global.Debug ? "开" : "关");
            })
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("回复").Then(
                    PresetNodes.Bool <DMEnv>("开关", "开", "关")
                    .Executes((env, args, dict) => {
                Global.DoAt = args.GetBool("开关");
                SaveUtil.SaveGlobal();
                env.Next = "回复:" + (Global.DoAt ? "开" : "关");
            })
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("自动载入").Then(
                    PresetNodes.Bool <DMEnv>("开关", "开", "关")
                    .Executes((env, args, dict) => {
                Global.AutoLoad = args.GetBool("开关");
                SaveUtil.SaveGlobal();
                env.Next = "自动载入:" + (Global.AutoLoad ? "开" : "关");
            })
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("翻译腔").Then(
                    PresetNodes.Bool <DMEnv>("开关", "开", "关")
                    .Executes((env, args, dict) => {
                Global.TranslatorTone = args.GetBool("开关");
                //SaveUtil.SaveGlobal();
                env.Next = "翻译腔:" + (Global.TranslatorTone ? "开" : "关");
            })
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("睡眠").Then(
                    PresetNodes.Bool <DMEnv>("开关", "开", "关")
                    .Executes((env, args, dict) => {
                Global.Sleep = args.GetBool("开关");
                SaveUtil.SaveGlobal();
                env.Next = (Global.Sleep ? "那我去睡觉觉咯~w" : "爷来啦!");
            })
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("灌铅")
                .Then(
                    PresetNodes.Int <DMEnv>("数值")
                    .Executes((env, args, dict) => {
                env.Next = !Global.AllowedLead ? "禁止给老娘灌铅!喵~o( =▼ω▼= )m!" : "当前铅量:" + (Global.SetLead(args.GetInt("数值")));
                SaveUtil.SaveGlobal();
            })
                    ).Then(
                    PresetNodes.Literal <DMEnv>("重置")
                    .Executes((env, args, dict) => {
                Global.SetLead(50);
                env.Next = "铅量已重置为" + Global.Lead;
                SaveUtil.SaveGlobal();
            })
                    )
                );

            dispatcher.SetAlias("配置", "全局 配置");
            dispatcher.SetAlias("调试", "全局 调试");
            dispatcher.SetAlias("回复", "全局 回复");
            dispatcher.SetAlias("自动载入", "全局 自动载入");
            dispatcher.SetAlias("闭嘴", "全局 睡眠 开");
            dispatcher.SetAlias("说话", "全局 睡眠 关");
            dispatcher.SetAlias("翻译腔", "全局 翻译腔");
            dispatcher.SetAlias("灌铅", "全局 灌铅");
        }
示例#8
0
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            DictMapper <DMEnv> mapper = new DictMapper <DMEnv>();

            mapper.Rest(new ValueParser());

            dispatcher.Register("人物卡")
            .Then(
                PresetNodes.Literal <DMEnv>("新建").Then(
                    PresetNodes.String <DMEnv>("名称")
                    .MapDict(mapper)
                    .Executes((env, args, dict) => CreateInv(env, args.GetStr("名称"), "", dict))
                    .Then(
                        PresetNodes.String <DMEnv>("描述")
                        .MapDict(mapper)
                        .Executes((env, args, dict) => CreateInv(env, args.GetStr("名称"), args.GetStr("描述"), dict))
                        )
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("重命名").Then(
                    PresetNodes.String <DMEnv>("新名称")
                    .Executes((env, args, dict) => Rename(env, args.GetStr("新名称")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("销毁").Then(
                    PresetNodes.String <DMEnv>("名称")
                    .Executes((env, args, dict) => "销毁人物卡需要操作者是管理员,并且需要加上“强制”参数!")
                    .Then(
                        PresetNodes.Literal <DMEnv>("强制")
                        .Executes((env, args, dict) => DestoryInv(env, args.GetStr("名称")))
                        )
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("重算")
                .Executes((env, args, dict) => ReCalc(env, env.Inv))
                .Then(
                    PresetNodes.String <DMEnv>("名称")
                    .Handles(Extensions.ExistInv)
                    .Executes((env, args, dict) => ReCalc(env, args.GetInv("名称")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("检查")
                .Executes((env, args, dict) => Check(env, env.Inv))
                ).Then(
                PresetNodes.Literal <DMEnv>("伤害加值")
                .Then(
                    Extensions.Dice("数值")
                    .Executes((env, args, dict) => SetDB(env, args.GetDice("数值")))
                    )
                ).Then(
                PresetNodes.Literal <DMEnv>("标记")
                .Then(
                    PresetNodes.Literal <DMEnv>("添加")
                    .Rest(
                        PresetNodes.String <DMEnv>("标签")
                        .Handles(PreProcesses.ConvertObjectArrayToStringArray)
                        .Executes((env, args, dict) => AddTags(env, env.Inv, args.Get <string[]>("标签")))
                        )
                    ).Then(
                    PresetNodes.Literal <DMEnv>("移除")
                    .Rest(
                        PresetNodes.String <DMEnv>("标签")
                        .Handles(PreProcesses.ConvertObjectArrayToStringArray)
                        .Executes((env, args, dict) => RemoveTags(env, env.Inv, args.Get <string[]>("标签")))
                        )
                    )
                );

            dispatcher.SetAlias("车卡", "人物卡 新建");
            dispatcher.SetAlias("撕卡", "人物卡 销毁");
            dispatcher.SetAlias("重算", "人物卡 重算");
            dispatcher.SetAlias("标记", "人物卡 标记 添加");
            dispatcher.SetAlias("反标", "人物卡 标记 移除");
        }