Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gameEvents: created CHALLENGE_UNO event. #154

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

sethdivyansh
Copy link
Contributor

@sethdivyansh sethdivyansh commented Jun 23, 2024

fixes: #145

Description

  • Created challengeUno.ts.
  • Checked if a player can be challenged.
  • Player can be challenged only if vulnerableToUNO is equal to that player.
  • If the challenge is successful, the player must draw two cards from the deck as a penalty.
  • Created tests for the challenge_uno event and its corner cases in events.test.ts.

How to Test

I have created some tests in events.test.ts

Checklist

  • I have tested these changes locally.
  • I have reviewed the code and ensured it follows the project's coding guidelines.
  • I have updated the documentation, if necessary.
  • I have assigned reviewers to this pull request.

Copy link

vercel bot commented Jun 23, 2024

@sethdivyansh is attempting to deploy a commit to the Shivansh Bhatanagar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sethdivyansh
Copy link
Contributor Author

sethdivyansh commented Jun 23, 2024

events.test.ts is getting failed in CI test, even though it passes successfully in the local.

image

@sethdivyansh sethdivyansh changed the title gameEvents: created CHALLENGE_UNO event. gameEvents: created CHALLENGE_UNO event. Jun 23, 2024
@kuv2707
Copy link
Collaborator

kuv2707 commented Jun 23, 2024

Its a typescript error. The Player type has been renamed. Make the changes accordingly

@sethdivyansh sethdivyansh force-pushed the fix/issue-#145 branch 2 times, most recently from d69fee6 to 7eab482 Compare June 23, 2024 12:40
@sethdivyansh
Copy link
Contributor Author

@kuv2707 I have made the changes.


export function challengeUNO(game: GameEngine, event: GameEvent): EventResult {
assert(event.type === 'CHALLENGE_UNO', 'Invalid event type');
const player = getPlayer(game, event.playerId);
Copy link
Collaborator

@kuv2707 kuv2707 Jun 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event.playerId refers to the id of the player who triggered the event (it is set in the handleAppEvent function)

We should modify the event type to have a field challengedPlayerId inside data (which is no longer optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍
Please review the changes.

Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are allowing the player to be able to challenge himself😂
Let's keep that as an easter egg.

@sethdivyansh
Copy link
Contributor Author

Looks like we are allowing the player to be able to challenge himself😂 Let's keep that as an easter egg.

Oh right! I didn't think of it.
It would be fun to make it an easter egg 🥚😂

- Created `challengeUno.ts`.
- Checked if a player can be challenged.
- Player can be challenged only if `vulnerableToUNO` is equal to that player.
- If the challenge is successful, the player must draw two cards from the deck.
- Created tests for the challenge_uno event and its corner cases.

fixes: shivansh-bhatnagar18#145
Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
I really appreciate that you write tests for all the new logic

@kuv2707 kuv2707 merged commit d0978f3 into shivansh-bhatnagar18:master Jun 23, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the CHALLENGE_UNO event in the game engine
2 participants