Exemplo n.º 1
0
        /// <summary>
        /// Parses the line
        /// </summary>
        /// <returns>A GrouveeGame object with all the data from the line</returns>
        public GrouveeGame ParseLine()
        {
            // Sets the tail to the full game line
            tail = gameString;
            var game = new GrouveeGame();

            // Each line here parses reads and parses each element of the game line.
            // When an element is read, it is removed from tail, so the subsequent element
            // will be at the front of the tail to be read next. Where an element ends
            // is detected with regex (thankfully internal json '"' are escaped as '""',
            // and '\""' inside json strings) in NextElement()
            game.id           = int.Parse(NextElement());
            game.name         = NextElement();
            game.shelves      = ShelfParser(NextElement());
            game.platforms    = NameUrlParser(NextElement());
            game.rating       = NullableIntParser(NextElement());
            game.review       = NextElement(); // For the love of all that is holy don't end these in '"', that case is a nightmare to handle, but feel free to try it if you're feeling brave.
            game.dates        = DateDataParser(NextElement());
            game.statuses     = StatusParser(NextElement());
            game.genres       = NameUrlParser(NextElement());
            game.franchises   = NameUrlParser(NextElement());
            game.developers   = NameUrlParser(NextElement());
            game.publishers   = NameUrlParser(NextElement());
            game.release_date = NullableDateTimeParser(NextElement());
            game.url          = new Uri(NextElement());
            game.giantbomb_id = NullableIntParser(NextElement());

            return(game);
        }
Exemplo n.º 2
0
        public IEnumerable <FinalFantasyVIIFilterModel> Selector(GrouveeGame game, int index)
        {
            var imageUri = Tools.getImageURI(game.url);

            return(game.dates.Select(d => new FinalFantasyVIIFilterModel
            {
                name = game.name,
                started_date = d.date_started.Value,
                finished_date = d.date_finished.Value,
                image = imageUri
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parse an array of date information
        /// </summary>
        /// <param name="dateDataString">The array as a json string</param>
        /// <returns>The date info as an IEnumerable[DateData]</returns>
        private static IEnumerable <GrouveeGame.DateData> DateDataParser(string dateDataString)
        {
            if (string.IsNullOrEmpty(dateDataString))
            {
                return(new List <GrouveeGame.DateData>());
            }

            return(from JObject t in JArray.Parse(dateDataString)
                   select new GrouveeGame.DateData
            {
                date_started = NullableDateTimeParser(t["date_started"].Value <string>()),
                date_finished = NullableDateTimeParser(t["date_finished"].Value <string>()),
                level_of_completion = GrouveeGame.ConvertLevelOfCompletion(t["level_of_completion"].Value <string>()),
                seconds_played = t["seconds_played"].Value <int?>()
            });
        }
Exemplo n.º 4
0
        public FinishedGameFilterModel Selector(GrouveeGame game, int index)
        {
            var finishedDateObject = game.dates.First(d => d.date_finished != null);

            var model = new FinishedGameFilterModel
            {
                name          = game.name,
                started_date  = finishedDateObject.date_started.Value,
                finished_date = finishedDateObject.date_finished.Value,
                index         = index + 1
            };

            model.MainStory = finishedDateObject.level_of_completion == GrouveeGame.LevelOfCompletion.MainStory
                ? model.index
                : (int?)null;
            model.MainStoryExtras = finishedDateObject.level_of_completion == GrouveeGame.LevelOfCompletion.MainStoryExtras
                ? model.index
                : (int?)null;
            model.HundredPercent = finishedDateObject.level_of_completion == GrouveeGame.LevelOfCompletion.HundredPercent
                ? model.index
                : (int?)null;

            return(model);
        }
Exemplo n.º 5
0
 public bool Filter(GrouveeGame game)
 { // Don't filter anything out
     return(true);
 }
Exemplo n.º 6
0
 public string Selector(GrouveeGame game, int index)
 {
     return(index + " " + game.name);
 }
Exemplo n.º 7
0
 public int Comparer(GrouveeGame x, GrouveeGame y)
 { // Order by game's name
     return(x.name.CompareTo(y.name));
 }
Exemplo n.º 8
0
 public int Comparer(GrouveeGame x, GrouveeGame y)
 { // Compares by start date
     return(x.dates.First(d => d.date_finished != null).date_finished.Value
            .CompareTo(y.dates.First(d => d.date_finished != null).date_finished.Value));
 }
Exemplo n.º 9
0
 public bool Filter(GrouveeGame game)
 { // Takes only games that have a finish date
     return(game.dates.FirstOrDefault(d => d.date_finished != null) != null);
 }
Exemplo n.º 10
0
 public bool Filter(GrouveeGame game)
 { // Takes only games that are in the FFVII series
     return(game.name.Contains("Final Fantasy VII"));
 }
Exemplo n.º 11
0
 public int Comparer(GrouveeGame x, GrouveeGame y)
 { // Compares by start date
     return(String.Compare(x.name, y.name, StringComparison.InvariantCulture));
 }
Exemplo n.º 12
0
 public bool Filter(GrouveeGame game)
 { // Takes only games that were played on the given year
     return(game.dates.Any(d => d.date_started?.Year == _year || d.date_finished?.Year == _year));
 }