Пример #1
0
        public async Task DrawMaskAsync()
        {
            using (var g = new GraphicsService())
            {
                var d = new CardDetails(Context.Account, Context.User);

                using (Bitmap card = g.DrawCard(d, PaletteType.GammaGreen))
                {
                    using (var factory = new TextFactory())
                    {
                        Grid <float> mask = ImageHelper.GetOpacityMask(card);

                        var pixels = new Grid <Color>(card.Size, new ImmutableColor(0, 0, 0, 255));

                        // TODO: Make ImmutableColor.Empty values
                        pixels.SetEachValue((x, y) =>
                                            ImmutableColor.Blend(new ImmutableColor(0, 0, 0, 255), new ImmutableColor(255, 255, 255, 255),
                                                                 mask.GetValue(x, y)));

                        using (Bitmap masked = ImageHelper.CreateRgbBitmap(pixels.Values))
                            await Context.Channel.SendImageAsync(masked, $"../tmp/{Context.User.Id}_card_mask.png");
                    }
                }
            }
        }
Пример #2
0
 public ConwayRenderer(ImmutableColor liveColor, ImmutableColor deadColor, ulong?decayTickLength, Grid <ConwayCell> pattern)
 {
     LiveColor       = liveColor;
     DeadColor       = deadColor;
     DecayTickLength = decayTickLength;
     Pattern         = CurrentGeneration = pattern;
 }
Пример #3
0
        private static Canvas CreateCanvas(float width, float height, ImmutableColor backgroundColor)
        {
            int u = (int)MathF.Floor(width);
            int v = (int)MathF.Floor(height);

            return(new Canvas(u, v, backgroundColor));
        }
Пример #4
0
        private static void DrawPointOn(Canvas canvas, float x, float y, ImmutableColor color)
        {
            int u = (int)MathF.Floor(x);
            int v = (int)MathF.Floor(y);

            if (canvas.Pixels.Contains(u, v))
            {
                canvas.Pixels.SetValue(color, u, v);
            }
        }
Пример #5
0
        public static Message ApplyAndDisplay(ArcadeUser user, DailyResultFlag flag)
        {
            long           reward = Reward;
            string         header = $"{Reward:##,0}";
            ImmutableColor color  = ImmutableColor.GammaGreen;
            var            icon   = "+ 💸";

            switch (flag)
            {
            case DailyResultFlag.Cooldown:
                TimeSpan sinceLast = StatHelper.SinceLast(user, CooldownVars.Daily);
                TimeSpan rem       = Cooldown - sinceLast;
                DateTime time      = DateTime.UtcNow.Add(rem);

                color  = GammaPalette.Amber[Gamma.Max];
                header = Format.Countdown(rem);
                icon   = Icons.GetClock(time.Hour);
                break;

            case DailyResultFlag.Reset:
                color = GammaPalette.NeonRed[Gamma.Max];
                user.SetVar(Stats.DailyStreak, 0);
                break;

            case DailyResultFlag.Bonus:
                color   = GammaPalette.Glass[Gamma.Max];
                header += $" + {Bonus:##,0}";
                reward += Bonus;
                break;
            }

            if (flag != DailyResultFlag.Cooldown)
            {
                user.SetVar(CooldownVars.Daily, DateTime.UtcNow.Ticks);
                user.AddToVar(Stats.DailyStreak);
                user.AddToVar(Stats.TimesDaily);
                Var.SetIfGreater(user, Stats.LongestDailyStreak, Stats.DailyStreak);
                user.Give(reward);
            }

            var message  = new MessageBuilder();
            var embedder = Embedder.Default;

            embedder.Color   = color;
            embedder.Header  = $"**{icon} {header}**";
            message.Content  = $"*\"{Replies.GetReply(flag)}\"*";
            message.Embedder = embedder;

            return(message.Build());
        }
Пример #6
0
 private static void DrawLineOn(Canvas canvas, float ax, float ay, float bx, float by, ImmutableColor color)
 => canvas.DrawLine((int)MathF.Floor(ax), (int)MathF.Floor(ay), (int)MathF.Floor(bx), (int)MathF.Floor(by), color);
