Make it so Chaos Wheel spins after winning a game

This commit is contained in:
drdev
2016-01-10 18:12:16 +00:00
parent 8e5822fe82
commit bc7a6fef0d
6 changed files with 33 additions and 5 deletions

View File

@@ -13,9 +13,14 @@ import forge.util.PhysicsObject;
import forge.util.ThreadUtil;
public class ConquestChaosWheel extends FOverlay {
public static void spin() {
ConquestChaosWheel wheel = new ConquestChaosWheel();
wheel.show();
}
private final WheelSpinAnimation animation = new WheelSpinAnimation();
public ConquestChaosWheel() {
private ConquestChaosWheel() {
}
@Override

View File

@@ -6,23 +6,27 @@ import forge.planarconquest.ConquestEvent;
import forge.screens.LaunchScreen;
import forge.screens.LoadingOverlay;
import forge.toolbox.FOptionPane;
import forge.util.Callback;
public class ConquestEventScreen extends LaunchScreen {
protected static final float PADDING = FOptionPane.PADDING;
private final ConquestEvent event;
private final Callback<ConquestEvent> callback;
private boolean launchedEvent;
public ConquestEventScreen(ConquestEvent event0) {
public ConquestEventScreen(ConquestEvent event0, Callback<ConquestEvent> callback0) {
super(event0.getEventName());
event = event0;
callback = callback0;
}
@Override
public void onActivate() {
if (launchedEvent) {
//when returning to this screen from launched event, close it immediately
//when returning to this screen from launched event, close it immediately and call callback
Forge.back();
callback.run(event);
}
}

View File

@@ -17,12 +17,14 @@ import forge.card.CardDetailUtil.DetailColors;
import forge.model.FModel;
import forge.planarconquest.ConquestData;
import forge.planarconquest.ConquestEvent.ConquestEventRecord;
import forge.planarconquest.ConquestEvent;
import forge.planarconquest.ConquestLocation;
import forge.planarconquest.ConquestPlane;
import forge.planarconquest.ConquestPlane.Region;
import forge.planarconquest.ConquestPlaneData;
import forge.screens.FScreen;
import forge.toolbox.FScrollPane;
import forge.util.Callback;
import forge.util.collect.FCollectionView;
public class ConquestMultiverseScreen extends FScreen {
@@ -57,7 +59,15 @@ public class ConquestMultiverseScreen extends FScreen {
}
private void launchEvent() {
Forge.openScreen(new ConquestEventScreen(model.getCurrentLocation().getEvent()));
Forge.openScreen(new ConquestEventScreen(model.getCurrentLocation().createEvent(), new Callback<ConquestEvent>() {
@Override
public void run(ConquestEvent event) {
if (event.wasConquered()) {
//spin Chaos Wheel if event was conquered
ConquestChaosWheel.spin();
}
}
}));
}
private class PlaneGrid extends FScrollPane {

View File

@@ -187,6 +187,7 @@ public final class ConquestData {
public void addWin(ConquestEvent event) {
getOrCreatePlaneData(event.getLocation().getPlane()).addWin(event);
getSelectedCommander().getRecord().addWin();
event.setConquered(true);
}
public void addLoss(ConquestEvent event) {

View File

@@ -12,6 +12,7 @@ public abstract class ConquestEvent {
private final ConquestLocation location;
private final int tier;
private Deck opponentDeck;
private boolean conquered;
public ConquestEvent(ConquestLocation location0, int tier0) {
location = location0;
@@ -33,6 +34,13 @@ public abstract class ConquestEvent {
return opponentDeck;
}
public boolean wasConquered() {
return conquered;
}
public void setConquered(boolean conquered0) {
conquered = conquered0;
}
protected abstract Deck buildOpponentDeck();
public abstract void addVariants(Set<GameType> variants);
public abstract String getEventName();

View File

@@ -113,7 +113,7 @@ public class ConquestLocation implements IXmlWritable {
catch (Exception e) { return false; }
}
public ConquestEvent getEvent() {
public ConquestEvent createEvent() {
//TODO: Make this pull from predefined events
return new ConquestEvent(this, 0) {
private final PaperCard commander = Aggregates.random(getRegion().getCommanders());