Exemple #1
0
        public CommandResult CatchFish(string data, string userId)
        {
            var fisher = FishingSystem.GetFisherById(userId);

            if (fisher != null && fisher.IsFishing)
            {
                var catchData = FishingSystem.CatchFish(fisher);
                if (catchData == null)
                {
                    return(new CommandResult("Nothing is biting yet! To reset your cast, use !cancelcast"));
                }

                if (FishingSystem.Tournament.IsRunning)
                {
                    var record    = fisher.Records.Where(x => x.Fish.Id == catchData.Fish.Id).FirstOrDefault();
                    var responses = new List <string>();
                    if (record.Weight == catchData.Weight)
                    {
                        responses.Add($"This is the biggest {catchData.Fish.Name} you've ever caught!");
                    }
                    var userEntry = FishingSystem.Tournament.CurrentTournament.Entries.Where(x => x.UserId.Equals(userId)).FirstOrDefault();
                    var sorted    = FishingSystem.Tournament.CurrentTournament.Entries.OrderBy(x => x.Points).ToList().IndexOf(userEntry) + 1;
                    responses.Add($"You caught a {catchData.Length} inch, {catchData.Weight} pound {catchData.Fish.Name} worth {catchData.Points} points! You are in {sorted.ToOrdinal()} place with {userEntry.Points} total points.");
                    return(new CommandResult(responses.ToArray()));
                }
                else
                {
                    return(new CommandResult($"Congratulations! You caught a {catchData.Length} inch, {catchData.Weight} pound {catchData.Fish.Name}!"));
                }
            }
            return(new CommandResult($"Your line has not been cast. Use !cast to start fishing"));
        }