Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #637 : show cards for last and specified games #633

Open
wants to merge 1 commit into
base: Renaissance
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
GameType g = ((GameTypeItem) mPresetSpinner.getSelectedItem()).gameType;
CardSet cardSet = CardSet.getCardSetMap().get(g);
mGameCards.setText(Strings.format(R.string.card_set_cards, Strings.getCardSetDescription(cardSet)));
updateCards();
}

@Override
Expand Down Expand Up @@ -694,14 +692,26 @@ private void updateVisibility() {

int presetVisibility = mGameType == TypeOptions.PRESET ? View.VISIBLE : View.GONE;
mPresetSpinner.setVisibility(presetVisibility);
mGameCards.setVisibility(presetVisibility);

int cardsVisibility = mGameType == TypeOptions.RANDOM ? View.GONE : View.VISIBLE;
mGameCards.setVisibility(cardsVisibility);

int includeCardsVisibility = mGameType == TypeOptions.PRESET || mGameType == TypeOptions.RANDOM ? View.VISIBLE : View.GONE;
mPlatColonyLayout.setVisibility(includeCardsVisibility);
mSheltersLayout.setVisibility(includeCardsVisibility);

}

private void updateCards() {
if (mGameType == TypeOptions.PRESET) {
GameType g = ((GameTypeItem) mPresetSpinner.getSelectedItem()).gameType;
CardSet cardSet = CardSet.getCardSetMap().get(g);
mGameCards.setText(Strings.format(R.string.card_set_cards, Strings.getCardSetDescription(cardSet)));
} else if (mGameType == TypeOptions.LAST) {
mGameCards.setText(Strings.format(R.string.card_set_cards, Strings.getCardSetDescription(mLastCards)));
} else if (mGameType == TypeOptions.SPECIFIED) {
mGameCards.setText(Strings.format(R.string.card_set_cards, Strings.getCardSetDescription(mCardsPassOnStartup)));
}
}
private void updatePlayersVisibility() {
mRandomPlayersLayout.setVisibility(mRandomPlayersCheckbox.isChecked() ? View.VISIBLE : View.GONE);
for (LinearLayout layout : mPlayersLayout) {
Expand Down Expand Up @@ -1058,6 +1068,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mGameType = TypeOptions.SPECIFIED;
}
updateVisibility();
updateCards();
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions androminion/src/com/mehtank/androminion/ui/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,10 @@ public static String getGameTimeString(long duration) {
return time;
}

public static String getCardSetDescription(String[] list) {
return getCardSetDescription(CardSet.getCardSet(list));
}

public static String getCardSetDescription(CardSet cardSet) {
ArrayList<String> events = new ArrayList<String>();
ArrayList<String> projects = new ArrayList<String>();
Expand Down
129 changes: 129 additions & 0 deletions vdom/src/com/vdom/core/CardSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,136 @@ private CardSet(final List<Card> cards, final boolean isRandom) {
this.obelisk = null;
this.druidBoons = null;
}

private CardSet(String[] list) {
this.cards = new ArrayList<Card>();
this.baneCard = null;
this.isRandom = false;
this.usePlatColony = UseOptionalCards.Random;
this.useShelters = UseOptionalCards.Random;
this.obelisk = null;
this.druidBoons = null;

for(String cardName : list) {
Card card = null;
boolean bane = false;
boolean obelisk = false;

if(cardName.startsWith(Game.BANE)) {
bane = true;
cardName = cardName.substring(Game.BANE.length());
}
if(cardName.startsWith(Game.OBELISK)) {
obelisk = true;
cardName = cardName.substring(Game.OBELISK.length());
}
if(cardName.startsWith(Game.BLACKMARKET)) {
continue;
}
if (cardName.startsWith(Game.DRUID_BOON)) {
cardName = cardName.substring(Game.DRUID_BOON.length());
String s = cardName.replace("/", "").replace(" ", "").replace("'", "");
for (Card c : Cards.boonCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
if (card != null)
druidBoons.add(card.instantiate());
continue;
}
String s = cardName.replace("/", "").replace(" ", "");
for (Card c : Cards.actionCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
for (Card c : Cards.eventsCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
for (Card c : Cards.projectCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
for (Card c : Cards.landmarkCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
// Handle split pile / knights cards being passed in incorrectly
for (Card c : Cards.variablePileCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
for (Card c : Cards.castleCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
for (Card c : Cards.knightsCards) {
if(c.getSafeName().equalsIgnoreCase(s)) {
card = c;
break;
}
}
if (card != null && Cards.variablePileCardToRandomizer.containsKey(card)) {
card = Cards.variablePileCardToRandomizer.get(card);
}

if(card != null && bane) {
this.baneCard = card;
}
if(card != null && obelisk) {
this.obelisk = card;
}
if (cardName.equalsIgnoreCase("Knights")) {
card = Cards.virtualKnight;
}

if (card != null && !cards.contains(card)) {
cards.add(card);
} else if ( s.equalsIgnoreCase(Cards.curse.getSafeName()) ||
s.equalsIgnoreCase(Cards.estate.getSafeName()) ||
s.equalsIgnoreCase(Cards.duchy.getSafeName()) ||
s.equalsIgnoreCase(Cards.province.getSafeName()) ||
s.equalsIgnoreCase(Cards.copper.getSafeName()) ||
s.equalsIgnoreCase(Cards.silver.getSafeName()) ||
s.equalsIgnoreCase(Cards.potion.getSafeName()) ||
s.equalsIgnoreCase(Cards.gold.getSafeName()) ||
s.equalsIgnoreCase(Cards.diadem.getSafeName()) ||
s.equalsIgnoreCase(Cards.followers.getSafeName()) ||
s.equalsIgnoreCase(Cards.princess.getSafeName()) ||
s.equalsIgnoreCase(Cards.trustySteed.getSafeName()) ||
s.equalsIgnoreCase(Cards.bagOfGold.getSafeName()) ) {
// do nothing
} else if ( s.equalsIgnoreCase(Cards.platinum.getSafeName()) ||
s.equalsIgnoreCase(Cards.colony.getSafeName()) ) {
usePlatColony = UseOptionalCards.Use;
} else if (s.equalsIgnoreCase("Shelter") ||
s.equalsIgnoreCase("Shelters") ||
s.equalsIgnoreCase(Cards.hovel.getSafeName()) ||
s.equalsIgnoreCase(Cards.overgrownEstate.getSafeName()) ||
s.equalsIgnoreCase(Cards.necropolis.getSafeName()) ) {
useShelters = UseOptionalCards.Use;
}
}
}

public static CardSet getCardSet(String[] list) {
return new CardSet(list);
}

public static CardSet getCardSet(final GameType type, int count) {
return getCardSet(type, count, null, null, 0, ExpansionAllocation.Random, 0, 0, 0, false, false, false);
}
Expand Down