-
Notifications
You must be signed in to change notification settings - Fork 834
WIP - Rework/continuous effects apply logic #13689
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
Open
Jmlundeen
wants to merge
39
commits into
master
Choose a base branch
from
rework/continuous-effects-layers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b7e1f3a
ContinuousEffects: Update timestamping
Jmlundeen 083bb47
ContinuousEffects: Refactor apply and add dependency checking logic
Jmlundeen e3d147e
ContinuousEffect: Add methods for dynamic dependency checks
Jmlundeen 9dd2656
GameImpl: add null check on playerList when trying to restore state i…
Jmlundeen 1f89cb2
MageObjectReference: Add method to return generic MageObject
Jmlundeen c4508e7
Dependency: Add jgrapht to determine continuous effect dependency cycles
Jmlundeen 7bd2100
Update March of the Machines, Humility, Mycosynth Lattice and their l…
Jmlundeen 8a35b7a
Update Blood Moon, (Urborg) AddBasicLandTypeAllLandsEffect and their …
Jmlundeen 5411166
Update Necrotic Ooze and yixlid Jailer
Jmlundeen a564176
Move TODO for calculateResult to method
Jmlundeen a565c93
Revert dependency changes
Jmlundeen 48b9a6b
Merge branch 'master' into rework/continuous-effects-layers
Jmlundeen 7cc245c
ContinuousEffects: Add queryAffectedObjects and applyToObjects methods
Jmlundeen f679b87
refactor common effects
Jmlundeen c5baa4a
refactor more common effects
Jmlundeen 0d7246a
refactor more common effects
Jmlundeen 0e6661c
refactor more common effects
Jmlundeen 36fd6d2
refactor more common effects
Jmlundeen 02d1d27
refactor more common effects
Jmlundeen a8b0c8d
ContinuousEffect: Update query and apply to use List<MageItem> since …
Jmlundeen efd717b
refactor more common effects
Jmlundeen bb37304
refactor more common effects
Jmlundeen 34b0e5f
Merge branch 'master' into rework/continuous-effects-layers
Jmlundeen 3d30999
Revert incorrect changes
Jmlundeen 38c0a08
Update continuous effects with applyToObjects and queryAffectedObjects
Jmlundeen b6112e7
Refactor some continuous effects
Jmlundeen 99673c7
Add test for EnduringGlimmerTriggeredAbility
Jmlundeen 59012a8
fix affectedObjectsMap checking for single layer effects
Jmlundeen 26aa703
fix ConditionalContinuousEffect to correctly clear affectedObjectMap …
Jmlundeen 19f22f1
Refactor some more effects
Jmlundeen 1487559
Fix affectedObjectMap wrongly assigning instead of adding keys/values…
Jmlundeen 6851dc1
Merge branch 'refs/heads/master' into rework/continuous-effects-layers
Jmlundeen 09af4b6
Readjust query+applyTo logic
Jmlundeen bc2db46
Refactor more effects
Jmlundeen 3eb9d24
Refactor more effects
Jmlundeen 102c18d
A little more refactoring
Jmlundeen 0c7df6f
I "C" more refactors ahead
Jmlundeen e64a10b
Merge branch 'master' into rework/continuous-effects-layers
Jmlundeen 64401be
"D"on't stop refactoring
Jmlundeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...Tests/src/test/java/org/mage/test/cards/triggers/EnduringGlimmerTriggeredAbilityTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.mage.test.cards.triggers; | ||
|
||
import mage.abilities.keyword.HasteAbility; | ||
import mage.constants.CardType; | ||
import mage.constants.PhaseStep; | ||
import mage.constants.Zone; | ||
import org.junit.Test; | ||
import org.mage.test.serverside.base.CardTestPlayerBase; | ||
|
||
public class EnduringGlimmerTriggeredAbilityTest extends CardTestPlayerBase { | ||
// Enchantment Creature - Dog Glimmer - 3/3 | ||
// Whenever another creature you control enters, it gets +2/+0 and gains haste until end of turn. | ||
// When Enduring Courage dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment. | ||
static String courage = "Enduring Courage"; | ||
// Deal 3 damage to any target | ||
static String bolt = "Lightning Bolt"; | ||
// Creature - Bear - 2/2 | ||
static String cub = "Bear Cub"; | ||
|
||
@Test | ||
public void testEnduringCourage() { | ||
setStrictChooseMode(true); | ||
|
||
addCard(Zone.BATTLEFIELD, playerA, courage); | ||
addCard(Zone.HAND, playerA, bolt); | ||
addCard(Zone.HAND, playerA, cub); | ||
addCard(Zone.BATTLEFIELD, playerA, "Taiga", 3); | ||
|
||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, cub); | ||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); | ||
|
||
checkAbility("Bear Cub has haste", 1, PhaseStep.PRECOMBAT_MAIN, playerA, cub, HasteAbility.class, true); | ||
checkPT("Bear Cub has +2/+0", 1, PhaseStep.PRECOMBAT_MAIN, playerA, cub, 2 + 2, 2); | ||
|
||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, courage); | ||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); | ||
|
||
checkType("Courage is just an enchantment",1, PhaseStep.PRECOMBAT_MAIN, playerA, courage, CardType.CREATURE, false); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
execute(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If you call
queryAffectedObjects
then it must buildaffectedObjectMap
every time from scratch. If you catch performance issue or duplication bugs -- then it's the problem of caller code, notqueryAffectedObjects
.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 see what you mean, I think I will remove the map from ContinuousEffectImpl. I don't think it will be used outside of apply and dependency checking later. I think in that case it could be changed back to a list of objects. Unless you think it would still benefit from being a map?
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.
If you don't need it in existing effects then do not add -- use simple List and cycle code.
P.S. I recommend to view improved approach -- create objects list outside and pass it to query method. So real effects must simply fill it without create/clean code in each effect.
Possible code -- I don't build it, just an idea -- make empty apply method (2 params) in


ContinuousEffectImpl
and insert query code in main apply method (4 params). So It must keep workable all old effects, but allow to migrate to new query logic for new/modified effects (you must remove apply method from effect and replace it by query and applyToObject methods).