mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'multiplayer' into 'master'
multiplayer fixes for graveyard and stack targeting See merge request core-developers/forge!248
This commit is contained in:
@@ -20,7 +20,11 @@ public final class RemoteClient implements IToClient {
|
||||
@Override
|
||||
public void send(final NetEvent event) {
|
||||
System.out.println("Sending event " + event + " to " + channel);
|
||||
channel.writeAndFlush(event);
|
||||
try {
|
||||
channel.writeAndFlush(event).sync();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,9 +30,11 @@ import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -170,20 +173,20 @@ public class TargetSelection {
|
||||
// Send in a list of valid cards, and popup a choice box to target
|
||||
final Game game = ability.getActivatingPlayer().getGame();
|
||||
|
||||
final List<Card> crdsBattle = Lists.newArrayList();
|
||||
final List<Card> crdsExile = Lists.newArrayList();
|
||||
final List<Card> crdsGrave = Lists.newArrayList();
|
||||
final List<Card> crdsLibrary = Lists.newArrayList();
|
||||
final List<Card> crdsStack = Lists.newArrayList();
|
||||
final List<Card> crdsAnte = Lists.newArrayList();
|
||||
final List<CardView> crdsBattle = Lists.newArrayList();
|
||||
final List<CardView> crdsExile = Lists.newArrayList();
|
||||
final List<CardView> crdsGrave = Lists.newArrayList();
|
||||
final List<CardView> crdsLibrary = Lists.newArrayList();
|
||||
final List<CardView> crdsStack = Lists.newArrayList();
|
||||
final List<CardView> crdsAnte = Lists.newArrayList();
|
||||
for (final Card inZone : choices) {
|
||||
Zone zz = game.getZoneOf(inZone);
|
||||
if (zz.is(ZoneType.Battlefield)) crdsBattle.add(inZone);
|
||||
else if (zz.is(ZoneType.Exile)) crdsExile.add(inZone);
|
||||
else if (zz.is(ZoneType.Graveyard)) crdsGrave.add(inZone);
|
||||
else if (zz.is(ZoneType.Library)) crdsLibrary.add(inZone);
|
||||
else if (zz.is(ZoneType.Stack)) crdsStack.add(inZone);
|
||||
else if (zz.is(ZoneType.Ante)) crdsAnte.add(inZone);
|
||||
if (zz.is(ZoneType.Battlefield)) crdsBattle.add(CardView.get(inZone));
|
||||
else if (zz.is(ZoneType.Exile)) crdsExile.add(CardView.get(inZone));
|
||||
else if (zz.is(ZoneType.Graveyard)) crdsGrave.add(CardView.get(inZone));
|
||||
else if (zz.is(ZoneType.Library)) crdsLibrary.add(CardView.get(inZone));
|
||||
else if (zz.is(ZoneType.Stack)) crdsStack.add(CardView.get(inZone));
|
||||
else if (zz.is(ZoneType.Ante)) crdsAnte.add(CardView.get(inZone));
|
||||
}
|
||||
List<Object> choicesFiltered = new ArrayList<Object>();
|
||||
if (!crdsBattle.isEmpty()) {
|
||||
@@ -232,8 +235,8 @@ public class TargetSelection {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (chosen instanceof Card) {
|
||||
ability.getTargets().add((Card) chosen);
|
||||
if (chosen instanceof CardView) {
|
||||
ability.getTargets().add(game.getCard((CardView) chosen));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -243,6 +246,7 @@ public class TargetSelection {
|
||||
final String message = tgt.getVTSelection();
|
||||
// Find what's targetable, then allow human to choose
|
||||
final List<Object> selectOptions = new ArrayList<Object>();
|
||||
HashMap<StackItemView, SpellAbilityStackInstance> stackItemViewSpellAbilityHashMap = new HashMap<>();
|
||||
|
||||
final Game game = ability.getActivatingPlayer().getGame();
|
||||
for (final SpellAbilityStackInstance si : game.getStack()) {
|
||||
@@ -252,7 +256,8 @@ public class TargetSelection {
|
||||
ability.resetTargets();
|
||||
}
|
||||
else if (ability.canTargetSpellAbility(abilityOnStack)) {
|
||||
selectOptions.add(si);
|
||||
stackItemViewSpellAbilityHashMap.put(si.getView(), si);
|
||||
selectOptions.add(si.getView());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,8 +280,8 @@ public class TargetSelection {
|
||||
if (madeChoice == null) {
|
||||
return false;
|
||||
}
|
||||
if (madeChoice instanceof SpellAbilityStackInstance) {
|
||||
ability.getTargets().add(((SpellAbilityStackInstance)madeChoice).getSpellAbility(true));
|
||||
if (madeChoice instanceof StackItemView) {
|
||||
ability.getTargets().add(stackItemViewSpellAbilityHashMap.get(madeChoice).getSpellAbility(true));
|
||||
}
|
||||
else {// 'FINISH TARGETING' chosen
|
||||
bTargetingDone = true;
|
||||
|
||||
Reference in New Issue
Block a user