use of mage.ObjectColor in project mage by magefree.
the class CagedSunEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color != null) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (perm.getColor(game).contains(color)) {
perm.addPower(1);
perm.addToughness(1);
}
}
}
}
return true;
}
use of mage.ObjectColor in project mage by magefree.
the class DiamondMareTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
if (spell != null && color != null && spell.getColor(game).shares(color)) {
return true;
}
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class SealOfTheGuildpactCostReductionEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
MageObject sourceObject = game.getObject(abilityToModify.getSourceId());
if (sourceObject != null) {
ObjectColor color1 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color1");
ObjectColor color2 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color2");
int amount = 0;
if (color1 != null && sourceObject.getColor(game).contains(color1)) {
amount++;
}
if (color2 != null && sourceObject.getColor(game).contains(color2)) {
amount++;
}
if (amount > 0) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
CardUtil.adjustCost(spellAbility, amount);
}
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class SphinxsTutelageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
int possibleIterations = targetPlayer.getLibrary().size() / 2;
int iteration = 0;
boolean colorShared;
do {
iteration++;
if (iteration > possibleIterations + 20) {
// 801.16. If the game somehow enters a "loop" of mandatory actions, repeating a sequence of events
// with no way to stop, the game is a draw for each player who controls an object that's involved in
// that loop, as well as for each player within the range of influence of any of those players. They
// leave the game. All remaining players continue to play the game.
game.setDraw(source.getControllerId());
return true;
}
colorShared = false;
List<Card> cards = targetPlayer.millCards(2, source, game).getCards(game).stream().filter(card -> !card.isLand(game)).collect(Collectors.toList());
if (cards.size() < 2) {
break;
}
for (int i = 0; i < cards.size(); i++) {
if (colorShared) {
break;
}
ObjectColor color1 = cards.get(i).getColor(game);
if (color1.isColorless()) {
continue;
}
for (int j = 0; j < cards.size(); j++) {
if (i >= j) {
continue;
}
ObjectColor color2 = cards.get(j).getColor(game);
if (color1.shares(color2)) {
colorShared = true;
break;
}
}
}
} while (colorShared);
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class CardInfo method getColor.
public ObjectColor getColor() {
ObjectColor color = new ObjectColor();
color.setBlack(black);
color.setBlue(blue);
color.setGreen(green);
color.setRed(red);
color.setWhite(white);
return color;
}
Aggregations