Search in sources :

Example 56 with Unit

use of bwapi.Unit in project Ecgberht by Jabbo16.

the class ChooseMachineShop method execute.

@Override
public State execute() {
    try {
        if (!((GameState) this.handler).Fs.isEmpty()) {
            for (Unit c : ((GameState) this.handler).Fs) {
                if (!c.isTraining() && c.getAddon() == null) {
                    ((GameState) this.handler).chosenBuildingAddon = c;
                    ((GameState) this.handler).chosenAddon = UnitType.Terran_Machine_Shop;
                    return State.SUCCESS;
                }
            }
        }
        ((GameState) this.handler).chosenBuildingAddon = null;
        ((GameState) this.handler).chosenAddon = null;
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        System.err.println(e);
        return State.ERROR;
    }
}
Also used : GameState(ecgberht.GameState) Unit(bwapi.Unit)

Example 57 with Unit

use of bwapi.Unit in project Ecgberht by Jabbo16.

the class Squad method giveStimOrder.

public void giveStimOrder() {
    for (Unit u : members) {
        if (u.canUseTech(TechType.Stim_Packs) && !u.isStimmed() && u.isAttacking() && u.getHitPoints() >= 25) {
            u.useTech(TechType.Stim_Packs);
            if (getGs().getGame().elapsedTime() > getGs().lastFrameStim + 20) {
                getGs().playSound("stim.mp3");
                getGs().lastFrameStim = getGs().getGame().elapsedTime();
            }
        }
    }
}
Also used : Unit(bwapi.Unit)

Example 58 with Unit

use of bwapi.Unit in project Ecgberht by Jabbo16.

the class ChooseMarine method execute.

@Override
public State execute() {
    try {
        if (!((GameState) this.handler).MBs.isEmpty()) {
            for (Unit b : ((GameState) this.handler).MBs) {
                if (!b.isTraining()) {
                    ((GameState) this.handler).chosenUnit = UnitType.Terran_Marine;
                    ((GameState) this.handler).chosenBuilding = b;
                    return State.SUCCESS;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        System.err.println(e);
        return State.ERROR;
    }
}
Also used : GameState(ecgberht.GameState) Unit(bwapi.Unit)

Example 59 with Unit

use of bwapi.Unit in project Ecgberht by Jabbo16.

the class ChooseSCV method execute.

@Override
public State execute() {
    try {
        if (((GameState) this.handler).strat.name == "ProxyBBS") {
            boolean notTraining = false;
            for (Unit b : ((GameState) this.handler).MBs) {
                if (!b.isTraining()) {
                    notTraining = true;
                    break;
                }
            }
            if (notTraining) {
                return State.FAILURE;
            }
        }
        if (((GameState) this.handler).getPlayer().allUnitCount(UnitType.Terran_SCV) < 50 && ((GameState) this.handler).getPlayer().allUnitCount(UnitType.Terran_SCV) < ((GameState) this.handler).mineralsAssigned.size() * 2 + 3 && !((GameState) this.handler).CCs.isEmpty()) {
            for (Unit b : ((GameState) this.handler).CCs.values()) {
                if (!b.isTraining() && !b.isConstructing()) {
                    ((GameState) this.handler).chosenUnit = UnitType.Terran_SCV;
                    ((GameState) this.handler).chosenBuilding = b;
                    return State.SUCCESS;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        System.err.println(e);
        return State.ERROR;
    }
}
Also used : GameState(ecgberht.GameState) Unit(bwapi.Unit)

Example 60 with Unit

use of bwapi.Unit in project Ecgberht by Jabbo16.

the class ChooseVulture method execute.

@Override
public State execute() {
    try {
        if (!((GameState) this.handler).Fs.isEmpty()) {
            if (((GameState) this.handler).getPlayer().allUnitCount(UnitType.Terran_Vulture) * 2 <= ((GameState) this.handler).getPlayer().allUnitCount(UnitType.Terran_Siege_Tank_Siege_Mode) + ((GameState) this.handler).getPlayer().allUnitCount(UnitType.Terran_Siege_Tank_Tank_Mode) + 2) {
                for (Unit b : ((GameState) this.handler).Fs) {
                    if (!b.isTraining() && b.canTrain()) {
                        ((GameState) this.handler).chosenUnit = UnitType.Terran_Vulture;
                        ((GameState) this.handler).chosenBuilding = b;
                        return State.SUCCESS;
                    }
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        System.err.println(e);
        return State.ERROR;
    }
}
Also used : GameState(ecgberht.GameState) Unit(bwapi.Unit)

Aggregations

Unit (bwapi.Unit)73 GameState (ecgberht.GameState)36 Test (org.junit.Test)21 Position (bwapi.Position)14 TilePosition (bwapi.TilePosition)10 BaseLocation (bwta.BaseLocation)7 Pair (bwapi.Pair)6 UnitType (bwapi.UnitType)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Player (bwapi.Player)3 EnemyBuilding (ecgberht.EnemyBuilding)3 RaceUtils.createMockRace (BWJSAL.utils.RaceUtils.createMockRace)2 UnitTypeUtils.mockResourceDepotUnitType (BWJSAL.utils.UnitTypeUtils.mockResourceDepotUnitType)2 Race (bwapi.Race)2 Squad (ecgberht.Squad)2 Game (bwapi.Game)1 UnitCommand (bwapi.UnitCommand)1 Region (bwta.Region)1 Random (java.util.Random)1