Skip to content

Commit

Permalink
WIP #2: Expose APIs for shield strength and status
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Brindamour committed Mar 1, 2016
1 parent d027f4c commit 7438b65
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public interface EngineeringConsoleManager {
List<VesselNodeConnection> getGridConnections();

Property<List<EnhancedDamconStatus>> getDamconTeams();

Property<Integer> getFrontShieldStrength();

Property<Integer> getRearShieldStrength();

Property<Integer> getFrontShieldMaxStrength();

Property<Integer> getRearShieldMaxStrength();

Property<Boolean> getShieldsActive();

void setSystemEnergyAllocated(ShipSystem system, int amount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ public Property<Integer> getTotalCoolantRemaining() {
private final DerivedProperty<Integer> totalCoolantRemaining = new DerivedProperty<>( () -> {
return totalShipCoolant.get() - systemCoolantAllocated.get().values().stream().mapToInt(Integer::intValue).sum();
}, systemCoolantAllocated, totalShipCoolant);



@Override
protected Property<List<DamconStatus>> getRawDamconStatus() {
Expand All @@ -138,6 +136,36 @@ public Property<Float> getTotalEnergyRemaining() {
}
private final SettableProperty<Float> totalEnergyRemaining = new SettableProperty<>(1000f);

@Override
public Property<Integer> getFrontShieldStrength() {
return frontShieldStrength;
}
private final SettableProperty<Integer> frontShieldStrength = new SettableProperty<>(80);

@Override
public Property<Integer> getRearShieldStrength() {
return rearShieldStrength;
}
private final SettableProperty<Integer> rearShieldStrength = new SettableProperty<>(60);

@Override
public Property<Integer> getFrontShieldMaxStrength() {
return frontShieldMaxStrength;
}
private final SettableProperty<Integer> frontShieldMaxStrength = new SettableProperty<>(80);

@Override
public Property<Integer> getRearShieldMaxStrength() {
return rearShieldMaxStrength;
}
private final SettableProperty<Integer> rearShieldMaxStrength = new SettableProperty<>(80);

@Override
public Property<Boolean> getShieldsActive() {
return shieldsActive;
}

private final SettableProperty<Boolean> shieldsActive = new SettableProperty<>(false);

@Override
protected void updateSystemEnergyAllocated(ShipSystem system, int amount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,73 @@ public Property<Float> getTotalEnergyRemaining() {
return this.worldAwareServer.getSystemManager().getPlayerShip(0).getEnergy();
}, systemManagerChangeObservable);

@Override
public Property<Integer> getFrontShieldStrength() {
return frontShieldStrength;
}
private final DerivedProperty<Integer> frontShieldStrength = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
return 0;
}

return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFront();
}, systemManagerChangeObservable);


@Override
public Property<Integer> getRearShieldStrength() {
return rearShieldStrength;

}
private final DerivedProperty<Integer> rearShieldStrength = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
return 0;
}

return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFront();
}, systemManagerChangeObservable);

@Override
public Property<Integer> getFrontShieldMaxStrength() {
return frontShieldMaxStrength;
}
private final DerivedProperty<Integer> frontShieldMaxStrength = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
return 0;
}

return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFront();
}, systemManagerChangeObservable);


@Override
public Property<Integer> getRearShieldMaxStrength() {
return rearShieldMaxStrength;

}
private final DerivedProperty<Integer> rearShieldMaxStrength = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
return 0;
}

return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFront();
}, systemManagerChangeObservable);

@Override
public Property<Boolean> getShieldsActive() {
return shieldsActive;
}

private final DerivedProperty<Boolean> shieldsActive = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
return false;
}

return this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsState().getBooleanValue();
}, systemManagerChangeObservable);



@Override
public void incrementSystemEnergyAllocated(ShipSystem system, int amount) {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) {
Expand Down
14 changes: 9 additions & 5 deletions src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ public void handleKeyPress(KeyEvent e) {

// for (Entry<GridCoord, Float> entry : this.engineeringConsoleManager.getGridHealth().entrySet()) {
// System.out.println(entry.getKey() + " = " + entry.getValue());
// }
//
// for (EnhancedDamconStatus damconStatus : this.engineeringConsoleManager.getDamconTeams().get()) {
// System.out.println(damconStatus);
// }

for (EnhancedDamconStatus damconStatus : this.engineeringConsoleManager.getDamconTeams().get()) {
System.out.println(damconStatus);
}

System.out.println("Energy remaining: " + this.engineeringConsoleManager.getTotalEnergyRemaining());
System.out.println("Energy remaining: " + this.engineeringConsoleManager.getTotalEnergyRemaining().get());
System.out.println("Front shields: " + this.engineeringConsoleManager.getFrontShieldStrength().get());
System.out.println("Rear shields: " + this.engineeringConsoleManager.getRearShieldStrength().get());
System.out.println("Front shields max: " + this.engineeringConsoleManager.getFrontShieldMaxStrength().get());
System.out.println("Rear shields max: " + this.engineeringConsoleManager.getRearShieldMaxStrength().get());

System.out.println("\n\n\n");
} else if (kc == KeyEvent.VK_EQUALS) {
Expand Down

0 comments on commit 7438b65

Please sign in to comment.