Merge branch 'morePartner' of git.cardforge.org:core-developers/forge into morePartner

This commit is contained in:
Agetian
2018-06-09 14:35:42 +03:00
8 changed files with 81 additions and 2 deletions

View File

@@ -37,6 +37,8 @@ public class StaticData {
private Predicate<PaperCard> brawlPredicate;
private Predicate<PaperCard> modernPredicate;
private boolean filteredHandsEnabled = false;
// Loaded lazily:
private IStorage<SealedProduct.Template> boosters;
private IStorage<SealedProduct.Template> specialBoosters;
@@ -209,6 +211,14 @@ public class StaticData {
return brawlPredicate;
}
public void setFilteredHandsEnabled(boolean filteredHandsEnabled){
this.filteredHandsEnabled = filteredHandsEnabled;
}
public boolean getFilteredHandsEnabled(){
return filteredHandsEnabled;
}
public PaperCard getCardByEditionDate(PaperCard card, Date editionDate) {
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), editionDate, CardDb.SetPreference.LatestCoreExp, card.getArtIndex());

View File

@@ -20,6 +20,7 @@ package forge.game;
import com.google.common.base.Predicate;
import com.google.common.collect.*;
import forge.GameCommand;
import forge.StaticData;
import forge.card.CardStateName;
import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityUtils;
@@ -1562,6 +1563,53 @@ public class GameAction {
}
}
private void drawStartingHand(Player p1){
//check initial hand
List<Card> lib1 = Lists.newArrayList(p1.getZone(ZoneType.Library).getCards().threadSafeIterable());
List<Card> hand1 = lib1.subList(0,p1.getMaxHandSize());
System.out.println(hand1.toString());
//shuffle
List shuffledCards = Lists.newArrayList(p1.getZone(ZoneType.Library).getCards().threadSafeIterable());
Collections.shuffle(shuffledCards);
//check a second hand
List<Card> hand2 = shuffledCards.subList(0,p1.getMaxHandSize());
System.out.println(hand2.toString());
//choose better hand according to land count
float averageLandRatio = getLandRatio(lib1);
if(getHandScore(hand1, averageLandRatio)>getHandScore(hand2, averageLandRatio)){
p1.getZone(ZoneType.Library).setCards(shuffledCards);
}
p1.drawCards(p1.getMaxHandSize());
}
private float getLandRatio(List<Card> deck){
int landCount = 0;
for(Card c:deck){
if(c.isLand()){
landCount++;
}
}
if (landCount == 0 ){
return 0;
}
return new Float(landCount)/new Float(deck.size());
}
private float getHandScore(List<Card> hand, float landRatio){
int landCount = 0;
for(Card c:hand){
if(c.isLand()){
landCount++;
}
}
float averageCount = landRatio * hand.size();
return Math.abs(averageCount-landCount);
}
public void startGame(GameOutcome lastGameOutcome) {
startGame(lastGameOutcome, null);
}
@@ -1582,7 +1630,11 @@ public class GameAction {
game.setAge(GameStage.Mulligan);
for (final Player p1 : game.getPlayers()) {
p1.drawCards(p1.getMaxHandSize());
if (StaticData.instance().getFilteredHandsEnabled() ) {
drawStartingHand(p1);
} else {
p1.drawCards(p1.getStartingHandSize());
}
// If pl has Backup Plan as a Conspiracy draw that many extra hands

View File

@@ -101,6 +101,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbRandomArtInPools(), FPref.UI_RANDOM_ART_IN_POOLS));
lstControls.add(Pair.of(view.getCbEnforceDeckLegality(), FPref.ENFORCE_DECK_LEGALITY));
lstControls.add(Pair.of(view.getCbPerformanceMode(), FPref.PERFORMANCE_MODE));
lstControls.add(Pair.of(view.getCbFilteredHands(), FPref.FILTERED_HANDS));
lstControls.add(Pair.of(view.getCbCloneImgSource(), FPref.UI_CLONE_MODE_SOURCE));
lstControls.add(Pair.of(view.getCbRemoveSmall(), FPref.DECKGEN_NOSMALL));
lstControls.add(Pair.of(view.getCbCardBased(), FPref.DECKGEN_CARDBASED));

View File

@@ -69,6 +69,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbWorkshopSyntax = new OptionsCheckBox("Workshop Syntax Checker");
private final JCheckBox cbEnforceDeckLegality = new OptionsCheckBox("Deck Conformance");
private final JCheckBox cbPerformanceMode = new OptionsCheckBox("Performance Mode");
private final JCheckBox cbFilteredHands = new OptionsCheckBox("Filtered Hands");
private final JCheckBox cbImageFetcher = new OptionsCheckBox("Automatically Download Missing Card Art");
private final JCheckBox cbCloneImgSource = new OptionsCheckBox("Clones Use Original Card Art");
private final JCheckBox cbScaleLarger = new OptionsCheckBox("Scale Image Larger");
@@ -175,6 +176,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbPerformanceMode, titleConstraints);
pnlPrefs.add(new NoteLabel("Disables additional static abilities checks to speed up the game engine. (Warning: breaks some 'as if had flash' scenarios when casting cards owned by opponents)."), descriptionConstraints);
pnlPrefs.add(cbFilteredHands, titleConstraints);
pnlPrefs.add(new NoteLabel("Generates two starting hands and keeps the one with the closest to average land count for the deck. (Requires restart)"), descriptionConstraints);
pnlPrefs.add(cbCloneImgSource, titleConstraints);
pnlPrefs.add(new NoteLabel("When enabled clones will use their original art instead of the cloned card's art."), descriptionConstraints);
@@ -641,6 +645,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbPerformanceMode;
}
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbFilteredHands() {
return cbFilteredHands;
}
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbCloneImgSource() {
return cbCloneImgSource;

View File

@@ -117,6 +117,10 @@ public class SettingsPage extends TabPage<SettingsScreen> {
"Performance Mode",
"Disables additional static abilities checks to speed up the game engine. (Warning: breaks some 'as if had flash' scenarios when casting cards owned by opponents)."),
1);
lstSettings.addItem(new BooleanSetting(FPref.FILTERED_HANDS,
"Filtered Hands",
"Generates two starting hands and keeps the one with the closest to average land count for the deck. (Requires restart)"),
1);
lstSettings.addItem(new BooleanSetting(FPref.UI_CLONE_MODE_SOURCE,
"Clones Use Original Card Art",
"When enabled clones will use their original art instead of the cloned card's art."),

View File

@@ -225,7 +225,7 @@ Booster=10 Common, 3 Uncommon, 1 RareMythic:!fromSheet("BBD RareMythic"), 1 Basi
215 R Vigor
216 C Wandering Wolf
217 R Apocalypse Hydra
218 C Augur Spree
218 C Auger Spree
219 C Centaur Healer
220 U Dinrova Horror
221 U Enduring Scalelord

View File

@@ -173,6 +173,8 @@ public final class FModel {
magicDb.setBrawlPredicate(formats.get("Brawl").getFilterRules());
magicDb.setModernPredicate(formats.getModern().getFilterRules());
magicDb.setFilteredHandsEnabled(preferences.getPrefBoolean(FPref.FILTERED_HANDS));
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
questPreferences = new QuestPreferences();
conquestPreferences = new ConquestPreferences();

View File

@@ -154,6 +154,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
ENFORCE_DECK_LEGALITY ("true"),
PERFORMANCE_MODE ("false"),
FILTERED_HANDS ("false"),
DEV_MODE_ENABLED ("false"),
DEV_WORKSHOP_SYNTAX ("false"),