Esempio n. 1
0
        public List<Event> GetValidEvents(FlagDictionary flagDictionary)
        {
            var automaticEvents = this.allEvents.Where(@event => @event.Automatic && EventCanExecute(@event, flagDictionary)).ToList();
              if (automaticEvents.Any())
            return new List<Event> { automaticEvents.First() };

              return this.allEvents.Where(@event => EventCanExecute(@event, flagDictionary)).ToList();
        }
Esempio n. 2
0
 void FlagImpl(FlagMap flagDic, string[] args)
 {
     if (args.Length < 2)
     {
         throw new NRuntimeException("引数が足りません。");
     }
     flagDic[args[1]] = args[0] == "on";
 }
Esempio n. 3
0
    protected override void Awake()
    {
        base.Awake();
        flags     = SaveDataHelper.Load <FlagMap>("flag.json") ?? new FlagMap();
        skipFlags = new FlagMap();
        areaFlags = new FlagMap();

        Wyte.GameSave += (wyte) =>
        {
            SaveDataHelper.Save("flag.json", flags);
            // スキップフラグはセーブされない.
        };

        Map.MapChanged += (wyte) =>
        {
            // さようなら.
            areaFlags.Clear();
        };
    }
Esempio n. 4
0
        public ShellFlagParser(string[] args, string[] flagConfig, Dictionary <string, int> followerConfig = null, string delim = "/")
        {
            Flags        = new FlagDictionary(this);
            FlagList     = new List <string>();
            NonFlags     = new List <string>();
            Followers    = new FollowerDictionary(this);
            FollowerList = new Dictionary <string, List <string> >();

            HashSet <string> flags = new HashSet <string>(flagConfig);

            flags.UnionWith(followerConfig.Keys);

            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i], flag = arg.Substring(delim.Length);
                if (arg.StartsWith(delim) && !FlagList.Contains(flag) && !String.IsNullOrEmpty(flag))
                {
                    if (!flags.Contains(flag))
                    {
                        throw new ShellArgumentException(arg, "Invalid flag name");
                    }

                    int followers;
                    if (followerConfig.TryGetValue(flag, out followers))
                    {
                        for (int j = 1; j <= followers && j + i < args.Length; j++)
                        {
                            if (!FollowerList.ContainsKey(flag))
                            {
                                FollowerList.Add(flag, new List <string>());
                            }
                            FollowerList[flag].Add(args[i + j]);
                        }
                        i += followers;
                    }
                    FlagList.Add(flag);
                }
                else
                {
                    NonFlags.Add(arg);
                }
            }
        }
Esempio n. 5
0
    private IEnumerator OnFlagImpl(FlagMap flagDic, string key, string[] labels)
    {
        if (labels.Length < 1)
        {
            return(null);
        }
        var useGosub = false;

        if (labels.Length >= 3)
        {
            useGosub = labels[0].ToLower() == "gosub";
            labels   = labels.Skip(1).ToArray();
        }
        if (flagDic[key])
        {
            return(useGosub ? Novel.Runtime.Gosub("", labels[0]) : Novel.Runtime.Goto("", labels[0]));
        }
        if (labels.Length >= 2)
        {
            return(useGosub ? Novel.Runtime.Gosub("", labels[1]) : Novel.Runtime.Goto("", labels[1]));
        }
        return(null);
    }
Esempio n. 6
0
 public override bool CanExecute(FlagDictionary flagDictionary) => flagDictionary["OverviewFinished"] && !flagDictionary["DepartureStarted"];
Esempio n. 7
0
 public override bool CanExecute(FlagDictionary flagDictionary) => flagDictionary["VillageDestroyed"];
Esempio n. 8
0
        public ActionResult Moment(int momentId)
        {
            if (this.userSession == null)
            return this.RedirectToRoute("Welcome");

              Claws.NotNull(() => this.userProfileClient);
              var userProfile = this.userProfileClient.GetUserProfile();
              if (userProfile == null)
            return this.RedirectToRoute("Welcome");

              var adventure = this.adventureDao.LookupAdventureByUserId(this.userSession.UserId);
              if (adventure == null)
            return this.RedirectToRoute("Game");

              var moment = this.adventureDao.LoadMoment(momentId);
              if (moment == null)
            return this.RedirectToRoute("Game");

              var readOnly = adventure.CurrentMomentId != momentId;

              var flags = moment.Flags;
              if (moment.EventName != null)
            flags = flags.Append(moment.EventName);
              var flagDictionary = new FlagDictionary(flags);
              var events = this.eventDriver.GetValidEvents(flagDictionary);

              var viewModel = new MomentViewModel {
            DisplayName = userProfile.DisplayName,
            StrideLength = userProfile.StrideLengthWalking,
            MomentId = momentId,
            ReadOnly = readOnly,
            Flags = flagDictionary,
            Choices = events,
              };

              if (this.Request.IsAjaxRequest())
            return this.View("~/Games/Views/Choices.cshtml", viewModel);
              else
            return this.View("~/Games/Views/Moment.cshtml", viewModel);
        }
Esempio n. 9
0
 public abstract bool CanExecute(FlagDictionary flagDictionary);
Esempio n. 10
0
 private static bool EventCanExecute(Event @event, FlagDictionary flagDictionary)
 {
     return (@event.Repeatable || !flagDictionary[@event.Name]) && @event.CanExecute(flagDictionary);
 }