mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Added replacement of {this} and{source} for selection of replacement effect order.
This commit is contained in:
parent
27c96d7ea9
commit
32dff5ae72
5 changed files with 23 additions and 8 deletions
|
@ -1244,7 +1244,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int chooseEffect(List<ReplacementEffect> rEffects, Game game) {
|
public int chooseEffect(List<String> rEffects, Game game) {
|
||||||
log.debug("chooseEffect");
|
log.debug("chooseEffect");
|
||||||
//TODO: implement this
|
//TODO: implement this
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -374,7 +374,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int chooseEffect(List<ReplacementEffect> rEffects, Game game) {
|
public int chooseEffect(List<String> rEffects, Game game) {
|
||||||
if (this.isHuman())
|
if (this.isHuman())
|
||||||
return rnd.nextInt(rEffects.size());
|
return rnd.nextInt(rEffects.size());
|
||||||
return super.chooseEffect(rEffects, game);
|
return super.chooseEffect(rEffects, game);
|
||||||
|
|
|
@ -155,12 +155,12 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int chooseEffect(List<ReplacementEffect> rEffects, Game game) {
|
public int chooseEffect(List<String> rEffects, Game game) {
|
||||||
updateGameStatePriority("chooseEffect", game);
|
updateGameStatePriority("chooseEffect", game);
|
||||||
replacementEffectChoice.getChoices().clear();
|
replacementEffectChoice.getChoices().clear();
|
||||||
int count = 1;
|
int count = 1;
|
||||||
for (ReplacementEffect effect: rEffects) {
|
for (String effectText: rEffects) {
|
||||||
replacementEffectChoice.getChoices().add(count + ". " + effect.getText(null));
|
replacementEffectChoice.getChoices().add(count + ". " + effectText);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (replacementEffectChoice.getChoices().size() == 1)
|
if (replacementEffectChoice.getChoices().size() == 1)
|
||||||
|
@ -173,7 +173,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
replacementEffectChoice.setChoice(response.getString());
|
replacementEffectChoice.setChoice(response.getString());
|
||||||
count = 1;
|
count = 1;
|
||||||
for (int i = 0; i < rEffects.size(); i++) {
|
for (int i = 0; i < rEffects.size(); i++) {
|
||||||
if (replacementEffectChoice.getChoice().equals(count + ". " + rEffects.get(i).getText(null)))
|
if (replacementEffectChoice.getChoice().equals(count + ". " + rEffects.get(i)))
|
||||||
return i;
|
return i;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.Constants.AsThoughEffectType;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.Constants.Layer;
|
import mage.Constants.Layer;
|
||||||
import mage.Constants.SubLayer;
|
import mage.Constants.SubLayer;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.StaticAbility;
|
import mage.abilities.StaticAbility;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -376,7 +377,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
else {
|
else {
|
||||||
//20100716 - 616.1c
|
//20100716 - 616.1c
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
Player player = game.getPlayer(event.getPlayerId());
|
||||||
index = player.chooseEffect(rEffects, game);
|
index = player.chooseEffect(getReplacementEffectsTexts(rEffects, game), game);
|
||||||
}
|
}
|
||||||
ReplacementEffect rEffect = rEffects.get(index);
|
ReplacementEffect rEffect = rEffects.get(index);
|
||||||
caught = rEffect.replaceEvent(event, this.getAbility(rEffect.getId()), game);
|
caught = rEffect.replaceEvent(event, this.getAbility(rEffect.getId()), game);
|
||||||
|
@ -541,6 +542,20 @@ public class ContinuousEffects implements Serializable {
|
||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getReplacementEffectsTexts(List<ReplacementEffect> rEffects, Game game) {
|
||||||
|
List<String> texts = new ArrayList<String>();
|
||||||
|
for (ReplacementEffect effect: rEffects) {
|
||||||
|
Ability ability = replacementEffects.getAbility(effect.getId());
|
||||||
|
MageObject object = game.getObject(ability.getSourceId());
|
||||||
|
if (object != null) {
|
||||||
|
texts.add(ability.getRule(object.getName()));
|
||||||
|
} else {
|
||||||
|
texts.add(effect.getText(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return texts;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class TimestampSorter implements Comparator<ContinuousEffect> {
|
class TimestampSorter implements Comparator<ContinuousEffect> {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -231,7 +231,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
// set the value for X spells and abilities
|
// set the value for X spells and abilities
|
||||||
int announceXMana(int min, int max, String message, Game game, Ability ability);
|
int announceXMana(int min, int max, String message, Game game, Ability ability);
|
||||||
|
|
||||||
int chooseEffect(List<ReplacementEffect> rEffects, Game game);
|
int chooseEffect(List<String> rEffects, Game game);
|
||||||
TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game);
|
TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game);
|
||||||
Mode chooseMode(Modes modes, Ability source, Game game);
|
Mode chooseMode(Modes modes, Ability source, Game game);
|
||||||
void selectAttackers(Game game, UUID attackingPlayerId);
|
void selectAttackers(Game game, UUID attackingPlayerId);
|
||||||
|
|
Loading…
Reference in a new issue