mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- Attempt to fix blocker targeting arrows without breaking the combat log.
This commit is contained in:
@@ -244,7 +244,7 @@ public enum TargetingOverlay {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (final CardView attackingCard : combat.getAttackers()) {
|
for (final CardView attackingCard : combat.getAttackers()) {
|
||||||
final Iterable<CardView> cards = combat.getBlockers(attackingCard);
|
final Iterable<CardView> cards = combat.getPlannedBlockers(attackingCard);
|
||||||
if (cards == null) continue;
|
if (cards == null) continue;
|
||||||
for (final CardView blockingCard : cards) {
|
for (final CardView blockingCard : cards) {
|
||||||
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ public class CombatView {
|
|||||||
private Map<Iterable<CardView>, GameEntityView> bandsWithDefenders = Maps.newHashMap();
|
private Map<Iterable<CardView>, GameEntityView> bandsWithDefenders = Maps.newHashMap();
|
||||||
private Map<Iterable<CardView>, Iterable<CardView>> bandsWithBlockers = Maps.newHashMap();
|
private Map<Iterable<CardView>, Iterable<CardView>> bandsWithBlockers = Maps.newHashMap();
|
||||||
|
|
||||||
|
private Map<CardView, Iterable<CardView>> attackersWithPlannedBlockers = Maps.newHashMap();
|
||||||
|
private Map<Iterable<CardView>, Iterable<CardView>> bandsWithPlannedBlockers = Maps.newHashMap();
|
||||||
|
|
||||||
public CombatView() {
|
public CombatView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +71,15 @@ public class CombatView {
|
|||||||
return attackersWithBlockers.get(attacker);
|
return attackersWithBlockers.get(attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param attacker
|
||||||
|
* @return the blockers associated with an attacker, or {@code null} if the
|
||||||
|
* attacker is unblocked (planning stage, for targeting overlay).
|
||||||
|
*/
|
||||||
|
public Iterable<CardView> getPlannedBlockers(final CardView attacker) {
|
||||||
|
return attackersWithPlannedBlockers.get(attacker);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an {@link Iterable} of the blockers of the specified band, or
|
* Get an {@link Iterable} of the blockers of the specified band, or
|
||||||
* {@code null} if that band is unblocked.
|
* {@code null} if that band is unblocked.
|
||||||
@@ -80,6 +92,18 @@ public class CombatView {
|
|||||||
return bandsWithBlockers.get(attackingBand);
|
return bandsWithBlockers.get(attackingBand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an {@link Iterable} of the blockers of the specified band, or
|
||||||
|
* {@code null} if that band is unblocked (planning stage, for targeting overlay).
|
||||||
|
*
|
||||||
|
* @param attackingBand
|
||||||
|
* an {@link Iterable} representing an attacking band.
|
||||||
|
* @return an {@link Iterable} of {@link CardView} objects, or {@code null}.
|
||||||
|
*/
|
||||||
|
public Iterable<CardView> getPlannedBlockers(final Iterable<CardView> attackingBand) {
|
||||||
|
return bandsWithPlannedBlockers.get(attackingBand);
|
||||||
|
}
|
||||||
|
|
||||||
public Iterable<CardView> getAttackersOf(final GameEntityView defender) {
|
public Iterable<CardView> getAttackersOf(final GameEntityView defender) {
|
||||||
return Maps.filterValues(attackersWithDefenders, Predicates.equalTo(defender)).keySet();
|
return Maps.filterValues(attackersWithDefenders, Predicates.equalTo(defender)).keySet();
|
||||||
}
|
}
|
||||||
@@ -87,21 +111,29 @@ public class CombatView {
|
|||||||
return Maps.filterValues(bandsWithDefenders, Predicates.equalTo(defender)).keySet();
|
return Maps.filterValues(bandsWithDefenders, Predicates.equalTo(defender)).keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAttackingBand(final Iterable<CardView> attackingBand, final GameEntityView defender, final Iterable<CardView> blockers) {
|
public void addPlannedBlockers(final CardView attacker, final Iterable<CardView> blockers) {
|
||||||
final List<CardView> attackingBandCopy = Lists.newArrayList(attackingBand),
|
List<CardView> blockersCopy = null;
|
||||||
blockersCopy;
|
if (blockers != null) {
|
||||||
if (blockers == null) {
|
|
||||||
blockersCopy = null;
|
|
||||||
} else {
|
|
||||||
blockersCopy = Lists.newArrayList(blockers);
|
blockersCopy = Lists.newArrayList(blockers);
|
||||||
}
|
}
|
||||||
|
this.attackersWithPlannedBlockers.put(attacker, blockersCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAttackingBand(final Iterable<CardView> attackingBand, final GameEntityView defender, final Iterable<CardView> blockers, final Iterable<CardView> plannedBlockers) {
|
||||||
|
final List<CardView> attackingBandCopy = Lists.newArrayList(attackingBand),
|
||||||
|
blockersCopy, plannedBlockersCopy;
|
||||||
|
|
||||||
|
blockersCopy = blockers == null ? null : Lists.newArrayList(blockers);
|
||||||
|
plannedBlockersCopy = plannedBlockers == null ? null : Lists.newArrayList(plannedBlockers);
|
||||||
|
|
||||||
for (final CardView attacker : attackingBandCopy) {
|
for (final CardView attacker : attackingBandCopy) {
|
||||||
this.attackersWithDefenders.put(attacker, defender);
|
this.attackersWithDefenders.put(attacker, defender);
|
||||||
this.attackersWithBlockers.put(attacker, blockersCopy);
|
this.attackersWithBlockers.put(attacker, blockersCopy);
|
||||||
|
this.attackersWithPlannedBlockers.put(attacker, plannedBlockersCopy);
|
||||||
}
|
}
|
||||||
this.bandsWithDefenders.put(attackingBandCopy, defender);
|
this.bandsWithDefenders.put(attackingBandCopy, defender);
|
||||||
this.bandsWithBlockers.put(attackingBandCopy, blockersCopy);
|
this.bandsWithBlockers.put(attackingBandCopy, blockersCopy);
|
||||||
|
this.bandsWithPlannedBlockers.put(attackingBandCopy, plannedBlockersCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ public abstract class LocalGameView implements IGameView {
|
|||||||
combatView.addAttackingBand(
|
combatView.addAttackingBand(
|
||||||
getCardViews(b.getAttackers()),
|
getCardViews(b.getAttackers()),
|
||||||
getGameEntityView(defender),
|
getGameEntityView(defender),
|
||||||
blockers == null || !isBlocked ? null : getCardViews(blockers));
|
blockers == null || !isBlocked ? null : getCardViews(blockers),
|
||||||
|
blockers == null ? null : getCardViews(blockers));
|
||||||
}
|
}
|
||||||
return combatView;
|
return combatView;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user