mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Merge branch 'master' into Attractions
# Conflicts: # forge-core/src/main/java/forge/deck/DeckFormat.java
This commit is contained in:
@@ -1,17 +1,7 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
@@ -38,6 +28,14 @@ import forge.screens.deckeditor.views.VStatistics;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.util.Localizer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controls the draft submenu in the home UI.
|
||||
*
|
||||
@@ -142,6 +140,12 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
|
||||
FModel.getGauntletMini().resetGauntletDraft();
|
||||
String duelType = (String)VSubmenuDraft.SINGLETON_INSTANCE.getCbOpponent().getSelectedItem();
|
||||
|
||||
if (duelType == null) {
|
||||
FOptionPane.showErrorDialog("Please select duel types for the draft match.", "Missing opponent items");
|
||||
return;
|
||||
}
|
||||
|
||||
final DeckGroup opponentDecks = FModel.getDecks().getDraft().get(humanDeck.getName());
|
||||
if (gauntlet) {
|
||||
if ("Gauntlet".equals(duelType)) {
|
||||
@@ -161,7 +165,7 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
List<Deck> aiDecks = Lists.newArrayList();
|
||||
Map<Integer, Deck> aiMap = Maps.newHashMap();
|
||||
if (VSubmenuDraft.SINGLETON_INSTANCE.isSingleSelected()) {
|
||||
// Restore Zero Indexing
|
||||
final int aiIndex = Integer.parseInt(duelType)-1;
|
||||
@@ -169,28 +173,43 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
if (aiDeck == null) {
|
||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||
}
|
||||
aiDecks.add(aiDeck);
|
||||
|
||||
aiMap.put(aiIndex, aiDeck);
|
||||
} else {
|
||||
final int numOpponents = Integer.parseInt(duelType);
|
||||
|
||||
List<Deck> randomOpponents = Lists.newArrayList(opponentDecks.getAiDecks());
|
||||
Collections.shuffle(randomOpponents);
|
||||
aiDecks = randomOpponents.subList(0, numOpponents);
|
||||
for(Deck d : aiDecks) {
|
||||
if (d == null) {
|
||||
int maxDecks = opponentDecks.getAiDecks().size();
|
||||
if (numOpponents > maxDecks) {
|
||||
throw new IllegalStateException("Draft: Not enough decks for the number of opponents!");
|
||||
}
|
||||
|
||||
List<Integer> aiIndices = Lists.newArrayList();
|
||||
for(int i = 0; i < maxDecks; i++) {
|
||||
aiIndices.add(i);
|
||||
}
|
||||
Collections.shuffle(aiIndices);
|
||||
aiIndices = aiIndices.subList(0, numOpponents);
|
||||
|
||||
for(int i : aiIndices) {
|
||||
final Deck aiDeck = opponentDecks.getAiDecks().get(i);
|
||||
if (aiDeck == null) {
|
||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||
}
|
||||
|
||||
aiMap.put(i + 1, aiDeck);
|
||||
}
|
||||
}
|
||||
|
||||
final List<RegisteredPlayer> starter = new ArrayList<>();
|
||||
// Human is 0
|
||||
final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
for(Deck aiDeck : aiDecks) {
|
||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
}
|
||||
for (final RegisteredPlayer pl : starter) {
|
||||
pl.assignConspiracies();
|
||||
human.setId(0);
|
||||
for(Map.Entry<Integer, Deck> aiDeck : aiMap.entrySet()) {
|
||||
RegisteredPlayer aiPlayer = new RegisteredPlayer(aiDeck.getValue()).setPlayer(GamePlayerUtil.createAiPlayer());
|
||||
aiPlayer.setId(aiDeck.getKey());
|
||||
starter.add(aiPlayer);
|
||||
aiPlayer.assignConspiracies();
|
||||
}
|
||||
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
|
||||
@@ -94,10 +94,12 @@ public class CardFaceSymbols {
|
||||
//ability icons
|
||||
MANA_IMAGES.put("commander", FSkin.getImage(FSkinProp.IMG_ABILITY_COMMANDER));
|
||||
MANA_IMAGES.put("ringbearer", FSkin.getImage(FSkinProp.IMG_ABILITY_RINGBEARER));
|
||||
MANA_IMAGES.put("annihilator", FSkin.getImage(FSkinProp.IMG_ABILITY_ANNIHILATOR));
|
||||
MANA_IMAGES.put("toxic", FSkin.getImage(FSkinProp.IMG_ABILITY_TOXIC));
|
||||
MANA_IMAGES.put("deathtouch", FSkin.getImage(FSkinProp.IMG_ABILITY_DEATHTOUCH));
|
||||
MANA_IMAGES.put("defender", FSkin.getImage(FSkinProp.IMG_ABILITY_DEFENDER));
|
||||
MANA_IMAGES.put("doublestrike", FSkin.getImage(FSkinProp.IMG_ABILITY_DOUBLE_STRIKE));
|
||||
MANA_IMAGES.put("exalted", FSkin.getImage(FSkinProp.IMG_ABILITY_EXALTED));
|
||||
MANA_IMAGES.put("firststrike", FSkin.getImage(FSkinProp.IMG_ABILITY_FIRST_STRIKE));
|
||||
MANA_IMAGES.put("fear", FSkin.getImage(FSkinProp.IMG_ABILITY_FEAR));
|
||||
MANA_IMAGES.put("flash", FSkin.getImage(FSkinProp.IMG_ABILITY_FLASH));
|
||||
|
||||
@@ -575,6 +575,14 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
CardFaceSymbols.drawAbilitySymbol("firststrike", g, abiX, abiY, abiScale, abiScale);
|
||||
abiY += abiSpace;
|
||||
}
|
||||
if (card.getCurrentState().hasAnnihilator()) {
|
||||
CardFaceSymbols.drawAbilitySymbol("annihilator", g, abiX, abiY, abiScale, abiScale);
|
||||
abiY += abiSpace;
|
||||
}
|
||||
if (card.getCurrentState().hasExalted()) {
|
||||
CardFaceSymbols.drawAbilitySymbol("exalted", g, abiX, abiY, abiScale, abiScale);
|
||||
abiY += abiSpace;
|
||||
}
|
||||
if (card.getCurrentState().hasDeathtouch()) {
|
||||
CardFaceSymbols.drawAbilitySymbol("deathtouch", g, abiX, abiY, abiScale, abiScale);
|
||||
abiY += abiSpace;
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
public class BoosterDraftTest implements IBoosterDraft {
|
||||
|
||||
private int n = 3;
|
||||
private int round = 1;
|
||||
|
||||
@Override
|
||||
@Test(timeOut = 1000)
|
||||
@@ -43,6 +44,11 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRound() {
|
||||
return round;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardPool nextChoice() {
|
||||
this.n--;
|
||||
@@ -95,4 +101,9 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
public LimitedPlayer getNeighbor(LimitedPlayer p, boolean left) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitedPlayer getPlayer(int i) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user