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

Implement blocker assignment #28

Open
norswap opened this issue May 31, 2023 · 1 comment
Open

Implement blocker assignment #28

norswap opened this issue May 31, 2023 · 1 comment

Comments

@norswap
Copy link
Member

norswap commented May 31, 2023

Blocker selection resembles attacker selection but with the added difficulty that each blocker must be matched to an attacker.

To assign a defender, drag from the defender to the attacker to block (these should be highlighted with a glow). The dragging should create an arrow whose head follows the mouse cursor. Upon making a valid assignment (dragging from non-previously attacking creatures on your side to an attacking creature on the other side, then releasing), the arrow settles in place between the center of the defender and the center of the attacker and becomes permanent. If you start re-dragging from the same creature, the old arrow vanishes and you can make another assignment instead.

This kind of thing is implement in another card game called alketh (github, frontend), which can be used as inspiration (with the blessing of the creator).

Once satisfied with the blocker assignment, a "start fight" button can be pressed.

@norswap
Copy link
Member Author

norswap commented Jun 19, 2023

Some research on this:

  • code for drawing arrows in alketh
    • useful, but limited, because having re-tried the frontend, it only draws the arrows after dropping the attacking card on top of the defending card (i.e. there is not arrow being drawed as we dragged, which is what I want)
  • react-xarrows to draw arrows between a pair of components
    • not sure this is what we want because not sure if we can get the arrow head to follow the mouse cursor loosely, or wether it can work with normal components that are not within a canvas
  • vanilla javascript approach
    • we can definitely make that one work with react — the example is janky but it's a good starting point
  • dnd kit
    • doesn't support arrows, but we'll need drag and drop for other things (like playing cards)
    • seems like the most polished drag and drop lib for React
    • examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant