mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Merge branch 'master' into 'master'
FlipOntoBattlefield: somewhat improve the chance to hit an attachment when targeting the card it's attached to. See merge request core-developers/forge!5672
This commit is contained in:
@@ -98,19 +98,24 @@ public class FlipOntoBattlefieldEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
private Card getNeighboringCard(Card c, int direction) {
|
||||
// Currently gets the nearest (in zone order) card to the left or to the right of the designated one by type
|
||||
// Currently gets the nearest (in zone order) card to the left or to the right of the designated one by type,
|
||||
// as well as cards attachments by the same controller that are visually located next to the requested card.
|
||||
Player controller = c.getController();
|
||||
ArrayList<Card> ownAttachments = Lists.newArrayList();
|
||||
ArrayList<Card> cardsOTB = Lists.newArrayList(CardLists.filter(
|
||||
controller.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
if (c.isCreature()) {
|
||||
if (card.isAttachedToEntity(c) && card.getController() == controller) {
|
||||
ownAttachments.add(card);
|
||||
return true;
|
||||
} else if (c.isCreature()) {
|
||||
return card.isCreature();
|
||||
} else if (c.isPlaneswalker() || c.isArtifact() || (c.isEnchantment() && !c.isAura())) {
|
||||
return card.isPlaneswalker() || card.isArtifact() || (c.isEnchantment() && !c.isAura());
|
||||
} else if (c.isLand()) {
|
||||
return card.isLand();
|
||||
} else if (c.isAttachedToEntity()) {
|
||||
} else if (c.isAttachedToEntity() && card.getController() == controller) {
|
||||
return card.isAttachedToEntity(c.getEntityAttachedTo()) || c.equals(card.getAttachedTo());
|
||||
}
|
||||
return card.sharesCardTypeWith(c);
|
||||
@@ -118,6 +123,12 @@ public class FlipOntoBattlefieldEffect extends SpellAbilityEffect {
|
||||
}
|
||||
));
|
||||
|
||||
// Chance to hit an attachment
|
||||
float hitAttachment = 0.50f;
|
||||
if (!ownAttachments.isEmpty() && direction < 0 && MyRandom.getRandom().nextFloat() <= hitAttachment) {
|
||||
return Aggregates.random(ownAttachments);
|
||||
}
|
||||
|
||||
int loc = cardsOTB.indexOf(c);
|
||||
if (direction < 0 && loc > 0) {
|
||||
return cardsOTB.get(loc - 1);
|
||||
|
||||
Reference in New Issue
Block a user