[CNS] Implements Grenzo's Rebuttal#13541
Conversation
xenohedron
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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