Пример #7
0
        private static void DrawCircleOn(Canvas canvas, float x, float y, float radius, ImmutableColor color)
        {
            int u = (int)MathF.Floor(x);
            int v = (int)MathF.Floor(y);
            int r = (int)MathF.Floor(radius);

            canvas.DrawCircle(u, v, r, GammaPalette.GammaGreen[Gamma.Standard]);
        }
Пример #8
0
 private static void DrawCircleOn(Canvas canvas, CircleF circle, ImmutableColor color)
 => DrawCircleOn(canvas, circle.X, circle.Y, circle.Radius, color);
Пример #9
0
 private static Canvas CreateCanvas(RegionF region, ImmutableColor backgroundColor)
 => CreateCanvas(region.Width, region.Height, backgroundColor);
Пример #10
0
 private static void DrawHitboxOn(Canvas canvas, EntityHitbox hitbox, ImmutableColor sightColor, ImmutableColor reachColor, ImmutableColor originColor)
 {
     DrawCircleOn(canvas, hitbox.Sight, sightColor);
     DrawCircleOn(canvas, hitbox.Reach, reachColor);
     DrawPointOn(canvas, hitbox.X, hitbox.Y, originColor);
 }
Пример #11
0
 private static void DrawRectangleOn(Canvas canvas, float x, float y, float width, float height, ImmutableColor color)
 => canvas.DrawRectangle((int)MathF.Floor(x),
                         (int)MathF.Floor(y),
                         (int)MathF.Floor(width),
                         (int)MathF.Floor(height),
                         color);
Пример #12
0
        public Message ApplyAndDisplay(ArcadeUser user)
        {
            ImmutableColor color = ImmutableColor.GammaGreen;
            string         type  = IsSuccess ? "+" : "-";
            long           value = IsSuccess ? Reward : Wager;

            user.AddToVar(TickStats.TotalBet, Wager);
            user.AddToVar(TickStats.TimesPlayed);

            user.ChipBalance -= Wager;

            switch (Flag)
            {
            case TickResultFlag.Exact:
            case TickResultFlag.Win:
                user.SetVar(TickStats.CurrentLossStreak, 0);

                user.AddToVar(TickStats.TimesWon);
                user.AddToVar(TickStats.TotalWon, Reward);

                if (ExpectedTick == ActualTick)
                {
                    user.AddToVar(TickStats.TimesWonExact);
                }

                user.AddToVar(TickStats.CurrentWinStreak);
                user.AddToVar(TickStats.CurrentWinAmount, Reward);

                Var.SetIfGreater(user, TickStats.LongestWin, TickStats.CurrentWinStreak);
                Var.SetIfGreater(user, TickStats.LargestWin, TickStats.CurrentWinAmount);
                Var.SetIfGreater(user, TickStats.LargestWinSingle, Reward);
                break;

            case TickResultFlag.Lose:
                Var.Clear(user, TickStats.CurrentWinStreak, TickStats.CurrentWinAmount);
                user.AddToVar(TickStats.TimesLost);
                user.AddToVar(TickStats.CurrentLossStreak);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Flag));
            }

            if (IsSuccess)
            {
                user.ChipBalance += CurrencyHelper.BoostValue(user, Reward, BoostType.Chips);
            }

            string header = $"**{type} 🧩 {value:##,0}**";

            string content = Replies.GetReply(Flag, user, this);
            //GetQuote(ExpectedTick, ActualTick, Multiplier, Reward, IsSuccess);

            var embedder = new Embedder
            {
                Header = header,
                Color  = color
            };

            var builder = new MessageBuilder();

            builder.WithEmbedder(embedder)
            .WithContent(content);

            return(builder.Build());
        }
