mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Add some delays to the end day process and make it so commanders selected in order
This commit is contained in:
@@ -86,7 +86,27 @@ public class CommandCenterScreen extends FScreen implements IVCommandCenter {
|
||||
public void updateCurrentDay() {
|
||||
lblCurrentPlane.setText("Plane - " + model.getCurrentPlane().getName());
|
||||
btnEndDay.setText("End Day " + model.getDay());
|
||||
regionDisplay.onRegionChanged(); //simulate region change when day changes to ensure everything is updated
|
||||
|
||||
commanderRow.selectedIndex = 0; //select first commander at the beginning of each day
|
||||
ConquestCommander commander = commanderRow.panels[0].commander;
|
||||
if (commander != null && commander.getDeployedRegion() != null) {
|
||||
model.setCurrentRegion(commander.getDeployedRegion());
|
||||
}
|
||||
regionDisplay.onRegionChanged(); //simulate region change when day changes to ensure everything is updated, even if region didn't change
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSelectedCommander(ConquestCommander commander) {
|
||||
int newIndex = model.getCurrentPlaneData().getCommanders().indexOf(commander);
|
||||
boolean changed = commanderRow.selectedIndex != newIndex;
|
||||
commanderRow.selectedIndex = newIndex;
|
||||
if (commander.getDeployedRegion() != null) {
|
||||
if (model.setCurrentRegion(commander.getDeployedRegion())) {
|
||||
regionDisplay.onRegionChanged();
|
||||
changed = true; //if region changed, always return true
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,11 +287,11 @@ public class CommandCenterScreen extends FScreen implements IVCommandCenter {
|
||||
if (model.setCurrentRegion(commander.getDeployedRegion())) {
|
||||
regionDisplay.onRegionChanged();
|
||||
}
|
||||
else if (commander.getCurrentDayAction() != ConquestAction.Undeploy) {
|
||||
//if already on commander's region, change action to undeploy
|
||||
else if (commander.getCurrentDayAction() == null) {
|
||||
//if already on commander's region, change action to undeploy if no action currently set
|
||||
commander.setCurrentDayAction(ConquestAction.Undeploy);
|
||||
}
|
||||
else {
|
||||
else if (commander.getCurrentDayAction() == ConquestAction.Undeploy) {
|
||||
commander.setCurrentDayAction(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.card.CardRarity;
|
||||
@@ -122,6 +123,15 @@ public class ConquestController {
|
||||
}
|
||||
//perform all commander actions
|
||||
for (ConquestCommander commander : commanders) {
|
||||
if (commandCenter.setSelectedCommander(commander)) {
|
||||
try {
|
||||
//sleep if selection changed so user can see it take effect
|
||||
Thread.sleep(500);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
switch (commander.getCurrentDayAction()) {
|
||||
case Attack1:
|
||||
playGame(commander, 0, false, commandCenter);
|
||||
@@ -136,10 +146,10 @@ public class ConquestController {
|
||||
playGame(commander, Aggregates.randomInt(0, 2), true, commandCenter); //defend against random opponent
|
||||
break;
|
||||
case Recruit:
|
||||
if (!recruit(commander)) { return; }
|
||||
recruit(commander);
|
||||
break;
|
||||
case Study:
|
||||
if (!study(commander)) { return; }
|
||||
study(commander);
|
||||
break;
|
||||
case Undeploy:
|
||||
model.getCurrentPlaneData().getRegionData(commander.getDeployedRegion()).setDeployedCommander(null);
|
||||
@@ -147,15 +157,19 @@ public class ConquestController {
|
||||
default: //remaining actions don't need to do anything more
|
||||
break;
|
||||
}
|
||||
commander.setCurrentDayAction(null);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//increment day and reset actions, then update UI for new day
|
||||
//update UI for new day
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
model.incrementDay();
|
||||
for (ConquestCommander commander : commanders) {
|
||||
commander.setCurrentDayAction(null);
|
||||
}
|
||||
commandCenter.updateCurrentDay();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,5 +4,6 @@ import forge.planarconquest.ConquestController.GameRunner;
|
||||
|
||||
public interface IVCommandCenter {
|
||||
void updateCurrentDay();
|
||||
boolean setSelectedCommander(ConquestCommander commander);
|
||||
void startGame(final GameRunner gameRunner);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user