Search in sources :

Example 1 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class MainTest method testMineralMining.

private void testMineralMining() throws AssertionError {
    boolean commandSuccessful = false;
    Player self = this.bw.getInteractionHandler().self();
    Collection<Unit> allUnits = this.bw.getAllUnits();
    MineralPatch patch = null;
    for (Unit unit : allUnits) {
        if (unit instanceof MineralPatch) {
            patch = (MineralPatch) unit;
        }
    }
    List<PlayerUnit> units = this.bw.getUnits(self);
    SCV scv = null;
    for (PlayerUnit unit : units) {
        if (unit instanceof SCV) {
            scv = (SCV) unit;
        }
    }
    if (patch != null && scv != null) {
        commandSuccessful = scv.gather(patch);
    } else {
        logger.error("no scv and patch found.");
    }
    assertTrue("gather command failed.", commandSuccessful);
}
Also used : MineralPatch(org.openbw.bwapi4j.unit.MineralPatch) SCV(org.openbw.bwapi4j.unit.SCV) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit) Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 2 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitDestroy.

private void onUnitDestroy(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitDestroy: no unit found for ID {}.", unitId);
    }
    listener.onUnitDestroy(unit);
    this.units.remove(unitId);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 3 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitShow.

private void onUnitShow(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitShow: no unit found for ID {}.", unitId);
    }
    listener.onUnitShow(unit);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 4 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitMorph.

private void onUnitMorph(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitMorph: no unit found for ID {}.", unitId);
    }
    listener.onUnitMorph(unit);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 5 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitComplete.

private void onUnitComplete(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitComplete: no unit found for ID {}.", unitId);
    }
    listener.onUnitComplete(unit);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Aggregations

PlayerUnit (org.openbw.bwapi4j.unit.PlayerUnit)11 Unit (org.openbw.bwapi4j.unit.Unit)11 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)1 SCV (org.openbw.bwapi4j.unit.SCV)1