mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
[MH2] reworked Academy Manufactor to match ruling
This commit is contained in:
parent
4a09b2a1ed
commit
4fee736a1f
2 changed files with 53 additions and 55 deletions
|
@ -1,17 +1,15 @@
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.CreateTokenEvent;
|
import mage.game.events.CreateTokenEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
@ -20,8 +18,11 @@ import mage.game.permanent.token.FoodToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.game.permanent.token.TreasureToken;
|
import mage.game.permanent.token.TreasureToken;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author weirddan455
|
* @author weirddan455
|
||||||
*/
|
*/
|
||||||
public final class AcademyManufactor extends CardImpl {
|
public final class AcademyManufactor extends CardImpl {
|
||||||
|
@ -70,12 +71,14 @@ class AcademyManufactorEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event instanceof CreateTokenEvent && event.getPlayerId().equals(source.getControllerId())) {
|
if (!(event instanceof CreateTokenEvent) || !event.getPlayerId().equals(source.getControllerId())) {
|
||||||
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
|
return false;
|
||||||
for (Token token : tokenEvent.getTokens().keySet()) {
|
|
||||||
if (token instanceof ClueArtifactToken || token instanceof FoodToken || token instanceof TreasureToken) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
for (Token token : ((CreateTokenEvent) event).getTokens().keySet()) {
|
||||||
|
if (token.hasSubtype(SubType.CLUE, game)
|
||||||
|
|| token.hasSubtype(SubType.FOOD, game)
|
||||||
|
|| token.hasSubtype(SubType.TREASURE, game)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -83,51 +86,22 @@ class AcademyManufactorEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
if (event instanceof CreateTokenEvent) {
|
int amount = 0;
|
||||||
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
|
Map<Token, Integer> tokens = ((CreateTokenEvent) event).getTokens();
|
||||||
int clues = 0;
|
for (Iterator<Map.Entry<Token, Integer>> iter = tokens.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
int food = 0;
|
Map.Entry<Token, Integer> entry = iter.next();
|
||||||
int treasures = 0;
|
|
||||||
ClueArtifactToken clueToken = null;
|
|
||||||
FoodToken foodToken = null;
|
|
||||||
TreasureToken treasureToken = null;
|
|
||||||
Map<Token, Integer> tokens = tokenEvent.getTokens();
|
|
||||||
|
|
||||||
for (Map.Entry<Token, Integer> entry : tokens.entrySet()) {
|
|
||||||
Token token = entry.getKey();
|
Token token = entry.getKey();
|
||||||
int amount = entry.getValue();
|
if (token.hasSubtype(SubType.CLUE, game)
|
||||||
if (token instanceof ClueArtifactToken) {
|
|| token.hasSubtype(SubType.FOOD, game)
|
||||||
clueToken = (ClueArtifactToken) token;
|
|| token.hasSubtype(SubType.TREASURE, game)) {
|
||||||
clues += amount;
|
amount += entry.getValue();
|
||||||
}
|
iter.remove();
|
||||||
else if (token instanceof FoodToken) {
|
|
||||||
foodToken = (FoodToken) token;
|
|
||||||
food += amount;
|
|
||||||
}
|
|
||||||
else if (token instanceof TreasureToken) {
|
|
||||||
treasureToken = (TreasureToken) token;
|
|
||||||
treasures += amount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clueToken == null) {
|
tokens.put(new ClueArtifactToken(), amount);
|
||||||
clueToken = new ClueArtifactToken();
|
tokens.put(new FoodToken(), amount);
|
||||||
}
|
tokens.put(new TreasureToken(), amount);
|
||||||
if (foodToken == null) {
|
|
||||||
foodToken = new FoodToken();
|
|
||||||
}
|
|
||||||
if (treasureToken == null) {
|
|
||||||
treasureToken = new TreasureToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
int cluesToAdd = food + treasures;
|
|
||||||
int foodToAdd = clues + treasures;
|
|
||||||
int treasuresToAdd = clues + food;
|
|
||||||
|
|
||||||
tokens.put(clueToken, tokens.getOrDefault(clueToken, 0) + cluesToAdd);
|
|
||||||
tokens.put(foodToken, tokens.getOrDefault(foodToken, 0) + foodToAdd);
|
|
||||||
tokens.put(treasureToken, tokens.getOrDefault(treasureToken, 0) + treasuresToAdd);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,28 @@ public class AcademyManufactorTest extends CardTestPlayerBase {
|
||||||
// 8 permanents above + 500 token limit
|
// 8 permanents above + 500 token limit
|
||||||
assertPermanentCount(playerA, 508);
|
assertPermanentCount(playerA, 508);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGingerbruteToken() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Academy Manufactor", 2);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Tundra", 5);
|
||||||
|
addCard(Zone.HAND, playerA, "Fractured Identity");
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Gingerbrute");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fractured Identity", "Gingerbrute");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
assertPermanentCount(playerA, "Tundra", 5);
|
||||||
|
assertPermanentCount(playerA, "Academy Manufactor", 2);
|
||||||
|
// Gingerbrute token copy becomes a regular Food
|
||||||
|
assertPermanentCount(playerA, "Gingerbrute", 0);
|
||||||
|
assertPermanentCount(playerB, "Gingerbrute", 0);
|
||||||
|
assertPermanentCount(playerA, "Clue", 3);
|
||||||
|
assertPermanentCount(playerA, "Food", 3);
|
||||||
|
assertPermanentCount(playerA, "Treasure", 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue