File tree Expand file tree Collapse file tree 5 files changed +59
-8
lines changed Expand file tree Collapse file tree 5 files changed +59
-8
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ public class Agent {
46
46
int stopFrames ;
47
47
int remainingStimFrames ;
48
48
boolean canStim ;
49
+ int plagueDamagePerFrameShifted ;
49
50
50
51
// Is Zerg and not an Egg/Larva
51
52
boolean regeneratesHealth ;
@@ -337,6 +338,11 @@ public Agent setHpConstructionRate(int buildTime) {
337
338
return this ;
338
339
}
339
340
341
+ public Agent setPlagueDamage (int plagueDamage ) {
342
+ this .plagueDamagePerFrameShifted = (plagueDamage << 8 ) / 76 ;
343
+ return this ;
344
+ }
345
+
340
346
public enum TargetingPriority {
341
347
LOW ,
342
348
MEDIUM ,
Original file line number Diff line number Diff line change @@ -230,7 +230,6 @@ public Agent of(PlayerUnit unit) {
230
230
hasEnergyUpgrade (unitType , player ));
231
231
if (map != null && !unit .isFlying ()) {
232
232
agent .setElevationLevel (map .getGroundHeight (unit .getTilePosition ()));
233
- // agent.setProtectedByDarkSwarm(unit.isUnderDarkSwarm()); Not supported by BWAPI4J currently
234
233
}
235
234
if (unitType == UnitType .Terran_Marine || unitType == UnitType .Terran_Firebat ) {
236
235
agent .setCanStim (player .hasResearched (TechType .Stim_Packs ));
Original file line number Diff line number Diff line change @@ -209,7 +209,8 @@ public Agent of(
209
209
.setUserObject (unit )
210
210
.setBurrowed (unit .isBurrowed ())
211
211
.setStasised (unit .isStasised ())
212
- .setLockeddown (unit .isLockedDown ());
212
+ .setLockeddown (unit .isLockedDown ())
213
+ .setPlagueDamage (unit .isPlagued () ? WeaponType .Plague .damageAmount () : 0 );
213
214
}
214
215
215
216
public Agent of (Unit unit ) {
Original file line number Diff line number Diff line change @@ -199,6 +199,15 @@ private void updateStats(UnorderedCollection<Agent> agents) {
199
199
if (agent .cooldown > 0 ) {
200
200
agent .cooldown --;
201
201
}
202
+ if (agent .shieldsShifted < agent .maxShieldsShifted ) {
203
+ agent .shieldsShifted += 7 ;
204
+ if (agent .shieldsShifted > agent .maxShieldsShifted ) {
205
+ agent .shieldsShifted = agent .maxShieldsShifted ;
206
+ }
207
+ }
208
+ if (agent .plagueDamagePerFrameShifted < agent .healthShifted ) {
209
+ agent .healthShifted -= agent .plagueDamagePerFrameShifted ;
210
+ }
202
211
if (agent .remainingStimFrames > 0 ) {
203
212
agent .remainingStimFrames --;
204
213
}
@@ -208,12 +217,6 @@ private void updateStats(UnorderedCollection<Agent> agents) {
208
217
agent .healthShifted = agent .maxHealthShifted ;
209
218
}
210
219
}
211
- if (agent .shieldsShifted < agent .maxShieldsShifted ) {
212
- agent .shieldsShifted += 7 ;
213
- if (agent .shieldsShifted > agent .maxShieldsShifted ) {
214
- agent .shieldsShifted = agent .maxShieldsShifted ;
215
- }
216
- }
217
220
agent .energyShifted += 8 ;
218
221
if (agent .energyShifted > agent .maxEnergyShifted ) {
219
222
agent .energyShifted = agent .maxEnergyShifted ;
Original file line number Diff line number Diff line change 5
5
import org .junit .jupiter .api .Test ;
6
6
import org .openbw .bwapi4j .test .BWDataProvider ;
7
7
import org .openbw .bwapi4j .type .UnitType ;
8
+ import org .openbw .bwapi4j .type .WeaponType ;
8
9
9
10
import static org .assertj .core .api .Assertions .assertThat ;
10
11
import static org .junit .jupiter .api .Assertions .assertThrows ;
@@ -771,4 +772,45 @@ void darkSwarmZerglingVsMarines() {
771
772
assertThat (simulator .getAgentsA ()).isEmpty ();
772
773
assertThat (simulator .getAgentsB ()).isNotEmpty ();
773
774
}
775
+
776
+ @ Test
777
+ void shouldDealPlagueDamage () {
778
+ // GIVEN
779
+ simulator .addAgentA (
780
+ factory .of (UnitType .Terran_Marine ).setPlagueDamage (WeaponType .Plague .damageAmount ()));
781
+
782
+ // Dummy unit
783
+ simulator .addAgentB (factory .of (UnitType .Protoss_Carrier ));
784
+
785
+ // WHEN
786
+ simulator .simulate (1 );
787
+
788
+ // THEN
789
+ assertThat (simulator .getAgentsA ())
790
+ .first ()
791
+ .extracting (a -> a .healthShifted )
792
+ .isEqualTo (9230 ); // ~4 damage taken
793
+ }
794
+
795
+ @ Test
796
+ void shouldNotDieFromPlague () {
797
+ // GIVEN
798
+ simulator .addAgentA (
799
+ factory
800
+ .of (UnitType .Terran_Marine )
801
+ .setPlagueDamage (WeaponType .Plague .damageAmount ())
802
+ .setHealth (2 ));
803
+
804
+ // Dummy unit
805
+ simulator .addAgentB (factory .of (UnitType .Protoss_Carrier ));
806
+
807
+ // WHEN
808
+ simulator .simulate (1 );
809
+
810
+ // THEN
811
+ assertThat (simulator .getAgentsA ())
812
+ .first ()
813
+ .extracting (a -> a .healthShifted )
814
+ .isEqualTo (512 ); // No damage taken
815
+ }
774
816
}
You can’t perform that action at this time.
0 commit comments