Пример #1
0
        public static void TraverseAndAddOres(string fromType)
        {
            var reaction = Reactions.Where(x => x.Produces.Type == fromType).FirstOrDefault();

            foreach (var reactionRequires in reaction.Requires)
            {
                if (reactionRequires.Type == "ORE")
                {
                    TotalOres = TotalOres + reactionRequires.NormalizedValue;
                    return;
                }
                else
                {
                    TraverseAndAddOres(reactionRequires.Type);
                }
            }
        }
        public VideoModel Load(Guid id)
        {
            Video video = Videos.SingleOrDefault(v => v.Id == id);

            if (video == null)
            {
                return(null);
            }

            return(new VideoModel
            {
                Video = video,
                Owner = Users.SingleOrDefault(u => u.Id == video.OwnerId),
                Channels = Channels.Where(c => ChannelVideos.Where(v => v.VideoId == video.Id).Select(v => v.ChannelId).Contains(c.Id)),
                Tags = Tags.Where(t => VideoTags.Where(v => v.VideoId == video.Id).Select(v => v.TagId).Contains(t.Id)),
                Views = Views.Where(v => v.VideoId == video.Id),
                Reactions = Reactions.Where(r => r.VideoId == video.Id),
                Favourites = Favourites.Where(f => f.VideoId == video.Id),
                Comments = Comments.Where(c => c.VideoId == video.Id)
            });
        }
Пример #3
0
        public static void TraverseReactions(string fromType, int unitsRequired)
        {
            var reaction = Reactions.Where(x => x.Produces.Type == fromType).FirstOrDefault();
            var factor   = unitsRequired;

            if (reaction.Produces.Units != unitsRequired)
            {
                if (reaction.Produces.Units < unitsRequired)
                {
                    factor = (int)Math.Ceiling(unitsRequired / (float)reaction.Produces.Units);
                }
            }
            else
            {
                reaction.Produces.NormalizedValue = unitsRequired;

                foreach (var requires in reaction.Requires)
                {
                    requires.NormalizedValue = requires.Units * unitsRequired;
                }
            }

            foreach (var reactionRequires in reaction.Requires)
            {
                if (reactionRequires.Type == "ORE")
                {
                    //done
                    TotalOres += reactionRequires.Units * factor;
                    return;
                }
                else
                {
                    TraverseReactions(reactionRequires.Type, factor);
                }
            }
        }
Пример #4
0
 public Task <List <DiscordReaction> > GetReactionsAsync(ulong msgId)
 => Reactions.Where(x => (ulong)x.MessageId == msgId).ToListAsync();
Пример #5
0
        public int CalculateOre()
        {
            //initialisatie
            var totalOre         = 0;
            var Ingredients_list = new List <(string Ingredient, long Number)>();
            int counter          = 0;

            Ingredients_list = Reactions.Where(x => x.Product_name == "FUEL").Select(x => x.Ingredients).Single().ToList();
            string wat     = "";
            long   hoeveel = 0;

            while (counter < Ingredients_list.Count())
            {
                // Te vervangen ingredient
                wat     = Ingredients_list[counter].Ingredient;
                hoeveel = Ingredients_list[counter].Number;
                // als ingredient = ore: overslaan, counter verhogen
                if (wat != "ORE")
                {
                    // Nieuw ingredient
                    var Ingredients_list_add   = Reactions.Where(x => x.Product_name == wat).Select(x => x.Ingredients).Single().ToList();
                    var Ingredients_list_count = Reactions.Where(x => x.Product_name == wat).Select(x => x.Product_number).Single();
                    // kijken hoeveel keer ingredient gemaakt moet worden,
                    // toevoegen aan lijst,
                    // wat over is aan stock toevoegen
                    var aanwezig = Stock[wat];
                    if (hoeveel <= aanwezig)
                    {
                        Stock[wat] = aanwezig - hoeveel;
                    }
                    else
                    {
                        if (hoeveel <= Ingredients_list_count + aanwezig)
                        {
                            // 1 maal maken en toevoegen, rest aan stock toevoegen
                            Ingredients_list.AddRange(Ingredients_list_add);
                            Stock[wat] = aanwezig + Ingredients_list_count - hoeveel;
                        }
                        else
                        {
                            // berekenen hoeveel er nodig is en toevoegen.
                            var maal   = (hoeveel - aanwezig) / Ingredients_list_count;
                            var modval = (hoeveel - aanwezig) % Ingredients_list_count;
                            if (modval != 0)
                            {
                                maal++;
                            }
                            foreach (var item in Ingredients_list_add)
                            {
                                Ingredients_list.Add((item.Ingredient, item.Number * maal));
                            }
                            Stock[wat] = aanwezig + (maal * Ingredients_list_count) - hoeveel;
                        }
                    }
                }
                counter++;
            }

            totalOre = Ingredients_list.Where(x => x.Ingredient == "ORE").Select(x => x.Number).ToList().Aggregate(0, (a, b) => (int)(a + b));
            return(totalOre);
        }
        internal void ReactionUpdate(double value)
        {
            switch (value)
            {
            //Happy
            case 1:
                var reaction = Reactions.Where(reaction1 => reaction1.ReactionType == ReactionType.Happy).FirstOrDefault();

                if (reaction == null)
                {
                    Reactions.Add(new PostReaction(this, ReactionType.Happy, 1));
                }
                else
                {
                    (reaction as PostReaction).PostReactionCount++;
                }
                ReactionText = "Happy";

                break;

            //Neutral
            case 2:
                reaction = Reactions.Where(reaction1 => reaction1.ReactionType == ReactionType.Neutral).FirstOrDefault();

                if (reaction == null)
                {
                    Reactions.Add(new PostReaction(this, ReactionType.Neutral, 1));
                }
                else
                {
                    (reaction as PostReaction).PostReactionCount++;
                }
                ReactionText = "Neutral";

                break;

            //Wonder
            case 3:
                reaction = Reactions.Where(reaction1 => reaction1.ReactionType == ReactionType.Wonder).FirstOrDefault();

                if (reaction == null)
                {
                    Reactions.Add(new PostReaction(this, ReactionType.Wonder, 1));
                }
                else
                {
                    (reaction as PostReaction).PostReactionCount++;
                }
                ReactionText = "Wonder";

                break;

            //Sad
            case 4:
                reaction = Reactions.Where(reaction1 => reaction1.ReactionType == ReactionType.Sad).FirstOrDefault();

                if (reaction == null)
                {
                    Reactions.Add(new PostReaction(this, ReactionType.Sad, 1));
                }
                else
                {
                    (reaction as PostReaction).PostReactionCount++;
                }
                ReactionText = "Sad";

                break;

            //Angry
            case 5:
                reaction = Reactions.Where(reaction1 => reaction1.ReactionType == ReactionType.Angry).FirstOrDefault();

                if (reaction == null)
                {
                    Reactions.Add(new PostReaction(this, ReactionType.Angry, 1));
                }
                else
                {
                    (reaction as PostReaction).PostReactionCount++;
                }
                ReactionText = "Angry";

                break;

            default:
                break;
            }

            ReactionIndex = 0;
        }