-
Notifications
You must be signed in to change notification settings - Fork 862
[CNS] Implements Grenzo's Rebuttal #13541
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
xenohedron
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.
custom effect is overimplemented and needs to be fully reworked
| } | ||
| // if player is in range they choose a creature to control | ||
| if (currentPlayer != null && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { | ||
| FilterArtifactPermanent filterArtifact = new FilterArtifactPermanent( |
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.
try using CardTypeAssigner in a custom target class, instead of reimplementing all the target choose code multiple times
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 didn't find a way for number of choices to be modular with CardTypeAssigner(like choosing same permanent for artifact and creature) so i made loop to reuse code like it was done in most recent effect like this in [[Mythos of Snapdax]].
Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSupportTokens.java
Outdated
Show resolved
Hide resolved
| Player currentPlayer = game.getPlayer(playerList.get()); | ||
| boolean firstIteration = true; | ||
|
|
||
| for (Player nextPlayer = game.getPlayer(playerList.getNext()); !currentPlayer.getId().equals(controllerId) || firstIteration; nextPlayer = game.getPlayer(playerList.getNext())) { |
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.
okay, you fulfilled the literal request, but that's not the point
What I really care about here is that the loop can be trivially analyzed to know that it will always finish. That means using a foreach / iterator. for (Object object : Set objects) basically.
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.
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.
Yeah, i tried to find a way to use foreach but only public methods that circular list allows are modifying list. It could be done with selecting index manually with getting index of current player and then incrementing it but that doesn't seem clean to me.
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.
It's by design cause there are possible effects that can change players order from left to right, see Aeon Engine.
So after getting copy by game.getState().getPlayersInRange -- you must call getNext and getPrev with game param (so it will cycle in good direction). Also you can use that code to get a static players list with workable index access -- controllerId will have index 0, next player +1, etc
List<UUID> playersList = new ArrayList<>(game.getState().getPlayersInRange(controllerId, game, true));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.
List<UUID> playersList = new ArrayList<>(game.getState().getPlayersInRange(controllerId, game, true));
for (int i = 0; i < playersList.size(); i++) {
UUID currentPlayer = playersList.get(i);
UUID nextPlayer = playersList.get(i + 1 < playersList.size() ? i + 1 : 0);
}

Implement Grenzo's Rebuttal