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 isEmpty function to Module:Opponent #3258

Merged
merged 14 commits into from
Sep 14, 2023

Conversation

hjpalpha
Copy link
Collaborator

@hjpalpha hjpalpha commented Sep 3, 2023

depends on #3285

Summary

Add isEmpty function to Module:Opponent
Idea is to have an easy function for checking against this case sicne we might find it useful in several modules

How did you test this change?

not tested, new functions so can not break stuff and logic is pretty simple
did not set up testcases for opponent module since it would have to (imo) include lots more test cases and i would rather add that via a sep pr at a later time

@hjpalpha hjpalpha requested a review from iMarbot September 3, 2023 18:38
@Rathoz
Copy link
Collaborator

Rathoz commented Sep 5, 2023

Mind splitting into 2 PRs? The bye is completely fine for instance merge, but wanna think through the empty one a bit.

@hjpalpha
Copy link
Collaborator Author

hjpalpha commented Sep 5, 2023

Mind splitting into 2 PRs? The bye is completely fine for instance merge, but wanna think through the empty one a bit.

#3264

@hjpalpha hjpalpha changed the title Add isEmpty and isBye functions to Module:Opponent Add isEmpty function to Module:Opponent Sep 5, 2023
@hjpalpha
Copy link
Collaborator Author

hjpalpha commented Sep 5, 2023

Mind splitting into 2 PRs? The bye is completely fine for instance merge, but wanna think through the empty one a bit.

for the isEmpty one as an alternative option that might be better:

---Checks if an opponent is empty
---@param opponent standardOpponent?
---@return boolean
function Opponent.isEmpty(opponent)
	return not opponent or not opponent.type
		or (String.isEmpty(opponent.name) and String.isEmpty(opponent.template) and Table.isEmpty(opponent.players))
		or (not Opponent.isTbd(opponent) and Table.deepEquals(opponent, Opponent.blank(opponent.type)))
end

@hjpalpha hjpalpha requested a review from Rathoz September 8, 2023 23:24
@hjpalpha hjpalpha requested a review from iMarbot September 12, 2023 03:18
Copy link
Collaborator

@Rathoz Rathoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some comments (why comments) for the two cases?
Like TBD Team Opponents are not considered empty

@hjpalpha hjpalpha marked this pull request as draft September 13, 2023 13:01
@hjpalpha hjpalpha mentioned this pull request Sep 13, 2023
@hjpalpha hjpalpha marked this pull request as ready for review September 14, 2023 07:34
@hjpalpha hjpalpha requested a review from iMarbot September 14, 2023 07:34
@Rathoz Rathoz merged commit ba166a2 into main Sep 14, 2023
2 checks passed
@Rathoz Rathoz deleted the add-isEmpty-and-isBye-functions-to-opponent-module branch September 14, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants