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 helper functions for having one of multiple, or all of a set of subtypes #7821

Closed
NBKelly opened this issue Oct 14, 2024 · 10 comments · Fixed by #7833
Closed

Add helper functions for having one of multiple, or all of a set of subtypes #7821

NBKelly opened this issue Oct 14, 2024 · 10 comments · Fixed by #7833

Comments

@NBKelly
Copy link
Collaborator

NBKelly commented Oct 14, 2024

Writing this so I don't forget later

We've written

(and/or (has-subtype? x a)
        ...
        (has-subtype? x z))

enough times that they might as well be helper functions for clarity, like:

(defn has-a-subtype? x [a...]) ;; this will get used a ton
(defn has-every-subtype? x [a...]) ;; not sure how much this will get used
@heyshiloh
Copy link
Contributor

@NBKelly master...heyshiloh:netrunner:nr-7821-multi-subtypes

here is helpers + tests, but i am having trouble finding places in the code where this would easily refactor existing logic. Do you have examples of the above pattern that I could test refactor in?

@NBKelly
Copy link
Collaborator Author

NBKelly commented Oct 19, 2024

I might have imagined a need for the has-every-subtype one (it's still good to have), but for multiple subtypes (this will be used for some dawn cards too):

  • Az McCaffery
  • The Archivist
  • Asmund Pudlat
  • Adept/Savant
  • Laser Pointer
  • Hammer
  • Hagen
  • Foxfire
  • Executive Search Firm
  • Restoring Face
  • Unregistered S&W '35

@heyshiloh
Copy link
Contributor

@NBKelly i'll take a look at refactoring these with the method i wrote and let you know

@heyshiloh
Copy link
Contributor

  • passing tests for the first few

I see that greek philosopher suite holds logic in break-multiple-types so i will be a bit more meticulous on testing those

@NBKelly
Copy link
Collaborator Author

NBKelly commented Oct 19, 2024

Ah, no need to touch those ones if it doesn't make the code simpler

@heyshiloh
Copy link
Contributor

it should make the brewak-multiple function simpler, its just separated out logic so i will have to make sure im not breaking anything

@heyshiloh
Copy link
Contributor

@NBKelly

Ah, no need to touch those ones if it doesn't make the code simpler

This ended up being the case, it is a different situation than others because it applies break quantity per subtype rather than just checking if any subtype

master...heyshiloh:netrunner:nr-7821-multi-subtypes

Here is the diff for now. not trying to bombard you with PRs so let me know if you have time for this and I will send it over

@NBKelly
Copy link
Collaborator Author

NBKelly commented Oct 20, 2024

Make as many PR's as you want as fast as you want :) Worst case scenario is we just look at them later.

@NoahTheDuke
Copy link
Collaborator

one time @francescopellegrini opened like 22 one line prs in a row lol. i reviewed and merged every one. don't worry about us.

@heyshiloh
Copy link
Contributor

@NBKelly @NoahTheDuke You two are great, I still aim to be mindful about wasting time or generating too much noise 😅

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 a pull request may close this issue.

3 participants