[Mobile] Auto select AI Enabled Decks randomly

- Auto select AI Enabled Decks (non generated decks) when the Player Panel is AI and at least more than 10 AI Decks is available randomly
This commit is contained in:
Anthony Calosa
2022-05-05 18:16:54 +08:00
committed by GitHub
parent 631ae3f9e5
commit 10af16aa1d

View File

@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import forge.util.MyRandom;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
@@ -195,7 +196,20 @@ public class FDeckChooser extends FScreen {
DeckgenUtil.randomSelect(lstDecks); DeckgenUtil.randomSelect(lstDecks);
} }
else { else {
DeckgenUtil.randomSelect(lstDecks); List<DeckProxy> AIDecks = new ArrayList<>();
int count = 0;
if (isAi) {
for (DeckProxy deckProxy : lstDecks.getPool().toFlatList()) {
if (deckProxy.getAI().inMainDeck == 0) {
AIDecks.add(deckProxy);
count++;
}
}
}
if (count > 10)
lstDecks.setSelectedItem(AIDecks.get(MyRandom.getRandom().nextInt(AIDecks.size())));
else
DeckgenUtil.randomSelect(lstDecks);
} }
accept(); accept();
} }