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

[MKM] Implement Expedited Inheritance #11791

Merged
merged 3 commits into from
Feb 22, 2024

Conversation

kzymaris
Copy link
Contributor

@kzymaris kzymaris commented Feb 15, 2024

Copy link
Member

@JayDi85 JayDi85 left a comment

Choose a reason for hiding this comment

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

Do not modify game engine without details description. See comments.

@@ -62,6 +62,8 @@ A Characteristic Defining Ability (CDA) is an ability that defines a characteris
// set to the turn number on your next turn.
private int effectStartingStepNum = 0; // Some continuous are waiting for the next step of a kind.
// Avoid miscancelling if the start step is of that kind.
private boolean useCustomController = false;
private UUID customControllerId;
Copy link
Member

@JayDi85 JayDi85 Feb 15, 2024

Choose a reason for hiding this comment

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

Smells bad. Do not modify game engine without reason/tests.

1

"Make card playable" code uses a defined playerId, so if you call makeCardPlayable with custom playerId then that playerId will be able to cast it, not source/ability controller:

shot_240215_091526
shot_240215_092205

So rewrite your code without game engine changes or make details examples and a detailed explanation (what you want to do, what you get without modification, what you get with modification).

2

method uses the ability's controller to calculate the duration

Use full method version instead -- it allows to customize duration and player:
shot_240215_092533

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if it's possible to implement this card fully without making a change to the game engine. The issue is that the code in ContinuousEffectImpl.java that calculates the duration for the effect always uses the controllerId of the effect's source:
getcontrollerId

This works fine for similar cards that allow other players to exile cards from the top of their libraries and play them for a certain duration, such as [[Rocco, Street Chef]] because in Rocco's case the duration is still dependent on the effect's controller (Until your next end step, each player may play the card they exiled this way).
With [[Expedited Inheritance]], the duration during which the card can be played depends not on the effect's controller, but the controller/owner of the exiled cards (They may play those cards until the end of their next turn).

I solved this by changing the setStartingControllerAndTurnNum call in ContinuousEffectImpl.java to conditionally use a dynamic startingController instead of always defaulting to source.getControllerId(). I'm curious if you have any thoughts on a better approach for this, or if it's possible to do without altering game engine code.
Either way, this is the only place where that new Id is used; the existing logic that determines which player is able to play the card still works are expected and is unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about creating your own effect that extends AsThoughEffectImpl with a custom duration and overrides isInactive? Then you could do the check yourself with the correct player ID. See EscapeToTheWildsMayPlayEffect, for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip, I've made those changes.
I'm guessing the build test failure is unrelated to these changes as it seems to be affecting other PRs as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, don't worry about the travis build, I'll go through PRs once the test failure on master is addressed

Copy link
Contributor

@xenohedron xenohedron left a comment

Choose a reason for hiding this comment

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

Yes, the isInactive() override is a much better approach. Minor nit, looks fine otherwise

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
UUID objectIdToCast = CardUtil.getMainCardId(game, sourceId);
return cardOwnerId == affectedControllerId
Copy link
Contributor

Choose a reason for hiding this comment

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

compare UUID with equals

UUID playerId = creature.getControllerId();
Player player = game.getPlayer(playerId);
String message = impulseDrawAmount > 1 ?
"Exile " + impulseDrawAmount + " cards from the top of your library. Until the end of your next turn, you may play those cards."
Copy link
Contributor

Choose a reason for hiding this comment

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

(can use CardUtil.numberToText for message, not required)

Copy link
Contributor

@xenohedron xenohedron left a comment

Choose a reason for hiding this comment

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

thanks for the contribution

@xenohedron xenohedron merged commit 540ee3c into magefree:master Feb 22, 2024
3 checks passed
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.

4 participants