Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Issue #48 Added command cards to overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
kingargyle committed Nov 2, 2017
1 parent 3df8007 commit 405916f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@
</div>
</#if>
</#list>

<hr />
<#list iaspec.commandCards as command>
<div id="commandCards">
<div class="cardName">${command.commandCard.name} : ${command.commandCard.cost}</div>
</div>
</#list>
<hr />
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.eclipse.ui.part.ViewPart;

import us.nineworlds.iadata.IASpec;
import us.nineworlds.iadata.command.CommandCard;
import us.nineworlds.iadata.command.CommandCards;
import us.nineworlds.iadata.deployment.Deployment;
import us.nineworlds.iadata.deployment.Deployments;
import us.nineworlds.iadata.enums.Factions;
Expand All @@ -36,6 +38,7 @@
import us.nineworlds.xstreamer.ia.events.GenerateArmyEvent;
import us.nineworlds.xstreamer.ia.jobs.GenerateArmyJob;
import us.nineworlds.xstreamer.ia.listeners.ArmySelectionChangeListener;
import us.nineworlds.xstreamer.ia.lookup.CommandCardLookup;
import us.nineworlds.xstreamer.ia.lookup.DeploymentsLookup;
import us.nineworlds.xstreamer.ia.model.ArmyContentProvider;
import us.nineworlds.xstreamer.ia.model.ArmyLabelProvider;
Expand Down Expand Up @@ -164,23 +167,8 @@ public void widgetSelected(SelectionEvent e) {
IASpecLoader iaspecFile = new IASpecLoader();
try {
IASpec iaspec = iaspecFile.load(new ByteArrayInputStream(json.getBytes()));
DeploymentsLookup deploymentsLookup = Activator.getDefault().getDeploymentsLookup();
for (Deployments deployments : iaspec.getArmy().getDeployments()) {
Deployment deployment = deployments.getDeployment();
Factions faction = deployment.getFaction();
String iaspecName = deployment.getIaspecname();
Deployment deploymentEntry = deploymentsLookup.findDeploymentCard(iaspecName, faction.toString());
if (deploymentEntry != null) {
deployment.setHealth(deploymentEntry.getHealth());
deployment.setSpeed(deploymentEntry.getSpeed());
deployment.setDeploymentCost(deploymentEntry.getDeploymentCost());
deployment.setUnitsInGroup(deploymentEntry.getUnitsInGroup());
deployment.setReenforcementCost(deploymentEntry.getReenforcementCost());
}
if (deployment.getName() == null && deploymentEntry == null) {
deployment.setName(deployment.getIaspecname());
}
}
updateDeployments(iaspec);
updateCommandCards(iaspec);

resetPlayerModel(iaspec);
refreshTree();
Expand All @@ -191,6 +179,45 @@ public void widgetSelected(SelectionEvent e) {
}
}

private void updateDeployments(IASpec iaspec) {
DeploymentsLookup deploymentsLookup = Activator.getDefault().getDeploymentsLookup();
for (Deployments deployments : iaspec.getArmy().getDeployments()) {
Deployment deployment = deployments.getDeployment();
Factions faction = deployment.getFaction();
String iaspecName = deployment.getIaspecname();
Deployment deploymentEntry = deploymentsLookup.findDeploymentCard(iaspecName, faction.toString());
if (deploymentEntry != null) {
deployment.setHealth(deploymentEntry.getHealth());
deployment.setSpeed(deploymentEntry.getSpeed());
deployment.setDeploymentCost(deploymentEntry.getDeploymentCost());
deployment.setUnitsInGroup(deploymentEntry.getUnitsInGroup());
deployment.setReenforcementCost(deploymentEntry.getReenforcementCost());
}
if (deployment.getName() == null && deploymentEntry == null) {
deployment.setName(deployment.getIaspecname());
}
}
}

private void updateCommandCards(IASpec iaspec) {
CommandCardLookup commandLookup = Activator.getDefault().getCommandCardLookup();
for (CommandCards commandCards : iaspec.getCommandCards()) {
CommandCard commandCard = commandCards.getCommandCard();
Factions faction = commandCard.getFaction();
String iaspecName = commandCard.getIaspecname();
CommandCard card = commandLookup.findCommandCard(iaspecName, faction.toString());
if (card != null) {
commandCard.setCost(card.getCost());
commandCard.setLimit(card.getLimit());
commandCard.setName(card.getName());
}
if (commandCard.getName() == null && card == null) {
commandCard.setName(commandCard.getIaspecname());
}
}
}


@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
Expand Down

0 comments on commit 405916f

Please sign in to comment.