Skip to content

Commit

Permalink
specific enemy selection updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kdoub4 committed May 7, 2018
1 parent 4a7322f commit 17847a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion vDom/src/main/java/com/vdom/comms/SelectCardOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public enum PickType {

public String header = null;
public ArrayList<Integer> allowedCards = new ArrayList<Integer>();
public ArrayList<Boolean> allowedEnemy = null;

//public SelectCardOptions setType(SelectType s) {selectType = s; return this;}
public SelectCardOptions setHeader(String s) {header = s; return this;}
Expand All @@ -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;}
Expand Down
4 changes: 4 additions & 0 deletions vDom/src/main/java/com/vdom/core/IndirectPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 17847a5

Please sign in to comment.