fixed bank quest

.nc will now show instructions
This commit is contained in:
Toastie 2025-03-30 18:38:31 +13:00
parent 6891869046
commit 53af8f940d
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
6 changed files with 48 additions and 38 deletions

View file

@ -100,6 +100,13 @@ public sealed class BankService(
if (rows > 0)
{
await _cur.AddAsync(userId, amount, new("bank", "withdraw"));
await quests.ReportActionAsync(userId,
QuestEventType.BankAction,
new()
{
{ "type", "withdraw" },
{ "amount", amount.ToString() }
});
return true;
}
@ -114,6 +121,13 @@ public sealed class BankService(
.FirstOrDefaultAsync(x => x.UserId == userId))
?.Balance
?? 0;
await quests.ReportActionAsync(userId,
QuestEventType.BankAction,
new()
{
{ "type", "balance" }
});
return res;
}
}

View file

@ -60,6 +60,12 @@ public partial class Games
await Response()
.File(stream, "ncanvas.png")
.Embed(CreateEmbed()
.WithDescription("""
Draw pixels on the canvas!
`.ncz x y` to zoom to a particular coordinates
`.ncs CODE color` to set color
`.nc` to see the whole canvas
""")
.WithOkColor()
#if GLOBAL_ELLIE
.WithDescription("This is not available yet.")

View file

@ -4,9 +4,8 @@ using LinqToDB.EntityFrameworkCore;
using EllieBot.Common.ModuleBehaviors;
using EllieBot.Db.Models;
using EllieBot.Modules.Games.Quests;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using SixLabors.ImageSharp.PixelFormats;
using Color = SixLabors.ImageSharp.Color;
namespace EllieBot.Modules.Games;
@ -20,8 +19,8 @@ public sealed class NCanvasService : INCanvasService, IReadyExecutor, IEService
private readonly ICurrencyService _cs;
private readonly QuestService _quests;
public const int CANVAS_WIDTH = 250;
public const int CANVAS_HEIGHT = 125;
public const int CANVAS_WIDTH = 200;
public const int CANVAS_HEIGHT = 100;
public const int INITIAL_PRICE = 3;
public NCanvasService(
@ -49,32 +48,6 @@ public sealed class NCanvasService : INCanvasService, IReadyExecutor, IEService
if (count == CANVAS_WIDTH * CANVAS_HEIGHT)
return;
var oldWidth = 500;
var oldHeight = 250;
if (count == oldWidth * oldHeight)
{
await uow.GetTable<NCPixel>()
.Where(x => x.Position % (oldWidth * 2) % 2 != 0 // x is odd
|| (x.Position / oldWidth) % 2 != 0) // or y is odd
.DeleteAsync();
await uow.GetTable<NCPixel>()
.Where(x => x.Position % (oldWidth * 2) % 2 == 0
&& (x.Position / oldWidth) % 2 == 0)
.UpdateAsync(old => new()
{
Position = (old.Position % oldWidth) / 2
+ ((old.Position / oldWidth) / 2) * CANVAS_WIDTH,
Price = INITIAL_PRICE,
Text = old.Text,
OwnerId = old.OwnerId,
Color = old.Color,
});
return;
}
await ResetAsync();
}
@ -92,12 +65,9 @@ public sealed class NCanvasService : INCanvasService, IReadyExecutor, IEService
await uow.GetTable<NCPixel>()
.BulkCopyAsync(toAdd.Select(x =>
{
var clr = ColorSpaceConverter.ToRgb(new Hsv(((float)Random.Shared.NextDouble() * 360),
(float)(0.5 + (Random.Shared.NextDouble() * 0.49)),
(float)(0.4 + (Random.Shared.NextDouble() / 5 + (x % 100 * 0.2)))))
.ToVector3();
var clr = Color.Black;
var packed = new Rgba32(clr).PackedValue;
var packed = ((Rgba32)clr).PackedValue;
return new NCPixel()
{
Color = packed,

View file

@ -4285,7 +4285,9 @@
"Aliases": [
".ncanvas",
".nc",
".ncanv"
".ncanv",
".pixel",
".pixels"
],
"Description": "Shows the current nCanvas.\nThe canvas allows users to set each pixel's color and text using currency.",
"Usage": [
@ -7717,6 +7719,22 @@
"Options": null,
"Requirements": []
},
{
"Aliases": [
".quoteadd",
".qa",
".qadd",
".quadd"
],
"Description": "Adds a new quote with the specified name and message.",
"Usage": [
".quoteadd sayhi Hi"
],
"Submodule": "QuoteCommands",
"Module": "Utility",
"Options": null,
"Requirements": []
},
{
"Aliases": [
".quoteedit",

View file

@ -4,7 +4,7 @@ version: 3
isEnabled: false
# Quotas for patron system
quotas:
None:
None:
I:
livechannels: 1
ai: 0
@ -22,4 +22,4 @@ quotas:
ai: 500
C:
livechannels: 5
ai: -1
ai: -1

View file

@ -1477,6 +1477,8 @@ ncanvas:
- ncanvas
- nc
- ncanv
- pixel
- pixels
ncsetimg:
- ncsetimg
- ncsi