mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Support rendering path through regions based on opponents
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -17480,6 +17480,7 @@ forge-gui/src/main/java/forge/planarconquest/ConquestController.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestData.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestDataIO.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestDeckMap.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestOpponent.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestPlane.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestPlaneData.java -text
|
||||
forge-gui/src/main/java/forge/planarconquest/ConquestPreferences.java -text
|
||||
|
||||
@@ -13,6 +13,7 @@ import forge.card.CardRenderer;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestData;
|
||||
import forge.planarconquest.ConquestOpponent;
|
||||
import forge.planarconquest.ConquestPlane;
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
import forge.screens.FScreen;
|
||||
@@ -64,7 +65,7 @@ public class ConquestMapScreen extends FScreen {
|
||||
|
||||
public void update() {
|
||||
model = FModel.getConquest().getModel();
|
||||
setHeaderCaption(model.getCurrentPlane().getName() + " - Map");
|
||||
setHeaderCaption(model.getCurrentPlane().getName());
|
||||
|
||||
FCollectionView<Region> regions = model.getCurrentPlane().getRegions();
|
||||
lstRegions.clear();
|
||||
@@ -91,6 +92,7 @@ public class ConquestMapScreen extends FScreen {
|
||||
FSkinFont font, FSkinColor foreColor, FSkinColor backColor,
|
||||
boolean pressed, float x, float y, float w, float h) {
|
||||
|
||||
//draw background art
|
||||
FImage art = (FImage)region.getArt();
|
||||
if (art != null) {
|
||||
g.drawImage(art, x, y, w, h);
|
||||
@@ -111,6 +113,55 @@ public class ConquestMapScreen extends FScreen {
|
||||
g.fillGradientRect(color1, color2, false, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
//draw path with opponents
|
||||
float gridSize = h / rows;
|
||||
float iconSize = gridSize * 0.5f;
|
||||
float iconOffset = (gridSize - iconSize) / 2;
|
||||
float dx = (w - h * cols / rows) / 2; //center grid
|
||||
FCollectionView<ConquestOpponent> opponents = region.getOpponents();
|
||||
for (int i = 0; i < opponents.size(); i++) {
|
||||
GridPosition pos = path[i];
|
||||
float x0 = x + gridSize * pos.col + dx + iconOffset;
|
||||
float y0 = y + gridSize * pos.row + iconOffset;
|
||||
g.drawImage((FImage)opponents.get(i).getMapIcon(), x0, y0, iconSize, iconSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//path through region should look like this:
|
||||
// 15
|
||||
// 12 13 14
|
||||
// 11
|
||||
// 10 09 08 07 06
|
||||
// 05
|
||||
// 02 03 04
|
||||
// 01
|
||||
private static final int rows = 7;
|
||||
private static final int cols = 5;
|
||||
private static final GridPosition[] path = {
|
||||
new GridPosition(6, 2), //01 is at row 7 col 3
|
||||
new GridPosition(5, 2),
|
||||
new GridPosition(5, 3),
|
||||
new GridPosition(5, 4),
|
||||
new GridPosition(4, 4),
|
||||
new GridPosition(3, 4),
|
||||
new GridPosition(3, 3),
|
||||
new GridPosition(3, 2),
|
||||
new GridPosition(3, 1),
|
||||
new GridPosition(3, 0),
|
||||
new GridPosition(2, 0),
|
||||
new GridPosition(1, 0),
|
||||
new GridPosition(1, 1),
|
||||
new GridPosition(1, 2),
|
||||
new GridPosition(0, 2)
|
||||
};
|
||||
|
||||
private static class GridPosition {
|
||||
public final int row, col;
|
||||
public GridPosition(int row0, int col0) {
|
||||
row = row0;
|
||||
col = col0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ConquestMenu extends FPopupMenu {
|
||||
private static final ConquestMapScreen mapScreen = new ConquestMapScreen();
|
||||
private static final ConquestPrefsScreen prefsScreen = new ConquestPrefsScreen();
|
||||
|
||||
private static final FMenuItem mapItem = new FMenuItem("Command Center", FSkinImage.QUEST_MAP, new FEventHandler() {
|
||||
private static final FMenuItem mapItem = new FMenuItem("Planar Map", FSkinImage.QUEST_MAP, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
Forge.openScreen(mapScreen);
|
||||
|
||||
@@ -47,12 +47,12 @@ public class ConquestDataIO {
|
||||
/*ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Kamigawa,
|
||||
ConquestPlane.Kamigawa.getCardPool().getCard("Meloku the Clouded Mirror"));*/
|
||||
ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Mirrodin,
|
||||
ConquestPlane.Mirrodin.getCardPool().getCard("Glissa Sunseeker"));
|
||||
/*ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Mirrodin,
|
||||
ConquestPlane.Mirrodin.getCardPool().getCard("Glissa Sunseeker"));*/
|
||||
ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Ravnica,
|
||||
ConquestPlane.Ravnica.getCardPool().getCard("Savra, Queen of the Golgari"));*/
|
||||
ConquestPlane.Ravnica.getCardPool().getCard("Savra, Queen of the Golgari"));
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.item.PaperCard;
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
|
||||
public class ConquestOpponent {
|
||||
private final PaperCard commander;
|
||||
private final Region region;
|
||||
private final ISkinImage mapIcon;
|
||||
|
||||
public ConquestOpponent(PaperCard commander0, Region region0) {
|
||||
commander = commander0;
|
||||
region = region0;
|
||||
mapIcon = GuiBase.getInterface().getSkinIcon(determineMapIcon());
|
||||
}
|
||||
|
||||
//determine map icon from commander color set
|
||||
private FSkinProp determineMapIcon() {
|
||||
ColorSet colors = commander.getRules().getColorIdentity();
|
||||
switch (colors.countColors()) {
|
||||
case 0:
|
||||
return FSkinProp.IMG_MANA_COLORLESS;
|
||||
case 1:
|
||||
switch (colors.getColor()) {
|
||||
case MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_W;
|
||||
case MagicColor.BLUE:
|
||||
return FSkinProp.IMG_MANA_U;
|
||||
case MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_B;
|
||||
case MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_R;
|
||||
default:
|
||||
return FSkinProp.IMG_MANA_G;
|
||||
}
|
||||
case 2:
|
||||
switch (colors.getColor()) {
|
||||
case MagicColor.WHITE | MagicColor.BLUE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_WU;
|
||||
case MagicColor.BLUE | MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_HYBRID_UB;
|
||||
case MagicColor.BLACK | MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_HYBRID_BR;
|
||||
case MagicColor.RED | MagicColor.GREEN:
|
||||
return FSkinProp.IMG_MANA_HYBRID_RG;
|
||||
case MagicColor.GREEN | MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_GW;
|
||||
case MagicColor.WHITE | MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_HYBRID_WB;
|
||||
case MagicColor.BLUE | MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_HYBRID_UR;
|
||||
case MagicColor.BLACK | MagicColor.GREEN:
|
||||
return FSkinProp.IMG_MANA_HYBRID_BG;
|
||||
case MagicColor.RED | MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_RW;
|
||||
default:
|
||||
return FSkinProp.IMG_MANA_HYBRID_GU;
|
||||
}
|
||||
default:
|
||||
return FSkinProp.IMG_MULTI;
|
||||
}
|
||||
}
|
||||
|
||||
public ISkinImage getMapIcon() {
|
||||
return mapIcon;
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,7 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.card.CardEdition;
|
||||
@@ -240,6 +237,9 @@ public enum ConquestPlane {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Region region : regions) {
|
||||
region.generateOpponents();
|
||||
}
|
||||
commanders.sort(); //sort main commanders list for the sake of UI
|
||||
}
|
||||
|
||||
@@ -277,6 +277,7 @@ public enum ConquestPlane {
|
||||
private final ColorSet colorSet;
|
||||
private final Predicate<PaperCard> pred;
|
||||
private final DeckGenPool cardPool = new DeckGenPool();
|
||||
private final FCollection<ConquestOpponent> opponents = new FCollection<ConquestOpponent>();
|
||||
private final FCollection<PaperCard> commanders = new FCollection<PaperCard>();
|
||||
|
||||
private ISkinImage art;
|
||||
@@ -318,24 +319,39 @@ public enum ConquestPlane {
|
||||
return cardPool;
|
||||
}
|
||||
|
||||
public FCollectionView<PaperCard> getCommanders() {
|
||||
return commanders;
|
||||
public FCollectionView<ConquestOpponent> getOpponents() {
|
||||
return opponents;
|
||||
}
|
||||
|
||||
public ConquestCommander getRandomOpponent(ConquestCommander[] used) {
|
||||
//each region should have 15 opponents include one boss
|
||||
private void generateOpponents() {
|
||||
int opponentsBeforeBoss = 14;
|
||||
HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders);
|
||||
for (int i = 0; i < used.length; i++) {
|
||||
if (used[i] != null) {
|
||||
cards.remove(used[i].getCard());
|
||||
if (cards.size() < opponentsBeforeBoss) {
|
||||
//if not enough commanders, add normal creatures as non-commander opponents
|
||||
Iterable<PaperCard> creatures = cardPool.getAllCards(new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard card) {
|
||||
return card.getRules().getType().isCreature();
|
||||
}
|
||||
});
|
||||
while (cards.size() < opponentsBeforeBoss) {
|
||||
PaperCard card = Aggregates.random(creatures);
|
||||
if (!cards.contains(card)) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
if (cards.isEmpty()) { //if all commanders are used, we can't prevent duplicates
|
||||
cards.addAll(commanders);
|
||||
if (cards.isEmpty()) {
|
||||
Iterables.addAll(cards, FModel.getConquest().getModel().getCurrentPlane().getCommanders());
|
||||
}
|
||||
else {
|
||||
while (cards.size() > opponentsBeforeBoss) {
|
||||
cards.remove(Aggregates.random(cards));
|
||||
}
|
||||
}
|
||||
return new ConquestCommander(Aggregates.random(cards), cardPool, true);
|
||||
for (PaperCard card : cards) {
|
||||
opponents.add(new ConquestOpponent(card, this));
|
||||
}
|
||||
//TODO: Determine boss
|
||||
opponents.add(new ConquestOpponent(FModel.getMagicDb().getCommonCards().getCard("Savra, Queen of the Golgari"), this));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
Reference in New Issue
Block a user