Пример #13
0
        public static Message ApplyAndDisplay(ArcadeUser user, VoteResultFlag flag)
        {
            long           reward  = Reward;
            string         header  = $"{Reward:##,0}";
            ImmutableColor color   = GammaPalette.Lemon[Gamma.Max];
            string         icon    = $"+ {Icons.Tokens}";
            string         content = "Thank you for voting!";

            switch (flag)
            {
            case VoteResultFlag.Cooldown:
                TimeSpan sinceLast = StatHelper.SinceLast(user, CooldownVars.Vote);
                TimeSpan rem       = Cooldown - sinceLast;
                DateTime time      = DateTime.UtcNow.Add(rem);

                content = "You are on cooldown.";
                color   = GammaPalette.Amber[Gamma.Max];
                header  = Format.Countdown(rem);
                icon    = Icons.GetClock(time.Hour);
                break;

            case VoteResultFlag.Reset:
                content = "Your streak has been reset.";
                color   = GammaPalette.NeonRed[Gamma.Max];
                user.SetVar(Stats.VoteStreak, 0);
                break;

            case VoteResultFlag.Bonus:
                content = "You have received a bonus.";
                color   = GammaPalette.Glass[Gamma.Max];
                header += $" + {Bonus:##,0}";
                reward += Bonus;
                break;

            case VoteResultFlag.Success:
                content = "Thank you for voting!";
                color   = GammaPalette.Wumpite[Gamma.Max];
                break;

            case VoteResultFlag.Unavailable:
                content = $"Voting allows you to receive a **Token** on each vote you submit.\nYou are given an additional 2 **Tokens** on each 7 day streak.\n**Tokens** can be cashed out, or saved to purchase upcoming special items that can only be bought with this currency!\nYou can vote every **12** hours on any voting platform, and your streak is cut short after **48**  hours.\n\n> **Voting Portal**\n• [**Discord Boats**](https://discord.boats/bot/686093964029329413/vote)";
                color   = GammaPalette.Oceanic[Gamma.Max];
                icon    = Icons.Tokens;
                header  = $"Voting";
                reward  = 0;
                break;
            }

            if (flag != VoteResultFlag.Cooldown && flag != VoteResultFlag.Unavailable)
            {
                user.SetVar(CooldownVars.Vote, DateTime.UtcNow.Ticks);
                user.AddToVar(Stats.VoteStreak);
                user.AddToVar(Stats.TimesVoted);
                Var.SetIfGreater(user, Stats.LongestVoteStreak, Stats.VoteStreak);
                user.Give(reward, CurrencyType.Tokens);
            }

            var message  = new MessageBuilder();
            var embedder = Embedder.Default;

            embedder.Color   = color;
            embedder.Header  = $"{icon} {header}";
            message.Content  = content;
            message.Embedder = embedder;

            return(message.Build());
        }
Пример #14
0
 private static void DrawLineOn(Canvas canvas, Vector2 a, Vector2 b, ImmutableColor color)
 => DrawLineOn(canvas, a.X, a.Y, b.X, b.Y, color);
Пример #15
0
 private static void DrawLineOn(Canvas canvas, Line line, ImmutableColor color)
 => DrawLineOn(canvas, line.A.X, line.A.Y, line.B.X, line.B.Y, color);
Пример #16
0
 private static void DrawPointOn(Canvas canvas, Vector2 point, ImmutableColor color)
 => DrawPointOn(canvas, point.X, point.Y, color);
Пример #17
0
 /// <summary>
 /// Adds embed color based on the provided <see cref="ImmutableColor"/> value.
 /// </summary>
 public static EmbedBuilder WithColor(this EmbedBuilder e, ImmutableColor color)
 => e.WithColor(color.R, color.G, color.B);
Пример #18
0
        private static void DrawRectangleOn(Canvas canvas, RegionF region, ImmutableColor color)
        {
            RegionF flat = RegionF.Floor(region);

            canvas.DrawRectangle((int)flat.X, (int)flat.Y, (int)flat.Width, (int)flat.Height, color);
        }
Пример #19
0
        public Message ApplyAndDisplay(ArcadeUser user)
        {
            var builder  = new MessageBuilder();
            var embedder = new Embedder();

            string         icon  = "💸";
            string         type  = "+";
            string         quote = Replies.GetReply(Flag, user, this);
            long           value = Reward;
            ImmutableColor color = ImmutableColor.GammaGreen;

            Var.Add(user, 1, GimiStats.TimesPlayed);

            switch (Flag)
            {
            case GimiResultFlag.Win:
            case GimiResultFlag.Gold:
                Var.Clear(user, GimiStats.CurrentCurseStreak, GimiStats.CurrentLossStreak, GimiStats.CurrentLossAmount);
                Var.Add(user, 1, GimiStats.TimesWon, GimiStats.CurrentWinStreak);
                Var.Add(user, Reward, GimiStats.TotalWon, GimiStats.CurrentWinAmount);
                Var.SetIfGreater(user, GimiStats.LongestWin, GimiStats.CurrentWinStreak);
                Var.SetIfGreater(user, GimiStats.LargestWin, GimiStats.CurrentWinAmount);

                if (Flag == GimiResultFlag.Gold)
                {
                    icon  = "💎";
                    type  = "+";
                    color = GammaPalette.Glass[Gamma.Max];

                    ItemHelper.GiveItem(user, Items.PocketLawyer);

                    if (RandomProvider.Instance.Next(0, 1001) == 1000)
                    {
                        ItemHelper.GiveItem(user, Items.PaletteGold);
                    }

                    Var.Add(user, 1, GimiStats.TimesGold, GimiStats.CurrentGoldStreak);
                    Var.SetIfGreater(user, GimiStats.LongestGold, GimiStats.CurrentGoldStreak);
                }
                else
                {
                    Var.Clear(user, GimiStats.CurrentGoldStreak);
                    Reward = CurrencyHelper.BoostValue(user, Reward, BoostType.Money);
                }
                long debt = user.Debt;
                user.Give(Reward);

                if (debt > Reward)
                {
                    icon  = "📃";
                    type  = "-";
                    quote = Replies.Recover.Length > 0 ? (string)Randomizer.Choose(Replies.Recover) : Replies.RecoverGeneric;
                }
                else if (debt > 0 && Reward - debt == 0)
                {
                    icon  = "📧";
                    type  = "";
                    quote = Replies.EvenGeneric;
                }

                break;

            case GimiResultFlag.Lose:
            case GimiResultFlag.Curse:
                type  = "-";
                color = ImmutableColor.NeonRed;

                Var.Clear(user, GimiStats.CurrentGoldStreak, GimiStats.CurrentWinStreak, GimiStats.CurrentWinAmount);
                Var.Add(user, 1, GimiStats.TimesLost, GimiStats.CurrentLossStreak);
                Var.Add(user, Reward, GimiStats.TotalLost, GimiStats.CurrentLossAmount);
                Var.SetIfGreater(user, GimiStats.LongestLoss, GimiStats.CurrentLossStreak);
                Var.SetIfGreater(user, GimiStats.LargestLoss, GimiStats.CurrentLossAmount);

                if (Flag == GimiResultFlag.Curse)
                {
                    icon  = "🌕";
                    type  = "-";
                    color = GammaPalette.Alconia[Gamma.Standard];

                    Var.Add(user, 1, GimiStats.TimesCursed, GimiStats.CurrentCurseStreak);
                    Var.SetIfGreater(user, GimiStats.LongestCurse, GimiStats.CurrentCurseStreak);
                }
                else
                {
                    Var.Clear(user, GimiStats.CurrentCurseStreak);
                    Reward = CurrencyHelper.BoostValue(user, Reward, BoostType.Money);
                }

                long balance = user.Balance;
                user.Take(Reward);

                if (balance < Reward)
                {
                    icon  = "📃";
                    type  = "+";
                    value = Reward - balance;
                    quote = Replies.Debt.Length > 0 ? (string)Randomizer.Choose(Replies.Debt) : Replies.DebtGeneric;
                }
                else if (balance > 0 && Reward - balance == 0)
                {
                    icon  = "📧";
                    value = Reward - balance;
                    type  = "";
                    quote = Replies.EvenGeneric;
                }
                break;
            }

            if (!string.IsNullOrWhiteSpace(type))
            {
                type += ' ';
            }

            string header  = $"**{type}{icon} {value:##,0}**";
            string content = $"*\"{quote}\"*";

            embedder.Header  = header;
            embedder.Color   = color;
            builder.Embedder = embedder;
            builder.Content  = content;

            return(builder.Build());
        }