mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Split cards improves:
* Fixed that fused spells can't be played from non hand zone; * Fixed double choose spell dialog (#5506, #6549);
This commit is contained in:
parent
6b5108770c
commit
63dbf5f40b
9 changed files with 1 additions and 190 deletions
|
@ -1895,27 +1895,6 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
case SPLIT_AFTERMATH:
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game);
|
||||
if (useableAbilities != null && !useableAbilities.isEmpty()) {
|
||||
// game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values()));
|
||||
// TODO: Improve this
|
||||
return (SpellAbility) useableAbilities.values().iterator().next();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode chooseMode(Modes modes, Ability source, Game game) {
|
||||
log.debug("chooseMode");
|
||||
|
|
|
@ -1973,51 +1973,6 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
if (gameInCheckPlayableState(game)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: add canRespond cycle?
|
||||
if (!canRespond()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
case SPLIT_AFTERMATH:
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
String message = "Choose ability to cast" + (noMana ? " for FREE" : "") + "<br>" + object.getLogName();
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game);
|
||||
if (useableAbilities != null
|
||||
&& useableAbilities.size() == 1) {
|
||||
return (SpellAbility) useableAbilities.values().iterator().next();
|
||||
} else if (useableAbilities != null
|
||||
&& !useableAbilities.isEmpty()) {
|
||||
|
||||
updateGameStatePriority("chooseSpellAbilityForCast", game);
|
||||
prepareForResponse(game);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetChoiceEvent(playerId, message, object, new ArrayList<>(useableAbilities.values()));
|
||||
}
|
||||
waitForResponse(game);
|
||||
|
||||
if (response.getUUID() != null) {
|
||||
if (useableAbilities.containsKey(response.getUUID())) {
|
||||
return (SpellAbility) useableAbilities.get(response.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseAbilityForCast(Card card, Game game, boolean nonMana) {
|
||||
if (gameInCheckPlayableState(game)) {
|
||||
|
|
|
@ -29,39 +29,6 @@ public class TestComputerPlayer extends ComputerPlayer {
|
|||
this.testPlayerLink = testPlayerLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
||||
// workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear)
|
||||
// reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
case SPLIT_AFTERMATH:
|
||||
if (!this.testPlayerLink.getChoices().isEmpty()) {
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game);
|
||||
|
||||
// left, right or fused cast
|
||||
for (String choose : this.testPlayerLink.getChoices()) {
|
||||
for (ActivatedAbility activatedAbility : useableAbilities.values()) {
|
||||
if (activatedAbility instanceof SpellAbility) {
|
||||
if (((SpellAbility) activatedAbility).getCardName().equals(choose)) {
|
||||
return (SpellAbility) activatedAbility;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default implementation by AI
|
||||
return super.chooseSpellAbilityForCast(ability, game, noMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
|
|
@ -29,39 +29,6 @@ public class TestComputerPlayer7 extends ComputerPlayer7 {
|
|||
this.testPlayerLink = testPlayerLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
||||
// workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear)
|
||||
// reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
case SPLIT_AFTERMATH:
|
||||
if (!this.testPlayerLink.getChoices().isEmpty()) {
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game);
|
||||
|
||||
// left, right or fused cast
|
||||
for (String choose : this.testPlayerLink.getChoices()) {
|
||||
for (ActivatedAbility activatedAbility : useableAbilities.values()) {
|
||||
if (activatedAbility instanceof SpellAbility) {
|
||||
if (((SpellAbility) activatedAbility).getCardName().equals(choose)) {
|
||||
return (SpellAbility) activatedAbility;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default implementation by AI
|
||||
return super.chooseSpellAbilityForCast(ability, game, noMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
|
|
@ -29,39 +29,6 @@ public class TestComputerPlayerMonteCarlo extends ComputerPlayerMCTS {
|
|||
this.testPlayerLink = testPlayerLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
||||
// workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear)
|
||||
// reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
case SPLIT_AFTERMATH:
|
||||
if (!this.testPlayerLink.getChoices().isEmpty()) {
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
if (object != null) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game);
|
||||
|
||||
// left, right or fused cast
|
||||
for (String choose : this.testPlayerLink.getChoices()) {
|
||||
for (ActivatedAbility activatedAbility : useableAbilities.values()) {
|
||||
if (activatedAbility instanceof SpellAbility) {
|
||||
if (((SpellAbility) activatedAbility).getCardName().equals(choose)) {
|
||||
return (SpellAbility) activatedAbility;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default implementation by AI
|
||||
return super.chooseSpellAbilityForCast(ability, game, noMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
// copy-paste for TestComputerXXX
|
||||
|
|
|
@ -3456,12 +3456,6 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.cleanUpOnMatchEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
Assert.fail("That's method must calls only from computerPlayer->cast(), see TestComputerPlayerXXX");
|
||||
return computerPlayer.chooseSpellAbilityForCast(ability, game, noMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skip() {
|
||||
computerPlayer.skip();
|
||||
|
|
|
@ -543,11 +543,6 @@ public class PlayerStub implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putInHand(Card card, Game game) {
|
||||
return false;
|
||||
|
|
|
@ -317,8 +317,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean cast(SpellAbility ability, Game game, boolean noMana, MageObjectReference reference);
|
||||
|
||||
SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana);
|
||||
|
||||
SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana);
|
||||
|
||||
boolean putInHand(Card card, Game game);
|
||||
|
|
|
@ -1120,13 +1120,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
SpellAbility ability = originalAbility.copy();
|
||||
ability.setControllerId(getId());
|
||||
ability.setSourceObjectZoneChangeCounter(game.getState().getZoneChangeCounter(ability.getSourceId()));
|
||||
if (ability.getSpellAbilityType() != SpellAbilityType.BASE) {
|
||||
ability = chooseSpellAbilityForCast(ability, game, noMana);
|
||||
if (ability == null) {
|
||||
// No ability could be cast (selected), probably because of no valid targets (happens often if a card can be cast by an effect).
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//20091005 - 601.2a
|
||||
if (ability.getSourceId() == null) {
|
||||
logger.error("Ability without sourceId turn " + game.getTurnNum() + ". Ability: " + ability.getRule());
|
||||
|
@ -1189,11 +1183,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
return ability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playLand(Card card, Game game, boolean ignoreTiming) {
|
||||
// Check for alternate casting possibilities: e.g. land with Morph
|
||||
|
|
Loading…
Reference in a new issue