mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Use VAssignGenericAmount dialog to assign mana combo
This commit is contained in:
@@ -207,7 +207,7 @@ public class NetGuiGame extends AbstractGuiGame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<GameEntityView, Integer> assignGenericAmount(final CardView effectSource, final Map<GameEntityView, Integer> targets, final int amount, final boolean atLeastOne, final String amountLabel) {
|
||||
public Map<Object, Integer> assignGenericAmount(final CardView effectSource, final Map<Object, Integer> targets, final int amount, final boolean atLeastOne, final String amountLabel) {
|
||||
return sendAndWait(ProtocolMethod.divideShield, effectSource, targets, amount, atLeastOne, amountLabel);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@ public interface IGuiGame {
|
||||
void setPanelSelection(CardView hostCard);
|
||||
SpellAbilityView getAbilityToPlay(CardView hostCard, List<SpellAbilityView> abilities, ITriggerEvent triggerEvent);
|
||||
Map<CardView, Integer> assignCombatDamage(CardView attacker, List<CardView> blockers, int damage, GameEntityView defender, boolean overrideOrder);
|
||||
Map<GameEntityView, Integer> assignGenericAmount(CardView effectSource, Map<GameEntityView, Integer> target, int amount, final boolean atLeastOne, final String amountLabel);
|
||||
// The Object passed should be GameEntityView for most case. Can be Byte for "generate mana of any combination" effect
|
||||
Map<Object, Integer> assignGenericAmount(CardView effectSource, Map<Object, Integer> target, int amount, final boolean atLeastOne, final String amountLabel);
|
||||
|
||||
void message(String message);
|
||||
void message(String message, String title);
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -394,11 +396,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
@Override
|
||||
public Map<GameEntity, Integer> divideShield(Card effectSource, Map<GameEntity, Integer> affected, int shieldAmount) {
|
||||
final CardView vSource = CardView.get(effectSource);
|
||||
final Map<GameEntityView, Integer> vAffected = new HashMap<>(affected.size());
|
||||
final Map<Object, Integer> vAffected = new HashMap<>(affected.size());
|
||||
for (Map.Entry<GameEntity, Integer> e : affected.entrySet()) {
|
||||
vAffected.put(GameEntityView.get(e.getKey()), e.getValue());
|
||||
}
|
||||
final Map<GameEntityView, Integer> vResult = getGui().assignGenericAmount(vSource, vAffected, shieldAmount, false,
|
||||
final Map<Object, Integer> vResult = getGui().assignGenericAmount(vSource, vAffected, shieldAmount, false,
|
||||
localizer.getMessage("lblShield"));
|
||||
Map<GameEntity, Integer> result = new HashMap<>(vResult.size());
|
||||
for (Map.Entry<GameEntity, Integer> e : affected.entrySet()) {
|
||||
@@ -409,6 +411,28 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Byte, Integer> specifyManaCombo(SpellAbility sa, ColorSet colorSet, int manaAmount, boolean different) {
|
||||
final CardView vSource = CardView.get(sa.getHostCard());
|
||||
final Map<Object, Integer> vAffected = new LinkedHashMap<>(manaAmount);
|
||||
Integer maxAmount = different ? 1 : manaAmount;
|
||||
Iterator<Byte> it = colorSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
vAffected.put(it.next(), maxAmount);
|
||||
}
|
||||
final Map<Object, Integer> vResult = getGui().assignGenericAmount(vSource, vAffected, manaAmount, false,
|
||||
localizer.getMessage("lblMana").toLowerCase());
|
||||
Map<Byte, Integer> result = new HashMap<>(vResult.size());
|
||||
it = colorSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
Byte color = it.next();
|
||||
if (vResult.containsKey(color)) {
|
||||
result.put(color, vResult.get(color));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer announceRequirements(final SpellAbility ability, final String announce) {
|
||||
int max = Integer.MAX_VALUE;
|
||||
@@ -1974,11 +1998,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
}
|
||||
label = localizer.getMessage(label).toLowerCase();
|
||||
final CardView vSource = CardView.get(currentAbility.getHostCard());
|
||||
final Map<GameEntityView, Integer> vTargets = new HashMap<>(targets.size());
|
||||
final Map<Object, Integer> vTargets = new HashMap<>(targets.size());
|
||||
for (GameEntity e : targets) {
|
||||
vTargets.put(GameEntityView.get(e), amount);
|
||||
}
|
||||
final Map<GameEntityView, Integer> vResult = getGui().assignGenericAmount(vSource, vTargets, amount, true, label);
|
||||
final Map<Object, Integer> vResult = getGui().assignGenericAmount(vSource, vTargets, amount, true, label);
|
||||
for (GameEntity e : targets) {
|
||||
currentAbility.addDividedAllocation(e, vResult.get(GameEntityView.get(e)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user