-
Notifications
You must be signed in to change notification settings - Fork 226
Randomized caste for modtools/transform-unit #353
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
base: master
Are you sure you want to change the base?
Conversation
This randomizes the caste if either the -caste argument is omitted or if the given caste isn't found
myk002
left a comment
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 think using a random caste is good when none is specified, but if a caste is specified but not found, the script should throw an error.
|
|
||
| if not caste then | ||
| error 'Invalid caste.' | ||
| local rand_caste = math.random( 0, math.abs(#race.caste-1) ) |
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.
Could you write a unit test to show coverage of the case where race.caste has no elements? See the test/ dir for sample unit tests.
| error 'Invalid caste.' | ||
| local rand_caste = math.random( 0, math.abs(#race.caste-1) ) | ||
| if not race.caste[rand_caste] then | ||
| error 'Creature has no castes or non have been found' |
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.
Typo non -> none
| local rand_caste = math.random( 0, math.abs(#race.caste-1) ) | ||
| if not race.caste[rand_caste] then | ||
| error 'Creature has no castes or non have been found' | ||
| else |
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.
No need to have an else clause if the if clause throws an error. Just replace the else with an end and let the assignment happen unconditionally.
|
I updated the title of the PR to track the status. Could you remove the |
|
@Bagelboi do you have time to address the review comments? |
|
ping on this |
|
waiting on response from author |
This randomizes the caste if either the -caste argument is omitted or if the given caste isn't found