Update the drop mechanic to take currency on drop instead of claim (#428)
All checks were successful
Deploy To Stage / build (push) Successful in 59s
Deploy To Stage / deploy (push) Successful in 17s

# Description

- Update the drop mechanic to take currency on drop instead of claim
- Update the time until anyone can claim the card to 2 minutes
- Remove the restriction that the last drop can only be claimed by the user who dropped it
    - Now just controlled by the 2 minutes rule

#415

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: #428
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Ethan Lane 2025-05-16 17:37:57 +01:00 committed by Vylpes
parent 0669dfb0d0
commit 730af871a0
15 changed files with 188 additions and 54 deletions

View file

@ -1,7 +1,6 @@
import { ButtonInteraction, TextChannel } from "discord.js";
import Claim from "../../src/buttonEvents/Claim";
import { ButtonInteraction as ButtonInteractionType } from "../__types__/discord.js";
import User from "../../src/database/entities/app/User";
import GenerateButtonInteractionMock from "../__functions__/discord.js/GenerateButtonInteractionMock";
jest.mock("../../src/client/appLogger");
@ -85,25 +84,7 @@ test("GIVEN interaction.message was created more than 5 minutes ago, EXPECT erro
// Assert
expect(interaction.channel!.send).toHaveBeenCalledTimes(1);
expect(interaction.channel!.send).toHaveBeenCalledWith("[object Object], Cards can only be claimed within 5 minutes of it being dropped!");
expect(interaction.editReply).not.toHaveBeenCalled();
});
test("GIVEN user.RemoveCurrency fails, EXPECT error", async () => {
// Arrange
User.FetchOneById = jest.fn().mockResolvedValue({
RemoveCurrency: jest.fn().mockReturnValue(false),
Currency: 5,
});
// Act
const claim = new Claim();
await claim.execute(interaction as unknown as ButtonInteraction);
// Assert
expect(interaction.channel!.send).toHaveBeenCalledTimes(1);
expect(interaction.channel!.send).toHaveBeenCalledWith("[object Object], Not enough currency! You need 10 currency, you have 5!");
expect(interaction.channel!.send).toHaveBeenCalledWith("[object Object], Cards can only be claimed within 2 minutes of it being dropped!");
expect(interaction.editReply).not.toHaveBeenCalled();
});