use of mage.game.permanent.token.KaldraToken in project mage by magefree.
the class HelmOfKaldraEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (new HelmOfKaldraCondition().apply(game, source)) {
CreateTokenEffect effect = new CreateTokenEffect(new KaldraToken());
effect.apply(game, source);
for (UUID tokenId : effect.getLastAddedTokenIds()) {
Permanent kaldra = game.getPermanent(tokenId);
if (kaldra != null) {
// Attach helm to the token
for (Permanent kaldrasHelm : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterHelm, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasHelm.getId(), source, game);
break;
}
// Attach shield to the token
for (Permanent kaldrasShield : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterShield, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasShield.getId(), source, game);
break;
}
// Attach sword to the token
for (Permanent kaldrasSword : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterSword, source.getControllerId(), game)) {
kaldra.addAttachment(kaldrasSword.getId(), source, game);
break;
}
}
return true;
}
}
return false;
}
Aggregations