-
Notifications
You must be signed in to change notification settings - Fork 42
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
gameEvent: Implement Throw Card Event #50
gameEvent: Implement Throw Card Event #50
Conversation
96835ef
to
5656cd6
Compare
5656cd6
to
273d3d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems promising, but is blocked by other issues currently.
ARCHITECTURE.md
Outdated
"data": { | ||
"cardID": "red-5" | ||
"card": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd want to use the CardID here
We'd have to be able to retrieve all cards by id.
Can you do that in a commit before the actual changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do it in a moment, rest of the things, i feel i have done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there much to do in this PR, apart from the documentation change, I guess the api handler will have a get card from card id function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should address all the feedback so far first.
return player.cards.find((c) => c.id === cardId); | ||
} | ||
|
||
export function throwCard(game: GameEngine, event: GameEvent): EventResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes need to be made to the logic when the drawCard
function is completed. I'll review it once that is done.
273d3d5
to
334ad0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Posted few comments.
334ad0a
to
6993e75
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted some comments.
Mainly, we'd need to work on:
- tests for the logic
- keeping
special
andwild
separate.
backend/src/types.d.ts
Outdated
@@ -1,7 +1,7 @@ | |||
// We declare those types which are used throughout the application here. | |||
// For types that are used only in one file, we can declare them in that file itself. | |||
|
|||
type CardType = 'number' | 'special' | 'wild'; | |||
type CardType = 'number' | 'special'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for removing the wild
type?
It made logical sense to separate special
from wild
, since some of the game rules (like DRAW4CHALLENGE
) depend on counting the number of wild
cards the user has. I think we'd want to keep them separate from special
cards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reasoning was that wild cards are just colorless special card, in the sense that they do soemthing to the game state, instead of just getting added to the pile.
i not aware of the draw4challenge rule, whenever i have played it before, we never had it, Though i guess uno is popular for everyone having their own rules, if its a official/popular rule, I'll add it back ig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of it either. But the rules we are following (link in ARCHITECTURE.md) mention it and it seems fun to implement.
Even if that weren't the case, it is a good idea to model the types after the actual game objects/properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need to add tests for all the logic here. This seems to be a crucial part of the game logic with many imaginable corner cases and bugs, so we'd need to look out for them in the tests.
@criticic Please prioritize this PR over any new work as this will help further work on the engine. |
4dd6ce4
to
7bc3d56
Compare
@criticic Are you working on it or should I close it? |
I’ll send a updated PR by tonight
On 11 Jun 2024, at 11:14 AM, Kislay ***@***.***> wrote:
@criticic<https://github.com/criticic> Are you working on it or should I close it?
—
Reply to this email directly, view it on GitHub<#50 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJVJDCRQRLZ4Z66WSIF7XTLZG2FDTAVCNFSM6AAAAABIUZLLWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJZHA2DAMRSGY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
6993e75
to
b05f7a3
Compare
b05f7a3
to
8ad0eca
Compare
8ad0eca
to
937e3a0
Compare
Adds the throw card event handler. Fixes shivansh-bhatnagar18#44 Signed-off-by: Sagnik Mandal <[email protected]>
937e3a0
to
435d475
Compare
} | ||
"type": "THROW_CARD", | ||
"playerId": "1", | ||
"cardId": "card-number-red-5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd want to go with the data object here.
return { type: 'ERROR', message: 'Player not found' }; | ||
} | ||
|
||
const card = findCard(player, event.data.card.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unnecessary to send the whole card object from the client when we can use id. I had earlier mentioned that we must setup a function to retrieve cards by id. In accordance with that, we will only be sending the card id from the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These provide foundational tests for the game engine, which is good to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic needs some minor reworking. For the record, the THROW_CARD
event object will have cardId
as the only attribute in its data
.
Also:
- We should shift the getting-card-by-id function to deck.ts.
- As mentioned earlier, it is very important to have tests for the throw-card logic because of subtle corner cases.
I think we can defer the tests for now, given that we are a little behind the schedule, but please be motivated to follow up on this with the tests. (you can open a PR for that even without any issue).
Despite some minor issues, I think we can merge it as it is good enough for the time being. I'll make some of the amendments in subsequent commits.
Some general suggestions:
- Respond to all feedback, even with an emoji reaction. This lets the maintainer know that the particular feedback has been addressed.
- Tag the maintainer if you want another review.
Merged, thanks @criticic |
Just pushed a commit, did that end up being merged?
On 13 Jun 2024, at 12:11 AM, Kislay ***@***.***> wrote:
Merged #50<#50> into master.
—
Reply to this email directly, view it on GitHub<#50 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJVJDCVMFYZI2IOG5E6WYTTZHCI4NAVCNFSM6AAAAABIUZLLWKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGEZTKOJYHE4DONI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
hey @kuv2707 please see the latest branch: https://github.com/criticic/csoc-multiplayer-uno/tree/feat/event-throw-card |
Description
adds the throw card handler
Fixes #44
Motivation and Context
[Explain the motivation behind these changes and provide any relevant context.]
How to Test
[Describe the steps to test the changes made in this pull request.]
Related Issues
[If applicable, mention any related issues or pull requests.]
Checklist
Screenshots (if applicable)
[If your changes include any visual updates, provide screenshots here.]