diff --git a/bulwarkMain/src/main/java/fm/fastmail/truesteel/bulwark/ui/GameTable.java b/bulwarkMain/src/main/java/fm/fastmail/truesteel/bulwark/ui/GameTable.java index 2d92aaf..001b280 100644 --- a/bulwarkMain/src/main/java/fm/fastmail/truesteel/bulwark/ui/GameTable.java +++ b/bulwarkMain/src/main/java/fm/fastmail/truesteel/bulwark/ui/GameTable.java @@ -526,9 +526,10 @@ private void cannotSelect() { * Is the given card an acceptable choice given the constrains saved in sco? * @param c chosen card * @param parent which pile the card was selected from + * @param position * @return */ - boolean isAcceptable(CardState cs, CardGroup parent) { + boolean isAcceptable(CardState cs, CardGroup parent, int position) { MyCard c = cs.c; if (cs.shade) return false; if (sco.fromHand && (parent != hand)) return false; @@ -552,8 +553,19 @@ else if (sco.fromTable) { } } else if (sco.fromPrizes) { if (parent != prizePile) return false; - } + } else if (sco.fromBlackMarket) { + if (parent != blackMarket) { + return false; + } + if (sco.isAttackPhase) { + if (sco.allowedEnemy == null) { + return false; + } else { + return sco.allowedEnemy.get(position); + } + } + } return sco.checkValid(c, cs.getCost()); } @@ -627,7 +639,7 @@ public void cardSelected(Button b) { int[] cards = new int[openedCards.size()]; for (int i = 0; i < openedCards.size(); i++) { CardInfo ci = openedCards.get(i); - if (!isAcceptable(ci.cs, ci.parent)) + if (!isAcceptable(ci.cs, ci.parent,ci.pos)) return; if (this.eventType == EventType.AttackingFoe || this.eventType == EventType.SelectFoe) cards[i] = ci.pos; @@ -1349,7 +1361,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) } } } else { - if (isAcceptable(clickedCard.getState(), clickedCard.parent)) { + if (isAcceptable(clickedCard.getState(), clickedCard.parent, position)) { HapticFeedback.vibrate(getContext(), AlertType.CLICK); if (sco.isDifferent() && hasDuplicate(openedCards, clickedCard.getState().c)) { int duplicateIndex = getFirstIndex(openedCards, clickedCard.getState().c); diff --git a/vDom/src/main/java/com/vdom/comms/SelectCardOptions.java b/vDom/src/main/java/com/vdom/comms/SelectCardOptions.java index f518549..6f37283 100644 --- a/vDom/src/main/java/com/vdom/comms/SelectCardOptions.java +++ b/vDom/src/main/java/com/vdom/comms/SelectCardOptions.java @@ -114,6 +114,7 @@ public enum PickType { public String header = null; public ArrayList allowedCards = new ArrayList(); + public ArrayList allowedEnemy = null; //public SelectCardOptions setType(SelectType s) {selectType = s; return this;} public SelectCardOptions setHeader(String s) {header = s; return this;} @@ -133,7 +134,9 @@ public enum PickType { public SelectCardOptions exactCount() {exactCount = true; return this;} public SelectCardOptions isAttackFoe() { - fromBlackMarket = true; isAttackPhase = true; this.pickType = PickType.ATTACK; return this;} + fromBlackMarket = true; isAttackPhase = true; this.pickType = PickType.ATTACK; + allowedEnemy = new ArrayList<>(); + return this;} public SelectCardOptions fromTable() {fromTable = true;isNonShelter=true;count=1;exactCount=true; return this;} public SelectCardOptions isBuy() {isBuyPhase= true; this.pickType = PickType.BUY; return this;} public SelectCardOptions isActionPhase() {isActionPhase=true; return this;} diff --git a/vDom/src/main/java/com/vdom/core/IndirectPlayer.java b/vDom/src/main/java/com/vdom/core/IndirectPlayer.java index ac6643b..04a4db2 100644 --- a/vDom/src/main/java/com/vdom/core/IndirectPlayer.java +++ b/vDom/src/main/java/com/vdom/core/IndirectPlayer.java @@ -192,6 +192,10 @@ private Card getFromBlackMarket(MoveContext context, SelectCardOptions sco) { if ( !card.isInvincible(enemyLine, context ) && sco.checkValid(card, card.getCost(context), false, context)) { sco.addValidCard(cardToInt(card)); + sco.allowedEnemy.add(true); + } + else { + sco.allowedEnemy.add(false); } } catch (IndexOutOfBoundsException e) {