Fix broken script when json is not in TF/O/M/D order#75
Merged
tchajed merged 1 commit intotchajed:mainfrom Nov 19, 2025
Merged
Conversation
tchajed
approved these changes
Nov 10, 2025
Owner
tchajed
left a comment
There was a problem hiding this comment.
Thanks for doing this!
I have one cleanup comment but I'm happy to merge even without that.
src/js/select_script.ts
Outdated
Comment on lines
+7
to
+15
| const ROLE_TYPE_ORDER = [ | ||
| "townsfolk", | ||
| "outsider", | ||
| "minion", | ||
| "demon", | ||
| "travellers", | ||
| "fabled", | ||
| ] as const; | ||
|
|
Owner
There was a problem hiding this comment.
Can you move this to ./botc/roles? It is related to display but the game consistently presents roles in this order.
Contributor
Author
There was a problem hiding this comment.
Oh it looks like there is already a similar list there RolesTypes, just that it's fabled first and then travelers, which is consistent with how official script tool presents it so I'll follow suit and just use that list.
eb1e6a0 to
6a37790
Compare
Contributor
Author
|
Done! |
6a37790 to
3a4bbd8
Compare
3a4bbd8 to
49081fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seems like this is a known issue from when parseJson was first implemented in #8.
It's an easy fix, just do a stable-sort in TF/O/M/D order. Tested with a randomly shuffled TB script:
http://localhost:5173/script.html?json=[{"id": "mayor"}, {"id": "poisoner"}, {"id": "investigator"}, {"id": "soldier"}, {"id": "undertaker"}, {"id": "spy"}, {"id": "virgin"}, {"id": "empath"}, {"id": "butler"}, {"id": "slayer"}, {"id": "monk"}, {"id": "_meta", "name": "Trouble Brewing"}, {"id": "recluse"}, {"id": "baron"}, {"id": "saint"}, {"id": "scarletwoman"}, {"id": "washerwoman"}, {"id": "fortuneteller"}, {"id": "chef"}, {"id": "ravenkeeper"}, {"id": "imp"}, {"id": "drunk"}, {"id": "librarian"}]