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

Add initiative ties resolution setting #295

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Trantion897
Copy link

@Trantion897 Trantion897 commented Aug 9, 2024

Pull Request Description

Add an option to define how initiative ties are resolved.

Default is players first, similar to existing behaviour (not explicitly defined, but players seem to be added to encounters before other creatures). Other options are NPCs first or random.

Changes Proposed

  • New option in settings to define how initiative ties are resolved.
  • When creatures are dragged & dropped, ordering index is stored for each creature to override initiative ties setting
  • Order of creatures is defined by initiative, then manual order, then initiative ties setting.
  • Dragging creatures outside of their current initiative still changes their initiative, as before
  • Rerolling initiative clears manual ordering and reapplies initiative ties setting
  • Used constants for an existing setting instead of hardcoded strings

Related Issues

Fixes #294 by adding an option to make NPCs win initiative ties

Checklist

  • I have read the contribution guidelines and code of conduct.
  • I have tested the changes locally and they are working as expected.
  • I have added appropriate comments and documentation for the code changes.
  • My code follows the coding style and standards of this project.
  • I have rebased my branch on the latest main (or master) branch.
  • All tests (if applicable) have passed successfully.
  • I have run linters and fixed any issues.
  • I have checked for any potential security issues or vulnerabilities.

Screenshots (if applicable)

Additional Notes

Player first - player characters go first, order is otherwise undefined.
This appears to be the existing behaviour, because player characters appear
in the unsorted array first.
NPC first - NPCs go first, order is otherwise undefined.
Random - All characters on the same initiative go in a random order

Also uses OVERFOW_TYPE constants in settings.ts
When any creature is dragged in the initiative order, the current order of every
creature is stored. The order of all creatures is resolved in this order:
1. Initiative
2. Manual order
3. Initiative ties option
If a creature is dragged out of its current initiative, the initiative value is
updated, as previously. Manual ordering lets you reorder initiative to override
other settings, for example in Pathfinder where by default NPCs always come
before players on the same initiative, you can drag a player to come before an
NPC if they have the feat that allows this.

Manual ordering is wiped when initiative is rerolled. It isn't wiped if the
initiative ties setting is changed, because this might not be what the player
wants.
@Trantion897
Copy link
Author

I've run the linters as part of npm run build, not a full eslint run; and I don't see any existing tests. Please let me know if I missed something

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.

🐞 Pathfinder initiative resolution for ties is incorrect
1 participant