Exemple #1
0
        public CompactCollection <Catch> PlayerLeaderboardCompact(string data, string userId)
        {
            string selectFunc(Catch x) => $"{x.Fish.Name}|{x.Length}|{x.Weight};";

            var fisher = FishingSystem.GetFisherById(userId);

            if (string.IsNullOrWhiteSpace(data))
            {
                if (fisher != null)
                {
                    return(new CompactCollection <Catch>(fisher.Records, selectFunc));
                }
                return(new CompactCollection <Catch>(new Catch[0], null));
            }
            else
            {
                if (int.TryParse(data, out var id))
                {
                    var fish = fisher.Records.ToList();
                    if (id > 0 && id <= fish.Count)
                    {
                        return(new CompactCollection <Catch>(new Catch[] { fish[id - 1] }, selectFunc));
                    }
                }
                return(null);
            }
        }