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

[M3C] Implement Desert Warfare #12749

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

Sidorovich77
Copy link
Contributor

/**
* @author Sidorovich77
*/
public enum DesertsYouControlCount implements DynamicValue {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be a common class. You can use existing PermanentsOnBattlefieldCount with a filter.

/**
* @author JayDi85
*/
public enum DesertsYouControlHint implements Hint {
Copy link
Contributor

Choose a reason for hiding this comment

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

This also should not be a common class. Just use ValueConditionHint.

// graveyard from your hand or library, put that card onto the battlefield under your control at the beginning of your next end step.

//Based on Seraph, Yuma, Proud Protector
Effect effect = new CreateDelayedTriggeredAbilityEffect((DelayedTriggeredAbility) new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new DesertWarfareReturnEffect(), TargetController.YOU).setTriggerPhrase("Put that card onto the battlefield under your control at the beginning of your next end step.").setRuleVisible(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Hiding the rule is bad style. I kinda see what you're doing here, simulating the compound trigger condition by two abilities, but it is not a clean approach.

You're already writing a custom trigger, so just go all the way and check SACRIFICED_PERMANENT in it as well, and remove extraneous parameters. Setting the trigger phrase in that class and the staticText in the effect class should be sufficient, without all this other manual text setting.

Mage.Sets/src/mage/cards/d/DesertWarfare.java Show resolved Hide resolved
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you checking source permanent existing? it's not necessary for the effect.

if (player == null || permanent == null) {
return false;
}
int deserts = game.getBattlefield().countAll(new FilterLandPermanent(SubType.DESERT, "Deserts"), game.getControllerId(source.getSourceId()), game);
Copy link
Contributor

Choose a reason for hiding this comment

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

can't you just use player.getId() here?

also, "Deserts" does not specify land

@Override
public boolean checkTrigger(GameEvent event, Game game) {
Card card = game.getCard(event.getTargetId());
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD
Copy link
Contributor

Choose a reason for hiding this comment

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

don't repeat checks in both branches of an if-else, perform the common checks first. return false at everything that doesn't trigger, and only have a single setTargetPointer at the end before returning true

also it's simpler to declare ZoneChangeEvent zEvent = (ZoneChangeEvent) event so you only have to cast once


public PutCardIntoGraveFromHandLibraryAllTriggeredAbility(Zone zone, Effect effect, boolean optional, TargetController targetController, SetTargetPointer setTargetPointer) {
super(zone, effect, optional);
FilterCard filter = filterCard.copy();
Copy link
Contributor

Choose a reason for hiding this comment

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

FilterOwnedCard exists.

This is a custom class, so it should include the card name, and params should just be hardcoded.

@Sidorovich77 Sidorovich77 marked this pull request as draft September 15, 2024 11:59
@Sidorovich77 Sidorovich77 marked this pull request as ready for review September 19, 2024 19:20

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.DESERT)).calculate(game, sourceAbility, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't wrap this in a custom class. Declare it as private static final DynamicValue xValue and likewise for the hint

@@ -0,0 +1 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these empty files


@Override
public boolean apply(Game game, Ability source) {
if (source.getControllerId() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the point of this null check?

}
}

class DesertWarfareReturnEffect extends OneShotEffect {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you actually need a custom class, won't ReturnFromGraveyardToBattlefieldTargetEffect suffice?

super(zone, effect, optional);
FilterOwnedCard filter = filterCard.copy();
this.setTargetPointer = setTargetPointer;
filter.add(targetController.getOwnerPredicate());
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no point in copying the filter and adding a redundant predicate


private final SetTargetPointer setTargetPointer;

public DesertWarfareTriggeredAbility(Zone zone, Effect effect, boolean optional, TargetController targetController, SetTargetPointer setTargetPointer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a custom class so hardcode all the params and remove the ones you don't need


protected DesertWarfareTriggeredAbility(final DesertWarfareTriggeredAbility ability) {
super(ability);
filterCard = filterCard.copy();
Copy link
Contributor

Choose a reason for hiding this comment

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

don't copy static member (it should be final anyway)

switch (event.getType()) {
case SACRIFICED_PERMANENT:
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || !permanent.hasSubtype(SubType.DESERT, game)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you're missing playerid check

@Sidorovich77 Sidorovich77 marked this pull request as draft September 30, 2024 05:18
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.

2 participants