├── .gitignore ├── .gitmodules ├── .travis.yml ├── BWAPI4J-AP ├── README.md └── src │ └── main │ ├── java │ └── org │ │ └── openbw │ │ └── bwapi4j │ │ └── ap │ │ ├── ArrayValue.java │ │ ├── Assignment.java │ │ ├── Assignments.java │ │ ├── BWMappedValue.java │ │ ├── BridgeCodeProcessor.java │ │ ├── BridgeModel.java │ │ ├── BridgeValue.java │ │ ├── Delegate.java │ │ ├── EnumValue.java │ │ ├── Indexed.java │ │ ├── ListValue.java │ │ ├── LookedUp.java │ │ ├── MapValue.java │ │ ├── Named.java │ │ ├── NamedAssignment.java │ │ ├── NativeClass.java │ │ ├── NewObjectValue.java │ │ ├── PrimitiveValue.java │ │ ├── RValue.java │ │ └── Reset.java │ └── resources │ ├── META-INF │ └── services │ │ └── javax.annotation.processing.Processor │ ├── c++_templates.stg │ └── java_templates.stg ├── BWAPI4J ├── .gitignore └── src │ ├── main │ ├── java │ │ ├── bwem │ │ │ ├── BWEM.java │ │ │ ├── Base.java │ │ │ ├── BaseImpl.java │ │ │ ├── CheckMode.java │ │ │ ├── ChokePoint.java │ │ │ ├── ChokePointImpl.java │ │ │ ├── Graph.java │ │ │ ├── LICENSE.txt │ │ │ ├── MapDrawer.java │ │ │ ├── MapPrinter.java │ │ │ ├── Markable.java │ │ │ ├── README.md │ │ │ ├── StaticMarkable.java │ │ │ ├── area │ │ │ │ ├── Area.java │ │ │ │ ├── AreaImpl.java │ │ │ │ ├── AreaInitializer.java │ │ │ │ ├── AreaInitializerImpl.java │ │ │ │ ├── TempAreaInfo.java │ │ │ │ └── typedef │ │ │ │ │ ├── AreaId.java │ │ │ │ │ └── GroupId.java │ │ │ ├── example │ │ │ │ └── MapPrinterExample.java │ │ │ ├── map │ │ │ │ ├── Map.java │ │ │ │ ├── MapData.java │ │ │ │ ├── MapDataImpl.java │ │ │ │ ├── MapImpl.java │ │ │ │ ├── MapInitializer.java │ │ │ │ ├── MapInitializerImpl.java │ │ │ │ ├── TerrainData.java │ │ │ │ ├── TerrainDataImpl.java │ │ │ │ ├── TerrainDataInitializer.java │ │ │ │ └── TerrainDataInitializerImpl.java │ │ │ ├── tile │ │ │ │ ├── MiniTile.java │ │ │ │ ├── MiniTileImpl.java │ │ │ │ ├── Tile.java │ │ │ │ ├── TileData.java │ │ │ │ ├── TileDataImpl.java │ │ │ │ └── TileImpl.java │ │ │ ├── typedef │ │ │ │ ├── Altitude.java │ │ │ │ ├── CPPath.java │ │ │ │ ├── Index.java │ │ │ │ └── Pred.java │ │ │ ├── unit │ │ │ │ ├── Geyser.java │ │ │ │ ├── Mineral.java │ │ │ │ ├── Neutral.java │ │ │ │ ├── NeutralData.java │ │ │ │ ├── NeutralDataImpl.java │ │ │ │ ├── NeutralImpl.java │ │ │ │ ├── Resource.java │ │ │ │ └── StaticBuilding.java │ │ │ └── util │ │ │ │ ├── Asserts.java │ │ │ │ ├── BwemException.java │ │ │ │ ├── BwemExt.java │ │ │ │ ├── IWrappedInteger.java │ │ │ │ ├── PairGenericAltitudeComparator.java │ │ │ │ ├── PairGenericMiniTileAltitudeComparator.java │ │ │ │ ├── Timer.java │ │ │ │ ├── Utils.java │ │ │ │ └── XYCropper.java │ │ ├── org │ │ │ └── openbw │ │ │ │ └── bwapi4j │ │ │ │ ├── BW.java │ │ │ │ ├── BWAPI4J.java │ │ │ │ ├── BWEventListener.java │ │ │ │ ├── BWMap.java │ │ │ │ ├── BWMapImpl.java │ │ │ │ ├── Bullet.java │ │ │ │ ├── DamageEvaluator.java │ │ │ │ ├── InteractionHandler.java │ │ │ │ ├── MapDrawer.java │ │ │ │ ├── Player.java │ │ │ │ ├── Position.java │ │ │ │ ├── TilePosition.java │ │ │ │ ├── UnitStatCalculator.java │ │ │ │ ├── WalkPosition.java │ │ │ │ ├── test │ │ │ │ ├── BWDataProvider.java │ │ │ │ ├── TechTypes.java │ │ │ │ ├── UnitTypes.java │ │ │ │ ├── UpgradeTypes.java │ │ │ │ └── WeaponTypes.java │ │ │ │ ├── type │ │ │ │ ├── BulletType.java │ │ │ │ ├── BwError.java │ │ │ │ ├── Color.java │ │ │ │ ├── DamageType.java │ │ │ │ ├── ExplosionType.java │ │ │ │ ├── GameType.java │ │ │ │ ├── IdMapperHelper.java │ │ │ │ ├── Key.java │ │ │ │ ├── Order.java │ │ │ │ ├── PlayerType.java │ │ │ │ ├── Race.java │ │ │ │ ├── TechType.java │ │ │ │ ├── UnitCommandType.java │ │ │ │ ├── UnitSizeType.java │ │ │ │ ├── UnitType.java │ │ │ │ ├── UpgradeType.java │ │ │ │ └── WeaponType.java │ │ │ │ ├── unit │ │ │ │ ├── Academy.java │ │ │ │ ├── Addon.java │ │ │ │ ├── AddonImpl.java │ │ │ │ ├── AirAttacker.java │ │ │ │ ├── Arbiter.java │ │ │ │ ├── ArbiterTribunal.java │ │ │ │ ├── Archon.java │ │ │ │ ├── Armory.java │ │ │ │ ├── Assimilator.java │ │ │ │ ├── Attacker.java │ │ │ │ ├── Barracks.java │ │ │ │ ├── BattleCruiser.java │ │ │ │ ├── Broodling.java │ │ │ │ ├── Building.java │ │ │ │ ├── BuildingImpl.java │ │ │ │ ├── Bunker.java │ │ │ │ ├── Burrowable.java │ │ │ │ ├── Carrier.java │ │ │ │ ├── CitadelOfAdun.java │ │ │ │ ├── Cloakable.java │ │ │ │ ├── Cocoon.java │ │ │ │ ├── CommandCenter.java │ │ │ │ ├── ComsatStation.java │ │ │ │ ├── ControlTower.java │ │ │ │ ├── Corsair.java │ │ │ │ ├── CovertOps.java │ │ │ │ ├── CreepColony.java │ │ │ │ ├── Critter.java │ │ │ │ ├── CyberneticsCore.java │ │ │ │ ├── DarkArchon.java │ │ │ │ ├── DarkSwarm.java │ │ │ │ ├── DarkTemplar.java │ │ │ │ ├── Defiler.java │ │ │ │ ├── DefilerMound.java │ │ │ │ ├── Detector.java │ │ │ │ ├── Devourer.java │ │ │ │ ├── DisruptionWeb.java │ │ │ │ ├── Dragoon.java │ │ │ │ ├── Drone.java │ │ │ │ ├── Dropship.java │ │ │ │ ├── Egg.java │ │ │ │ ├── EngineeringBay.java │ │ │ │ ├── EvolutionChamber.java │ │ │ │ ├── ExtendibleByAddon.java │ │ │ │ ├── Extractor.java │ │ │ │ ├── Factory.java │ │ │ │ ├── Firebat.java │ │ │ │ ├── FleetBeacon.java │ │ │ │ ├── FlyingBuilding.java │ │ │ │ ├── Forge.java │ │ │ │ ├── GasMiningFacility.java │ │ │ │ ├── GasMiningFacilityImpl.java │ │ │ │ ├── Gateway.java │ │ │ │ ├── Gatherable.java │ │ │ │ ├── Ghost.java │ │ │ │ ├── Goliath.java │ │ │ │ ├── GreaterSpire.java │ │ │ │ ├── GroundAttacker.java │ │ │ │ ├── Guardian.java │ │ │ │ ├── Hatchery.java │ │ │ │ ├── HighTemplar.java │ │ │ │ ├── Hive.java │ │ │ │ ├── Hydralisk.java │ │ │ │ ├── HydraliskDen.java │ │ │ │ ├── InfestedCommandCenter.java │ │ │ │ ├── InfestedTerran.java │ │ │ │ ├── Interceptor.java │ │ │ │ ├── Lair.java │ │ │ │ ├── Larva.java │ │ │ │ ├── Loadable.java │ │ │ │ ├── Lurker.java │ │ │ │ ├── LurkerEgg.java │ │ │ │ ├── MachineShop.java │ │ │ │ ├── Marine.java │ │ │ │ ├── Mechanical.java │ │ │ │ ├── Medic.java │ │ │ │ ├── MineralPatch.java │ │ │ │ ├── MissileTurret.java │ │ │ │ ├── MobileUnit.java │ │ │ │ ├── MobileUnitImpl.java │ │ │ │ ├── Morphable.java │ │ │ │ ├── Mutalisk.java │ │ │ │ ├── Nexus.java │ │ │ │ ├── NuclearMissile.java │ │ │ │ ├── NuclearSilo.java │ │ │ │ ├── NydusCanal.java │ │ │ │ ├── Observatory.java │ │ │ │ ├── Observer.java │ │ │ │ ├── Organic.java │ │ │ │ ├── Overlord.java │ │ │ │ ├── PhotonCannon.java │ │ │ │ ├── PhysicsLab.java │ │ │ │ ├── PlayerUnit.java │ │ │ │ ├── PlayerUnitImpl.java │ │ │ │ ├── Probe.java │ │ │ │ ├── Pylon.java │ │ │ │ ├── Queen.java │ │ │ │ ├── QueensNest.java │ │ │ │ ├── RawUnit.java │ │ │ │ ├── RawUnitFactory.java │ │ │ │ ├── Reaver.java │ │ │ │ ├── Refinery.java │ │ │ │ ├── ResearchingFacility.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceDepot.java │ │ │ │ ├── Robotic.java │ │ │ │ ├── RoboticsFacility.java │ │ │ │ ├── RoboticsSupportBay.java │ │ │ │ ├── SCV.java │ │ │ │ ├── ScannerSweep.java │ │ │ │ ├── Scarab.java │ │ │ │ ├── ScienceFacility.java │ │ │ │ ├── ScienceVessel.java │ │ │ │ ├── Scourge.java │ │ │ │ ├── Scout.java │ │ │ │ ├── ShieldBattery.java │ │ │ │ ├── Shuttle.java │ │ │ │ ├── SiegeTank.java │ │ │ │ ├── SpawningPool.java │ │ │ │ ├── SpecialBuilding.java │ │ │ │ ├── SpecialUnit.java │ │ │ │ ├── Spell.java │ │ │ │ ├── SpellCaster.java │ │ │ │ ├── SpiderMine.java │ │ │ │ ├── Spire.java │ │ │ │ ├── SporeColony.java │ │ │ │ ├── Stargate.java │ │ │ │ ├── Starport.java │ │ │ │ ├── SunkenColony.java │ │ │ │ ├── SupplyDepot.java │ │ │ │ ├── SupplyProvider.java │ │ │ │ ├── TemplarArchives.java │ │ │ │ ├── TrainingFacility.java │ │ │ │ ├── Transporter.java │ │ │ │ ├── Ultralisk.java │ │ │ │ ├── UltraliskCavern.java │ │ │ │ ├── Unit.java │ │ │ │ ├── UnitDataBridge.java │ │ │ │ ├── UnitFactory.java │ │ │ │ ├── UnitImpl.java │ │ │ │ ├── UnsupportedUnitException.java │ │ │ │ ├── Valkyrie.java │ │ │ │ ├── VespeneGeyser.java │ │ │ │ ├── Vulture.java │ │ │ │ ├── Weapon.java │ │ │ │ ├── Worker.java │ │ │ │ ├── Wraith.java │ │ │ │ ├── Zealot.java │ │ │ │ └── Zergling.java │ │ │ │ └── util │ │ │ │ ├── BridgeUtils.java │ │ │ │ ├── Cache.java │ │ │ │ ├── DependencyManager.java │ │ │ │ ├── MathUtils.java │ │ │ │ ├── Pair.java │ │ │ │ └── system │ │ │ │ ├── OSType.java │ │ │ │ └── SystemUtils.java │ │ └── yata │ │ │ ├── MapPrinter.java │ │ │ └── YATA.java │ └── resources │ │ └── log4j2.xml │ └── test │ ├── java │ ├── bwem │ │ ├── MarkableClassA.java │ │ ├── MarkableClassB.java │ │ ├── MarkableTest.java │ │ ├── OldMarkable.java │ │ ├── OldMarkableClassA.java │ │ ├── OldMarkableClassB.java │ │ ├── OldMarkableTest.java │ │ ├── TestListenerBwem.java │ │ ├── map │ │ │ └── MapTest.java │ │ ├── typedef │ │ │ └── AltitudeTest.java │ │ └── util │ │ │ ├── PairGenericAltitudeComparatorTest.java │ │ │ └── PairGenericMiniTileAltitudeComparatorTest.java │ ├── mockdata │ │ ├── BWAPI_DummyData.java │ │ ├── BWAPI_MapInfo.java │ │ ├── BWEM_CPPathSamples.java │ │ ├── BWEM_DummyData.java │ │ ├── DummyDataUtils.java │ │ └── TestDataExporter.java │ ├── org │ │ └── openbw │ │ │ └── bwapi4j │ │ │ ├── BWMapImplTest.java │ │ │ ├── BWMapMock.java │ │ │ ├── MainTest.java │ │ │ ├── PositionTest.java │ │ │ ├── TestListener.java │ │ │ ├── TilePositionTest.java │ │ │ ├── WalkPositionTest.java │ │ │ ├── type │ │ │ ├── UnitTypeTest.java │ │ │ └── UpgradeTypeTest.java │ │ │ ├── unit │ │ │ ├── BuildingMock.java │ │ │ ├── BuildingTest.java │ │ │ ├── MineralPatchMock.java │ │ │ ├── UnitMock.java │ │ │ └── VespeneGeyserMock.java │ │ │ └── util │ │ │ └── PairTest.java │ └── yata │ │ └── TestListenerYata.java │ └── resources │ └── mockdata │ ├── DummyBwapiData_MapInfo_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwapiData_Neutrals_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwapiData_getGroundHeight_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwapiData_getStartLocations_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwapiData_isBuildable_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwapiData_isWalkable_BWAPI-4.2.0.tar.bz2 │ ├── DummyBwemData_Bases_Minerals_Geysers_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 │ ├── DummyBwemData_CPPathSamples_1_Node_Min_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 │ ├── DummyBwemData_ChokePoints_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 │ └── DummyBwemData_MiniTileAltitudes_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 ├── BWAPI4JBridge ├── .clang-format ├── .gitignore ├── CMakeLists.txt ├── ap_inc.cmake ├── build_bridge_openbw_linux.sh ├── build_bridge_openbw_windows.bat ├── build_bridge_vanilla_windows.bat ├── build_bwapi_openbw_linux.sh ├── build_bwapi_openbw_windows.bat ├── build_bwapi_vanilla_windows.bat ├── build_bwem_openbw_linux.sh ├── build_bwem_openbw_windows.bat ├── build_bwem_vanilla_windows.bat ├── bwapi4j.cmake ├── bwapi4jbridge.cmake ├── bwapi_inc.cmake ├── bwapi_lib.cmake ├── externals.cmake ├── externals │ └── bwem │ │ ├── CMakeLists.txt │ │ ├── bwem.cmake │ │ ├── bwem_defs.cmake │ │ ├── bwem_inc.cmake │ │ └── bwem_lib.cmake ├── flags.cmake ├── formatting.sh ├── func.cmake ├── jni_inc.cmake ├── spdlog_inc.cmake └── src │ ├── BWAPILauncher.cpp │ ├── BWAPILauncher.h │ ├── Bridge.cpp │ ├── BridgeEnum.cpp │ ├── BridgeEnum.h │ ├── BridgeMap.cpp │ ├── BridgeMap.h │ ├── Callbacks.cpp │ ├── Callbacks.h │ ├── DamageEvaluator.cpp │ ├── DataBuffer.cpp │ ├── DataBuffer.h │ ├── Globals.cpp │ ├── Globals.h │ ├── InteractionHandler.cpp │ ├── JavaRefs.cpp │ ├── JavaRefs.h │ ├── JniBwem.cpp │ ├── JniBwem.h │ ├── Logger.cpp │ ├── Logger.h │ ├── MapDrawer.cpp │ ├── OpenBridgeModule.cpp │ ├── OpenBridgeModule.h │ └── Unit.cpp ├── CONTRIBUTING.md ├── CREDITS.md ├── LICENSE ├── README.md ├── appveyor.yml ├── build.gradle ├── bwapi-data └── bwapi.ini.sample ├── githooks └── pre-commit.sh ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── webhooks └── appveyor_discord.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | /openbw/ 2 | .cache/ 3 | .gradle/ 4 | .idea/ 5 | out/ 6 | /BWAPI4J.iml 7 | /BWAPI4J-AP/build/ 8 | *.png 9 | *.log 10 | maps/ 11 | *.mpq 12 | bwapi.ini 13 | 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "BWAPI4JBridge/externals/openbw/bwapi"] 2 | path = BWAPI4JBridge/externals/openbw/bwapi 3 | url = https://github.com/OpenBW/bwapi 4 | [submodule "BWAPI4JBridge/externals/openbw/openbw"] 5 | path = BWAPI4JBridge/externals/openbw/openbw 6 | url = https://github.com/OpenBW/openbw 7 | [submodule "BWAPI4JBridge/externals/bwapi"] 8 | path = BWAPI4JBridge/externals/bwapi 9 | url = https://github.com/bwapi/bwapi 10 | [submodule "BWAPI4JBridge/externals/spdlog"] 11 | path = BWAPI4JBridge/externals/spdlog 12 | url = https://github.com/gabime/spdlog 13 | [submodule "BWAPI4JBridge/externals/bwem/BWEM-community"] 14 | path = BWAPI4JBridge/externals/bwem/BWEM-community 15 | url = https://github.com/n00byedge/bwem-community 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - openjdk8 5 | 6 | os: 7 | - linux 8 | #- osx 9 | 10 | addons: 11 | # sonarcloud: 12 | # branches: 13 | # - dev 14 | # - master 15 | 16 | cache: 17 | directories: 18 | - '$HOME/.m2/repository' 19 | - '$HOME/.sonar/cache' 20 | - '$HOME/.gradle' 21 | - '.gradle' 22 | 23 | env: 24 | - TERM=dumb 25 | 26 | before_install: 27 | - 'if [ ${TRAVIS_OS_NAME} = "linux" ]; then 28 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && 29 | sudo apt-get update -qq && 30 | sudo apt-get -y install g++-6 && 31 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90 && 32 | sudo apt-get -y install libsdl2-dev libegl1-mesa-dev libgles2-mesa-dev; 33 | elif [ ${TRAVIS_OS_NAME} = "osx" ]; then 34 | echo "OSX not yet supported"; 35 | exit 1; 36 | fi' 37 | 38 | script: 39 | - ROOT_PROJ_DIR=$(pwd) 40 | - ./gradlew --stacktrace clean build buildOpenBWBridgeForLinux && ./gradlew --stacktrace sourcesJar javadocJar shadowJar 41 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/ArrayValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | public class ArrayValue { 4 | 5 | private final String amountBy; 6 | private final RValue rValue; 7 | private final String componentType; 8 | 9 | public ArrayValue(String amountBy, RValue rValue, String componentType) { 10 | this.amountBy = amountBy; 11 | this.rValue = rValue; 12 | this.componentType = componentType; 13 | } 14 | 15 | public RValue getRValue() { 16 | return rValue; 17 | } 18 | 19 | public String getAmountBy() { 20 | return amountBy; 21 | } 22 | 23 | public String getComponentType() { 24 | return componentType; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Assignment.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import javax.lang.model.element.Name; 4 | 5 | public class Assignment { 6 | 7 | private final Name field; 8 | private RValue rValue; 9 | private String accessor; 10 | private String indirection; 11 | private Delegate byDelegate; 12 | 13 | Assignment(Name field, RValue rValue, String accessor, String indirection) { 14 | this.field = field; 15 | this.rValue = rValue; 16 | this.accessor = accessor; 17 | this.indirection = indirection; 18 | } 19 | 20 | Assignment(Name field, Delegate byDelegate) { 21 | this.field = field; 22 | this.byDelegate = byDelegate; 23 | } 24 | 25 | public Name getField() { 26 | return field; 27 | } 28 | 29 | public RValue getRValue() { 30 | return rValue; 31 | } 32 | 33 | public Delegate getByDelegate() { 34 | return byDelegate; 35 | } 36 | 37 | public String getAccessor() { 38 | return accessor; 39 | } 40 | 41 | public String getIndirection() { 42 | return indirection; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Assignments.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Assignments { 7 | 8 | private List namedAssignments = new ArrayList<>(); 9 | private List delegatedAssignments = new ArrayList<>(); 10 | private List assignments = new ArrayList<>(); 11 | private List resetAssignments = new ArrayList<>(); 12 | int namedFieldIndex = 0; 13 | 14 | public int getFirstDelegateIndex() { 15 | return namedFieldIndex; 16 | } 17 | 18 | public void addAssignment(Assignment assignment) { 19 | assignments.add(assignment); 20 | } 21 | 22 | public List getAssignments() { 23 | return assignments; 24 | } 25 | 26 | public void addResetAssignment(Assignment assignment) { 27 | resetAssignments.add(assignment); 28 | } 29 | 30 | public List getResetAssignments() { 31 | return resetAssignments; 32 | } 33 | 34 | public void addNamedAssignment(NamedAssignment namedAssignment) { 35 | namedAssignments.add(namedAssignment); 36 | } 37 | 38 | public List getNamedAssignments() { 39 | return namedAssignments; 40 | } 41 | 42 | public void addDelegatedAssignment(Assignment delegatedAssignment) { 43 | delegatedAssignments.add(delegatedAssignment); 44 | } 45 | 46 | public List getDelegatedAssignments() { 47 | return delegatedAssignments; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/BWMappedValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import javax.lang.model.element.Name; 4 | 5 | public class BWMappedValue { 6 | 7 | private final String bwMethod; 8 | private final Name targetType; 9 | 10 | public BWMappedValue(String bwMethod, Name targetType) { 11 | 12 | this.bwMethod = bwMethod; 13 | this.targetType = targetType; 14 | } 15 | 16 | public String getBwMethod() { 17 | return bwMethod; 18 | } 19 | 20 | public Name getTargetType() { 21 | return targetType; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/BridgeValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD, ElementType.CONSTRUCTOR}) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface BridgeValue { 11 | String accessor() default ""; 12 | 13 | String indirection() default ""; 14 | 15 | boolean initializeOnly() default false; 16 | } 17 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Delegate.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.util.Objects; 4 | 5 | public class Delegate { 6 | 7 | private final String fqClassName; 8 | private final String fieldName; 9 | private final Assignments assignments; 10 | 11 | public Delegate(String fqClassName, String fieldName, Assignments assignments) { 12 | this.fqClassName = fqClassName; 13 | this.fieldName = fieldName; 14 | this.assignments = assignments; 15 | } 16 | 17 | public String getFieldName() { 18 | return fieldName; 19 | } 20 | 21 | public String getFqClassName() { 22 | return fqClassName; 23 | } 24 | 25 | public Assignments getAssignments() { 26 | return assignments; 27 | } 28 | 29 | @Override 30 | public boolean equals(Object o) { 31 | if (this == o) { 32 | return true; 33 | } 34 | if (o == null || getClass() != o.getClass()) { 35 | return false; 36 | } 37 | Delegate delegate = (Delegate) o; 38 | return Objects.equals(fqClassName, delegate.fqClassName) 39 | && Objects.equals(fieldName, delegate.fieldName); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | 45 | return Objects.hash(fqClassName, fieldName); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/EnumValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import javax.lang.model.element.Name; 4 | 5 | public class EnumValue { 6 | 7 | private final Name enumName; 8 | 9 | public EnumValue(Name enumName) { 10 | this.enumName = enumName; 11 | } 12 | 13 | public Name getEnumName() { 14 | return enumName; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Indexed.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface Indexed { 11 | 12 | String getAmountBy(); 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/ListValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | public class ListValue { 4 | 5 | private final RValue rValue; 6 | 7 | public ListValue(RValue rValue) { 8 | this.rValue = rValue; 9 | } 10 | 11 | public RValue getRValue() { 12 | return rValue; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/LookedUp.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(ElementType.TYPE) 7 | public @interface LookedUp { 8 | 9 | String method(); 10 | } 11 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/MapValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | public class MapValue { 4 | 5 | private final RValue index; 6 | private final RValue rValue; 7 | 8 | public MapValue(RValue index, RValue rValue) { 9 | this.index = index; 10 | this.rValue = rValue; 11 | } 12 | 13 | public RValue getIndex() { 14 | return index; 15 | } 16 | 17 | public RValue getRValue() { 18 | return rValue; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Named.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface Named { 11 | 12 | String name(); 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/NamedAssignment.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import javax.lang.model.element.Name; 4 | 5 | class NamedAssignment extends Assignment { 6 | 7 | private final String name; 8 | private final int index; 9 | private final boolean initializeOnly; 10 | 11 | NamedAssignment( 12 | Name field, 13 | RValue rValue, 14 | String accessor, 15 | String indirection, 16 | boolean initializeOnly, 17 | String name, 18 | int index) { 19 | super(field, rValue, accessor, indirection); 20 | this.name = name; 21 | this.index = index; 22 | this.initializeOnly = initializeOnly; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public int getIndex() { 30 | return index; 31 | } 32 | 33 | public boolean isInitializeOnly() { 34 | return initializeOnly; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/NativeClass.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface NativeClass { 11 | 12 | String name() default ""; 13 | 14 | String parentName() default ""; 15 | 16 | String accessOperator() default "->"; 17 | } 18 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/NewObjectValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.util.List; 4 | import javax.lang.model.element.Name; 5 | 6 | public class NewObjectValue { 7 | 8 | private final Name fqClassName; 9 | private final Name className; 10 | private final List constructorArgs; 11 | private final boolean needsOuterClass; 12 | 13 | NewObjectValue( 14 | Name fqClassName, Name className, List constructorArgs, boolean needsOuterClass) { 15 | this.fqClassName = fqClassName; 16 | this.className = className; 17 | this.constructorArgs = constructorArgs; 18 | this.needsOuterClass = needsOuterClass; 19 | } 20 | 21 | public List getConstructorArgs() { 22 | return constructorArgs; 23 | } 24 | 25 | public Name getFqClassName() { 26 | return fqClassName; 27 | } 28 | 29 | public Name getClassName() { 30 | return className; 31 | } 32 | 33 | public boolean isNeedsOuterClass() { 34 | return needsOuterClass; 35 | } 36 | 37 | public int getDataAmount() { 38 | return constructorArgs.stream().mapToInt(RValue::getDataAmount).sum(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/PrimitiveValue.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.util.Objects; 4 | 5 | public class PrimitiveValue { 6 | 7 | private final String typeName; 8 | 9 | public PrimitiveValue(String typeName) { 10 | Objects.requireNonNull(typeName); 11 | this.typeName = typeName; 12 | } 13 | 14 | public String getTypeName() { 15 | return typeName; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/java/org/openbw/bwapi4j/ap/Reset.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.ap; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface Reset { 11 | 12 | String value(); 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J-AP/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | org.openbw.bwapi4j.ap.BridgeCodeProcessor -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/BWEM.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem; 14 | 15 | import bwem.map.Map; 16 | import bwem.map.MapInitializer; 17 | import bwem.map.MapInitializerImpl; 18 | import org.openbw.bwapi4j.BW; 19 | 20 | public final class BWEM { 21 | private final Map map; 22 | 23 | public BWEM(final BW bw) { 24 | this.map = 25 | new MapInitializerImpl( 26 | bw.getBWMap(), 27 | bw.getMapDrawer(), 28 | bw.getAllPlayers(), 29 | bw.getMineralPatches(), 30 | bw.getVespeneGeysers(), 31 | bw.getAllUnits()); 32 | } 33 | 34 | /** Returns the root internal data container. */ 35 | public Map getMap() { 36 | return this.map; 37 | } 38 | 39 | /** 40 | * Default value for {@code enableTimer} is {@code false}. 41 | * 42 | * @see #initialize() 43 | */ 44 | public void initialize() { 45 | initialize(false); 46 | } 47 | 48 | /** 49 | * Initializes and pre-computes all of the internal data. 50 | * 51 | * @param enableTimer whether to print the elapsed time of each initialization stage 52 | */ 53 | public void initialize(final boolean enableTimer) { 54 | if (!(this.map instanceof MapInitializer)) { 55 | throw new IllegalStateException("BWEM was not instantiated properly."); 56 | } else { 57 | ((MapInitializer) this.map).initialize(enableTimer); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/CheckMode.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem; 14 | 15 | public enum CheckMode { 16 | CHECK, 17 | NO_CHECK 18 | } 19 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/LICENSE.txt: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | // (MIT/X11 License) 5 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 6 | // Permission is hereby granted, free of charge, to any person obtaining a 7 | // copy of this software and associated documentation files (the "Software"), 8 | // to deal in the Software without restriction, including without limitation 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | // and/or sell copies of the Software, and to permit persons to whom the 11 | // Software is furnished to do so, subject to the following conditions: 12 | // - The above copyright notice and this permission notice shall be included 13 | // in all copies or substantial portions of the Software. 14 | // - The Software is provided "as is", without warranty of any kind, express 15 | // or implied, including but not limited to the warranties of merchantability, 16 | // fitness for a particular purpose and noninfringement. In no event shall the 17 | // authors or copyright holders be liable for any claim, damages or 18 | // other liability, whether in an action of contract, tort or otherwise, 19 | // arising from, out of or in connection with the software or the use or other 20 | // dealings in the Software. 21 | // - Except as contained in this notice, the name of the copyright holders 22 | // shall not be used in advertising or otherwise to promote the sale, use or 23 | // other dealings in this Software without prior written authorization from 24 | // the copyright holders. 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/Markable.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem; 14 | 15 | /** 16 | * See original C++ BWEM for an explanation of this code. Do NOT mimic BWEM's C++ inheritance for 17 | * this code. See "src/test/util/OldMarkable.java" for what NOT to do. 18 | */ 19 | public final class Markable { 20 | private final StaticMarkable staticMarkable; 21 | private int lastMark; 22 | 23 | public Markable(final StaticMarkable staticMarkable) { 24 | this.staticMarkable = staticMarkable; 25 | this.lastMark = 0; 26 | } 27 | 28 | private StaticMarkable getStaticMarkable() { 29 | return this.staticMarkable; 30 | } 31 | 32 | public boolean isMarked() { 33 | return (this.lastMark == getStaticMarkable().getCurrentMark()); 34 | } 35 | 36 | public void setMarked() { 37 | this.lastMark = getStaticMarkable().getCurrentMark(); 38 | } 39 | 40 | public void setUnmarked() { 41 | this.lastMark = getStaticMarkable().getCurrentMark() - 1; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/StaticMarkable.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem; 14 | 15 | /** 16 | * See original C++ BWEM for an explanation of this code. Do NOT mimic BWEM's C++ inheritance for 17 | * this code. See "src/test/util/OldMarkable.java" for what NOT to do. 18 | */ 19 | public final class StaticMarkable { 20 | private int currentMark; 21 | 22 | public StaticMarkable() { 23 | this.currentMark = 0; 24 | } 25 | 26 | public int getCurrentMark() { 27 | return this.currentMark; 28 | } 29 | 30 | public void unmarkAll() { 31 | ++this.currentMark; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/area/typedef/AreaId.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.area.typedef; 14 | 15 | import bwem.util.IWrappedInteger; 16 | 17 | /** 18 | * Immutable wrapper of the integer primitive to satisfy the original C++ definition: 19 | * area.h:54:typedef int16_t id; 20 | */ 21 | public final class AreaId implements IWrappedInteger, Comparable { 22 | public static final AreaId UNINITIALIZED = new AreaId(-1); 23 | public static final AreaId ZERO = new AreaId(0); 24 | private final int val; 25 | 26 | public AreaId(final int val) { 27 | this.val = val; 28 | } 29 | 30 | @Override 31 | public int intValue() { 32 | return this.val; 33 | } 34 | 35 | @Override 36 | public int compareTo(final AreaId that) { 37 | return Integer.compare(this.val, that.val); 38 | } 39 | 40 | @Override 41 | public boolean equals(final Object object) { 42 | if (this == object) { 43 | return true; 44 | } else if (!(object instanceof AreaId)) { 45 | return false; 46 | } else { 47 | final AreaId that = (AreaId) object; 48 | return (this.val == that.val); 49 | } 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return this.val; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/area/typedef/GroupId.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.area.typedef; 14 | 15 | import bwem.util.IWrappedInteger; 16 | 17 | /** 18 | * Immutable wrapper of the integer primitive to satisfy the original C++ definition: 19 | * area.h:56:typedef int16_t groupId; 20 | */ 21 | public final class GroupId implements IWrappedInteger, Comparable { 22 | public static final GroupId ZERO = new GroupId(0); 23 | private final int val; 24 | 25 | public GroupId(final int val) { 26 | this.val = val; 27 | } 28 | 29 | @Override 30 | public int intValue() { 31 | return this.val; 32 | } 33 | 34 | @Override 35 | public int compareTo(final GroupId that) { 36 | return Integer.compare(this.val, that.val); 37 | } 38 | 39 | @Override 40 | public boolean equals(final Object object) { 41 | if (this == object) { 42 | return true; 43 | } else if (!(object instanceof GroupId)) { 44 | return false; 45 | } else { 46 | final GroupId that = (GroupId) object; 47 | return (this.val == that.val); 48 | } 49 | } 50 | 51 | @Override 52 | public int hashCode() { 53 | return this.val; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/map/TerrainData.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.map; 14 | 15 | import bwem.CheckMode; 16 | import bwem.tile.MiniTile; 17 | import bwem.tile.Tile; 18 | import bwem.tile.TileData; 19 | import org.openbw.bwapi4j.TilePosition; 20 | import org.openbw.bwapi4j.WalkPosition; 21 | 22 | public interface TerrainData { 23 | MapData getMapData(); 24 | 25 | TileData getTileData(); 26 | 27 | Tile getTile(TilePosition tilePosition, CheckMode checkMode); 28 | 29 | Tile getTile(TilePosition tilePosition); 30 | 31 | MiniTile getMiniTile(WalkPosition walkPosition, CheckMode checkMode); 32 | 33 | MiniTile getMiniTile(WalkPosition walkPosition); 34 | 35 | boolean isSeaWithNonSeaNeighbors(WalkPosition walkPosition); 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/map/TerrainDataInitializer.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.map; 14 | 15 | import bwem.CheckMode; 16 | import bwem.tile.MiniTile; 17 | import bwem.tile.Tile; 18 | import org.openbw.bwapi4j.BWMap; 19 | import org.openbw.bwapi4j.TilePosition; 20 | import org.openbw.bwapi4j.WalkPosition; 21 | 22 | public interface TerrainDataInitializer { 23 | Tile getTile_(TilePosition tilePosition, CheckMode checkMode); 24 | 25 | Tile getTile_(TilePosition tilePosition); 26 | 27 | MiniTile getMiniTile_(WalkPosition walkPosition, CheckMode checkMode); 28 | 29 | MiniTile getMiniTile_(WalkPosition walkPosition); 30 | 31 | void markUnwalkableMiniTiles(BWMap bwMap); 32 | 33 | void markBuildableTilesAndGroundHeight(BWMap bwMap); 34 | 35 | void decideSeasOrLakes(int lakeMaxMiniTiles, int lakeMaxWidthInMiniTiles); 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/tile/TileData.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.tile; 14 | 15 | import java.util.List; 16 | 17 | public interface TileData { 18 | /** Provides access to the internal array of Tiles. */ 19 | List getTiles(); 20 | 21 | /** Provides access to the internal array of miniTiles. */ 22 | List getMiniTiles(); 23 | } 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/tile/TileDataImpl.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.tile; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class TileDataImpl implements TileData { 19 | private final List tiles; 20 | private final List miniTiles; 21 | 22 | public TileDataImpl(final int tileCount, final int miniTileCount) { 23 | this.tiles = new ArrayList<>(tileCount); 24 | for (int i = 0; i < tileCount; ++i) { 25 | this.tiles.add(new TileImpl()); 26 | } 27 | 28 | this.miniTiles = new ArrayList<>(miniTileCount); 29 | for (int i = 0; i < miniTileCount; ++i) { 30 | this.miniTiles.add(new MiniTileImpl()); 31 | } 32 | } 33 | 34 | @Override 35 | public List getTiles() { 36 | return this.tiles; 37 | } 38 | 39 | @Override 40 | public List getMiniTiles() { 41 | return this.miniTiles; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/typedef/Altitude.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.typedef; 14 | 15 | import bwem.util.IWrappedInteger; 16 | 17 | /** 18 | * Immutable wrapper of the integer primitive to satisfy the original C++ definition: 19 | * defs.h:54:typedef int16_t altitude_t; 20 | * 21 | *

Type of the altitudes in pixels. 22 | */ 23 | public final class Altitude implements IWrappedInteger, Comparable { 24 | public static final Altitude UNINITIALIZED = new Altitude(-1); 25 | public static final Altitude ZERO = new Altitude(0); 26 | private final int val; 27 | 28 | public Altitude(final int val) { 29 | this.val = val; 30 | } 31 | 32 | @Override 33 | public int intValue() { 34 | return this.val; 35 | } 36 | 37 | @Override 38 | public int compareTo(final Altitude that) { 39 | return Integer.compare(this.val, that.val); 40 | } 41 | 42 | @Override 43 | public boolean equals(final Object object) { 44 | if (this == object) { 45 | return true; 46 | } else if (!(object instanceof Altitude)) { 47 | return false; 48 | } else { 49 | final Altitude that = (Altitude) object; 50 | return (this.val == that.val); 51 | } 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return this.val; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return String.valueOf(this.val); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/typedef/CPPath.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.typedef; 14 | 15 | import bwem.ChokePoint; 16 | import java.util.ArrayList; 17 | import java.util.Iterator; 18 | import java.util.List; 19 | 20 | /** 21 | * Type of all the Paths used in BWEM (Cf. Map::GetPath). 22 | * 23 | *

cp.h:68:typedef std::vector Path; cp.h:168:typedef ChokePoint::Path 24 | * CPPath; 25 | */ 26 | public class CPPath implements Iterable { 27 | private final List chokepoints; 28 | 29 | public CPPath() { 30 | this.chokepoints = new ArrayList<>(); 31 | } 32 | 33 | public int size() { 34 | return this.chokepoints.size(); 35 | } 36 | 37 | public ChokePoint get(final int index) { 38 | return this.chokepoints.get(index); 39 | } 40 | 41 | public void add(final ChokePoint chokepoint) { 42 | this.chokepoints.add(chokepoint); 43 | } 44 | 45 | public void add(final int index, final ChokePoint chokepoint) { 46 | this.chokepoints.add(index, chokepoint); 47 | } 48 | 49 | public void clear() { 50 | this.chokepoints.clear(); 51 | } 52 | 53 | public boolean isEmpty() { 54 | return this.chokepoints.isEmpty(); 55 | } 56 | 57 | @Override 58 | public Iterator iterator() { 59 | return chokepoints.iterator(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/typedef/Index.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.typedef; 14 | 15 | import bwem.util.IWrappedInteger; 16 | 17 | /** 18 | * Immutable wrapper of the integer primitive to satisfy the original C++ definition: 19 | * cp.h:143:typedef int index; 20 | */ 21 | public final class Index implements IWrappedInteger, Comparable { 22 | private final int val; 23 | 24 | public Index(final int val) { 25 | this.val = val; 26 | } 27 | 28 | public Index add(final int val) { 29 | return new Index(this.val + val); 30 | } 31 | 32 | @Override 33 | public int intValue() { 34 | return this.val; 35 | } 36 | 37 | @Override 38 | public int compareTo(final Index that) { 39 | return Integer.compare(this.val, that.val); 40 | } 41 | 42 | @Override 43 | public boolean equals(final Object object) { 44 | if (this == object) { 45 | return true; 46 | } else if (!(object instanceof Index)) { 47 | return false; 48 | } else { 49 | final Index that = (Index) object; 50 | return (this.val == that.val); 51 | } 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return this.val; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return String.valueOf(this.val); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/typedef/Pred.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.typedef; 14 | 15 | @FunctionalInterface 16 | public interface Pred { 17 | boolean isTrue(final Object... args); 18 | } 19 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/unit/NeutralData.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.unit; 14 | 15 | import java.util.List; 16 | import org.openbw.bwapi4j.unit.Unit; 17 | 18 | public interface NeutralData { 19 | List getMinerals(); 20 | 21 | /** 22 | * If a Mineral wrappers the given BWAPI unit, returns a pointer to it. Otherwise, returns null. 23 | */ 24 | Mineral getMineral(Unit u); 25 | 26 | // Returns a reference to the geysers (Cf. Geyser). 27 | List getGeysers(); 28 | 29 | // If a Geyser wrappers the given BWAPI unit, returns a pointer to it. 30 | // Otherwise, returns nullptr. 31 | Geyser getGeyser(Unit g); 32 | 33 | // Returns a reference to the StaticBuildings (Cf. StaticBuilding). 34 | List getStaticBuildings(); 35 | } 36 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/unit/Resource.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.unit; 14 | 15 | import bwem.map.Map; 16 | import org.openbw.bwapi4j.unit.Unit; 17 | 18 | /** A Resource is either a Mineral or a Geyser. */ 19 | public abstract class Resource extends NeutralImpl { 20 | protected Resource(final Unit unit, final Map map) { 21 | super(unit, map); 22 | } 23 | 24 | /** 25 | * Returns the initial amount of resources for this Resource (same as 26 | * unit()->getInitialResources). 27 | */ 28 | public abstract int getInitialAmount(); 29 | 30 | /** Returns the current amount of resources for this Resource (same as unit()->getResources). */ 31 | public abstract int getAmount(); 32 | 33 | @Override 34 | public boolean equals(final Object object) { 35 | if (this == object) { 36 | return true; 37 | } else if (!(object instanceof Resource)) { 38 | return false; 39 | } else { 40 | final Resource that = (Resource) object; 41 | return (this.getUnit().getId() == that.getUnit().getId()); 42 | } 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return getUnit().hashCode(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/unit/StaticBuilding.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.unit; 14 | 15 | import bwem.map.Map; 16 | import org.openbw.bwapi4j.unit.Unit; 17 | 18 | /** 19 | * StaticBuildings Correspond to the units in BWAPI::getStaticNeutralUnits() for which 20 | * getType().isSpecialBuilding. StaticBuilding also wrappers some special units like 21 | * Special_Pit_Door. 22 | */ 23 | public class StaticBuilding extends NeutralImpl { 24 | public StaticBuilding(final Unit unit, final Map map) { 25 | super(unit, map); 26 | 27 | // TODO 28 | // bwem_assert(Type().isSpecialBuilding() || 29 | // (Type() == Special_Pit_Door) || 30 | // Type() == Special_Right_Pit_Door); 31 | } 32 | 33 | @Override 34 | public boolean equals(final Object object) { 35 | if (this == object) { 36 | return true; 37 | } else if (!(object instanceof StaticBuilding)) { 38 | return false; 39 | } else { 40 | final StaticBuilding that = (StaticBuilding) object; 41 | return (this.getUnit().getId() == that.getUnit().getId()); 42 | } 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return getUnit().hashCode(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/Asserts.java: -------------------------------------------------------------------------------- 1 | package bwem.util; 2 | 3 | public class Asserts { 4 | public static boolean BWEM_ASSERTS = true; 5 | 6 | public static void bwem_assert(final boolean condition, final String message) { 7 | if (BWEM_ASSERTS && !condition) { 8 | if (message != null && !message.isEmpty()) { 9 | throw new BwemException(message); 10 | } else { 11 | throw new BwemException(); 12 | } 13 | } 14 | } 15 | 16 | public static void bwem_assert(final boolean condition) { 17 | bwem_assert(condition, null); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/BwemException.java: -------------------------------------------------------------------------------- 1 | package bwem.util; 2 | 3 | public class BwemException extends RuntimeException { 4 | public BwemException() { 5 | super(); 6 | } 7 | 8 | public BwemException(final String message) { 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/IWrappedInteger.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.util; 14 | 15 | public interface IWrappedInteger { 16 | int intValue(); 17 | 18 | int compareTo(T that); 19 | 20 | boolean equals(Object that); 21 | 22 | int hashCode(); 23 | 24 | String toString(); 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/PairGenericAltitudeComparator.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.util; 14 | 15 | import bwem.typedef.Altitude; 16 | import java.util.Comparator; 17 | import org.apache.commons.lang3.tuple.MutablePair; 18 | 19 | public final class PairGenericAltitudeComparator 20 | implements Comparator> { 21 | @Override 22 | public int compare(MutablePair o1, MutablePair o2) { 23 | int a1 = o1.getRight().intValue(); 24 | int a2 = o2.getRight().intValue(); 25 | return Integer.compare(a1, a2); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/PairGenericMiniTileAltitudeComparator.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.util; 14 | 15 | import bwem.tile.MiniTile; 16 | import java.util.Comparator; 17 | import org.apache.commons.lang3.tuple.MutablePair; 18 | 19 | public final class PairGenericMiniTileAltitudeComparator 20 | implements Comparator> { 21 | @Override 22 | public int compare(MutablePair o1, MutablePair o2) { 23 | int a1 = o1.getRight().getAltitude().intValue(); 24 | int a2 = o2.getRight().getAltitude().intValue(); 25 | return Integer.compare(a1, a2); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/Timer.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.util; 14 | 15 | /** This timer class is similar to the one provided by the original C++ BWEM. */ 16 | public class Timer { 17 | private static final double NANOSECONDS_PER_MILLISECOND = Math.pow(10, 6); 18 | 19 | private long start; 20 | 21 | public Timer() { 22 | reset(); 23 | } 24 | 25 | public void reset() { 26 | this.start = now(); 27 | } 28 | 29 | public double elapsedMilliseconds() { 30 | return ((double) (now() - this.start)) / NANOSECONDS_PER_MILLISECOND; 31 | } 32 | 33 | private long now() { 34 | return System.nanoTime(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/bwem/util/XYCropper.java: -------------------------------------------------------------------------------- 1 | // Original work Copyright (c) 2015, 2017, Igor Dimitrijevic 2 | // Modified work Copyright (c) 2017-2018 OpenBW Team 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // 6 | // This file is part of the BWEM Library. 7 | // BWEM is free software, licensed under the MIT/X11 License. 8 | // A copy of the license is provided with the library in the LICENSE file. 9 | // Copyright (c) 2015, 2017, Igor Dimitrijevic 10 | // 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | package bwem.util; 14 | 15 | public class XYCropper { 16 | private final int minX; 17 | private final int minY; 18 | private final int maxX; 19 | private final int maxY; 20 | 21 | public XYCropper(final int minX, final int minY, final int maxX, final int maxY) { 22 | this.minX = minX; 23 | this.minY = minY; 24 | this.maxX = maxX; 25 | this.maxY = maxY; 26 | } 27 | 28 | public int cropX(int x) { 29 | return (x < this.minX ? this.minX : (x > this.maxX) ? this.maxX : x); 30 | } 31 | 32 | public int cropY(int y) { 33 | return (y < this.minY ? this.minY : (y > this.maxY) ? this.maxY : y); 34 | } 35 | 36 | public int[] crop(int x, int y) { 37 | x = cropX(x); 38 | y = cropY(y); 39 | return new int[] {x, y}; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/BWEventListener.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j; 22 | 23 | import org.openbw.bwapi4j.unit.Unit; 24 | 25 | public interface BWEventListener { 26 | public void onStart(); 27 | 28 | public void onEnd(boolean isWinner); 29 | 30 | public void onFrame(); 31 | 32 | public void onSendText(String text); 33 | 34 | public void onReceiveText(Player player, String text); 35 | 36 | public void onPlayerLeft(Player player); 37 | 38 | public void onNukeDetect(Position target); 39 | 40 | public void onUnitDiscover(Unit unit); 41 | 42 | public void onUnitEvade(Unit unit); 43 | 44 | public void onUnitShow(Unit unit); 45 | 46 | public void onUnitHide(Unit unit); 47 | 48 | public void onUnitCreate(Unit unit); 49 | 50 | public void onUnitDestroy(Unit unit); 51 | 52 | public void onUnitMorph(Unit unit); 53 | 54 | public void onUnitRenegade(Unit unit); 55 | 56 | public void onSaveGame(String gameName); 57 | 58 | public void onUnitComplete(Unit unit); 59 | } 60 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/test/BWDataProvider.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.test; 2 | 3 | public final class BWDataProvider { 4 | 5 | private BWDataProvider() {} 6 | 7 | public static void injectValues() throws Exception { 8 | UnitTypes.initializeUnitType(); 9 | UpgradeTypes.initializeUpgradeType(); 10 | TechTypes.initializeTechType(); 11 | WeaponTypes.initializeWeaponType(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/BwError.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum BwError { 24 | Unit_Does_Not_Exist, 25 | Unit_Not_Visible, 26 | Unit_Not_Owned, 27 | Unit_Busy, 28 | Incompatible_UnitType, 29 | Incompatible_TechType, 30 | Incompatible_State, 31 | Already_Researched, 32 | Fully_Upgraded, 33 | Currently_Researching, 34 | Currently_Upgrading, 35 | Insufficient_Minerals, 36 | Insufficient_Gas, 37 | Insufficient_Supply, 38 | Insufficient_Energy, 39 | Insufficient_Tech, 40 | Insufficient_Ammo, 41 | Insufficient_Space, 42 | Invalid_Tile_Position, 43 | Unbuildable_Location, 44 | Unreachable_Location, 45 | Out_Of_Range, 46 | Unable_To_Hit, 47 | Access_Denied, 48 | File_Not_Found, 49 | Invalid_Parameter, 50 | None, 51 | Unknown; 52 | } 53 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/Color.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum Color implements WithId { 24 | RED(111), 25 | BLUE(165), 26 | TEAL(159), 27 | PURPLE(164), 28 | ORANGE(179), 29 | BROWN(19), 30 | WHITE(255), 31 | YELLOW(135), 32 | GREEN(117), 33 | CYAN(128), 34 | BLACK(0), 35 | GREY(74); 36 | 37 | private int rgb; 38 | 39 | Color(int rgb) { 40 | this.rgb = rgb; 41 | } 42 | 43 | public static Color withId(int id) { 44 | return IdMapper.colorForId[id]; 45 | } 46 | 47 | @Override 48 | public int getId() { 49 | return rgb; 50 | } 51 | 52 | public int getValue() { 53 | return this.rgb; 54 | } 55 | 56 | private static class IdMapper { 57 | 58 | static final Color[] colorForId = IdMapperHelper.toIdTypeArray(Color.class); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/DamageType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum DamageType { 24 | Independent, 25 | Explosive, 26 | Concussive, 27 | Normal, 28 | Ignore_Armor, 29 | None, 30 | Unknown; 31 | 32 | public static DamageType withId(int id) { 33 | return values()[id]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/ExplosionType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum ExplosionType { 24 | None, 25 | Normal, 26 | Radial_Splash, 27 | Enemy_Splash, 28 | Lockdown, 29 | Nuclear_Missile, 30 | Parasite, 31 | Broodlings, 32 | EMP_Shockwave, 33 | Irradiate, 34 | Ensnare, 35 | Plague, 36 | Stasis_Field, 37 | Dark_Swarm, 38 | Consume, 39 | Yamato_Gun, 40 | Restoration, 41 | Disruption_Web, 42 | Corrosive_Acid, 43 | Mind_Control, 44 | Feedback, 45 | Optical_Flare, 46 | Maelstrom, 47 | Unused, 48 | Air_Splash, 49 | Unknown, 50 | MAX; 51 | 52 | public static ExplosionType withId(int id) { 53 | return values()[id]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/GameType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum GameType { 24 | None, 25 | Custom, // Warcraft III 26 | Melee, 27 | Free_For_All, 28 | One_on_One, 29 | Capture_The_Flag, 30 | Greed, 31 | Slaughter, 32 | Sudden_Death, 33 | Ladder, 34 | Use_Map_Settings, 35 | Team_Melee, 36 | Team_Free_For_All, 37 | Team_Capture_The_Flag, 38 | Unknown_0x0E, 39 | Top_vs_Bottom, 40 | Iron_Man_Ladder, // Warcraft II 41 | 42 | // Pro_Gamer_League = 32, // Not valid 43 | // Unknown, 44 | // MAX 45 | } 46 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/IdMapperHelper.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.type; 2 | 3 | import java.lang.reflect.Array; 4 | import java.util.stream.Stream; 5 | 6 | final class IdMapperHelper { 7 | 8 | private IdMapperHelper() {} 9 | 10 | static E[] toIdTypeArray(Class enumClass) { 11 | E[] enumConstants = enumClass.getEnumConstants(); 12 | int maxId = Stream.of(enumConstants).mapToInt(E::getId).max().getAsInt(); 13 | E[] idToType = (E[]) Array.newInstance(enumClass, maxId + 1); 14 | for (E type : enumConstants) { 15 | idToType[type.getId()] = type; 16 | } 17 | return idToType; 18 | } 19 | } 20 | 21 | interface WithId { 22 | 23 | int getId(); 24 | } 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/PlayerType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum PlayerType { 24 | None, 25 | Computer, 26 | Player, 27 | RescuePassive, 28 | RescueActive, 29 | EitherPreferComputer, 30 | EitherPreferHuman, 31 | Neutral, 32 | Closed, 33 | Observer, 34 | PlayerLeft, 35 | ComputerLeft, 36 | Unknown; 37 | 38 | public static PlayerType withId(int id) { 39 | return values()[id]; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/type/UnitSizeType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.type; 22 | 23 | public enum UnitSizeType { 24 | Independent, 25 | Small, 26 | Medium, 27 | Large, 28 | None, 29 | Unknown; 30 | 31 | public static UnitSizeType withId(int id) { 32 | return values()[id]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Addon.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | public interface Addon extends Building { 4 | Building getMainBuilding(); 5 | } 6 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/AddonImpl.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public abstract class AddonImpl extends BuildingImpl implements Addon { 26 | 27 | protected AddonImpl(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | 31 | public Building getMainBuilding() { 32 | return (Building) buildUnit; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/AirAttacker.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Units implementing this interface can attack air units. */ 24 | public interface AirAttacker extends Attacker { 25 | Weapon getAirWeapon(); 26 | 27 | int getAirWeaponMaxRange(); 28 | 29 | int getAirWeaponMaxCooldown(); 30 | 31 | int getAirWeaponCooldown(); 32 | 33 | int getAirWeaponDamage(); 34 | 35 | int getMaxAirHits(); 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Assimilator.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class Assimilator extends GasMiningFacilityImpl implements Mechanical { 26 | 27 | protected Assimilator(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Attacker.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Units implementing this interface can attack. */ 24 | public interface Attacker extends PlayerUnit { 25 | boolean attack(Unit target); 26 | 27 | boolean attack(Unit target, boolean queued); 28 | 29 | Unit getTargetUnit(); 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Broodling.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Broodling extends MobileUnitImpl implements Organic, GroundAttacker { 24 | @Override 25 | public Weapon getGroundWeapon() { 26 | return groundWeapon; 27 | } 28 | 29 | @Override 30 | public int getGroundWeaponMaxRange() { 31 | return super.getGroundWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getGroundWeaponMaxCooldown() { 36 | return super.getGroundWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getGroundWeaponCooldown() { 41 | return super.getGroundWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getGroundWeaponDamage() { 46 | return super.getGroundWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxGroundHits() { 51 | return super.getMaxGroundHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Building.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.Position; 4 | import org.openbw.bwapi4j.TilePosition; 5 | 6 | public interface Building extends PlayerUnit { 7 | boolean cancelConstruction(); 8 | 9 | int getBuildTime(); 10 | 11 | int getRemainingBuildTime(); 12 | 13 | int getProbableConstructionStart(); 14 | 15 | /** 16 | * Returns the distance to given position from where this unit was located when it last was 17 | * visible. 18 | * 19 | * @param position tile position to measure distance to 20 | * @return distance in tiles 21 | */ 22 | int getLastKnownDistance(TilePosition position); 23 | 24 | /** 25 | * Returns the distance to given position from where this unit was located when it last was 26 | * visible. 27 | * 28 | * @param position position to measure distance to 29 | * @return distance in pixels 30 | */ 31 | double getLastKnownDistance(Position position); 32 | 33 | double getLastKnownDistance(Unit target); 34 | } 35 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Burrowable.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for burrowable units. */ 24 | public interface Burrowable extends PlayerUnit { 25 | boolean burrow(); 26 | 27 | boolean unburrow(); 28 | 29 | boolean isBurrowed(); 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Cloakable.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for cloakable units. */ 24 | public interface Cloakable extends PlayerUnit { 25 | boolean cloak(); 26 | 27 | boolean decloak(); 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Cocoon.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.UnitCommandType.Cancel_Morph; 24 | 25 | public class Cocoon extends PlayerUnitImpl implements Organic { 26 | public boolean cancelMorph() { 27 | return issueCommand(this.iD, Cancel_Morph, -1, -1, -1, -1); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/ComsatStation.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.TechType.Scanner_Sweep; 24 | import static org.openbw.bwapi4j.type.UnitCommandType.Use_Tech_Position; 25 | 26 | import org.openbw.bwapi4j.Position; 27 | import org.openbw.bwapi4j.type.UnitType; 28 | 29 | public class ComsatStation extends AddonImpl implements Mechanical, SpellCaster { 30 | 31 | protected ComsatStation(UnitType unitType, int timeSpotted) { 32 | super(unitType, timeSpotted); 33 | } 34 | 35 | public boolean scannerSweep(Position p) { 36 | return issueCommand(this.iD, Use_Tech_Position, -1, p.getX(), p.getY(), Scanner_Sweep.getId()); 37 | } 38 | 39 | @Override 40 | public int getEnergy() { 41 | return this.energy; 42 | } 43 | 44 | @Override 45 | public int getMaxEnergy() { 46 | return super.getMaxEnergy(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Critter.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Critter extends UnitImpl {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/DarkSwarm.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class DarkSwarm extends Spell { 24 | 25 | protected DarkSwarm(int timeSpotted) { 26 | super(timeSpotted); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Detector.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for detectors (detectors can see cloaked units). */ 24 | public interface Detector extends PlayerUnit {} 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Devourer.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Devourer extends MobileUnitImpl implements Organic, AirAttacker { 24 | @Override 25 | public Weapon getAirWeapon() { 26 | return airWeapon; 27 | } 28 | 29 | @Override 30 | public int getAirWeaponMaxRange() { 31 | return super.getAirWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getAirWeaponMaxCooldown() { 36 | return super.getAirWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getAirWeaponCooldown() { 41 | return super.getAirWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getAirWeaponDamage() { 46 | return super.getAirWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxAirHits() { 51 | return super.getMaxAirHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/DisruptionWeb.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class DisruptionWeb extends Spell { 24 | 25 | protected DisruptionWeb(int timeSpotted) { 26 | super(timeSpotted); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Drone.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.UnitCommandType.Burrow; 24 | import static org.openbw.bwapi4j.type.UnitCommandType.Morph; 25 | import static org.openbw.bwapi4j.type.UnitCommandType.Unburrow; 26 | 27 | import org.openbw.bwapi4j.type.UnitType; 28 | 29 | public class Drone extends Worker implements Organic, Burrowable, Morphable { 30 | public boolean burrow() { 31 | return issueCommand(this.iD, Burrow, -1, -1, -1, -1); 32 | } 33 | 34 | @Override 35 | public boolean unburrow() { 36 | return issueCommand(this.iD, Unburrow, -1, -1, -1, -1); 37 | } 38 | 39 | @Override 40 | public boolean isBurrowed() { 41 | return this.burrowed; 42 | } 43 | 44 | @Override 45 | public boolean morph(UnitType type) { 46 | return issueCommand(this.iD, Morph, -1, -1, -1, type.getId()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Dropship.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Dropship extends Transporter implements Mechanical {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Egg.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.UnitCommandType.Cancel_Morph; 24 | 25 | import org.openbw.bwapi4j.type.UnitType; 26 | 27 | public class Egg extends PlayerUnitImpl implements Organic { 28 | public boolean cancelMorph() { 29 | return issueCommand(this.iD, Cancel_Morph, -1, -1, -1, -1); 30 | } 31 | 32 | public UnitType getBuildType() { 33 | return buildType; 34 | } 35 | 36 | public int getRemainingMorphTime() { 37 | return remainingBuildTime; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/ExtendibleByAddon.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | /** Units implementing this can have an addon. */ 26 | public interface ExtendibleByAddon extends Building { 27 | boolean build(UnitType addon); 28 | 29 | boolean cancelAddon(); 30 | 31 | Addon getAddon(); 32 | 33 | default boolean isBuildingAddon() { 34 | return getAddon() != null && !getAddon().isCompleted(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Extractor.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class Extractor extends GasMiningFacilityImpl implements Organic { 26 | 27 | protected Extractor(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/FlyingBuilding.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.Position; 24 | 25 | public interface FlyingBuilding extends Building { 26 | boolean lift(); 27 | 28 | boolean land(Position p); 29 | 30 | boolean move(Position p); 31 | 32 | boolean isLifted(); 33 | } 34 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/GasMiningFacility.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public interface GasMiningFacility extends Building, Gatherable { 24 | public int getResources(); 25 | 26 | public int getInitialResources(); 27 | 28 | public boolean isBeingGathered(); 29 | } 30 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/GasMiningFacilityImpl.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.type.UnitType; 4 | 5 | public abstract class GasMiningFacilityImpl extends BuildingImpl implements GasMiningFacility { 6 | 7 | protected GasMiningFacilityImpl(UnitType unitType, int timeSpotted) { 8 | super(unitType, timeSpotted); 9 | } 10 | 11 | @Override 12 | public int getResources() { 13 | return this.resources; 14 | } 15 | 16 | @Override 17 | public int getInitialResources() { 18 | return this.initialResources; 19 | } 20 | 21 | @Override 22 | public boolean isBeingGathered() { 23 | return this.beingGathered; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Gatherable.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public interface Gatherable extends Unit { 24 | int getId(); 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/GreaterSpire.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class GreaterSpire extends Spire implements Organic, ResearchingFacility { 26 | 27 | protected GreaterSpire(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/GroundAttacker.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Units implementing this interface can attack ground units. */ 24 | public interface GroundAttacker extends Attacker { 25 | Weapon getGroundWeapon(); 26 | 27 | int getGroundWeaponMaxRange(); 28 | 29 | int getGroundWeaponMaxCooldown(); 30 | 31 | int getGroundWeaponCooldown(); 32 | 33 | int getGroundWeaponDamage(); 34 | 35 | int getMaxGroundHits(); 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Guardian.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Guardian extends MobileUnitImpl implements Organic, GroundAttacker { 24 | @Override 25 | public Weapon getGroundWeapon() { 26 | return groundWeapon; 27 | } 28 | 29 | @Override 30 | public int getGroundWeaponMaxRange() { 31 | return super.getGroundWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getGroundWeaponMaxCooldown() { 36 | return super.getGroundWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getGroundWeaponCooldown() { 41 | return super.getGroundWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getGroundWeaponDamage() { 46 | return super.getGroundWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxGroundHits() { 51 | return super.getMaxGroundHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Hive.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class Hive extends Lair { 26 | 27 | protected Hive(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | 31 | @Override 32 | public boolean morph(UnitType type) { 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Larva.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.UnitCommandType.Morph; 24 | 25 | import org.openbw.bwapi4j.type.UnitType; 26 | 27 | public class Larva extends PlayerUnitImpl implements Organic, Morphable { 28 | public Hatchery getHatchery() { 29 | return (Hatchery) hatchery; 30 | } 31 | 32 | @Override 33 | public boolean morph(UnitType type) { 34 | return issueCommand(this.iD, Morph, -1, -1, -1, type.getId()); 35 | } 36 | 37 | /** 38 | * Returns a {@link org.openbw.bwapi4j.unit.UnitImpl.TrainingSlot} if this larva is about to morph 39 | * or null if not. 40 | */ 41 | public TrainingSlot getTrainingSlot() { 42 | return trainingQueue.isEmpty() ? null : trainingQueue.get(0); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Loadable.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import java.util.List; 24 | 25 | public interface Loadable extends PlayerUnit { 26 | boolean isLoaded(); 27 | 28 | boolean load(MobileUnit target); 29 | 30 | /** 31 | * Loads target unit into this transporter. 32 | * 33 | * @param target unit to load 34 | * @param queued true if command is queued 35 | * @return true is command successful, false else 36 | */ 37 | boolean load(MobileUnit target, boolean queued); 38 | 39 | boolean unload(MobileUnit target); 40 | 41 | boolean unloadAll(); 42 | 43 | boolean unloadAll(boolean queued); 44 | 45 | int getSpaceRemaining(); 46 | 47 | List getLoadedUnits(); 48 | } 49 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/LurkerEgg.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class LurkerEgg extends Egg {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Mechanical.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for mechanical units. */ 24 | public interface Mechanical extends PlayerUnit {} 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/MineralPatch.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class MineralPatch extends UnitImpl implements Resource, Gatherable { 24 | @Override 25 | public int getResources() { 26 | return this.resources; 27 | } 28 | 29 | @Override 30 | public int getInitialResources() { 31 | return this.initialResources; 32 | } 33 | 34 | @Override 35 | public int getLastKnownResources() { 36 | return this.lastKnownResources; 37 | } 38 | 39 | @Override 40 | public boolean isBeingGathered() { 41 | return this.beingGathered; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/MobileUnit.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.Position; 4 | import org.openbw.bwapi4j.ap.LookedUp; 5 | 6 | @LookedUp(method = "getUnit") 7 | public interface MobileUnit extends PlayerUnit { 8 | 9 | boolean attack(Position p); 10 | 11 | boolean attack(Position p, boolean queued); 12 | 13 | boolean attack(Unit target); 14 | 15 | boolean attack(Unit target, boolean queued); 16 | 17 | boolean move(Position p); 18 | 19 | boolean move(Position p, boolean queued); 20 | 21 | boolean patrol(Position p); 22 | 23 | boolean patrol(Position p, boolean queued); 24 | 25 | boolean holdPosition(); 26 | 27 | boolean holdPosition(boolean queued); 28 | 29 | boolean stop(boolean queued); 30 | 31 | boolean follow(Unit target, boolean queued); 32 | 33 | int getAcidSporeCount(); 34 | 35 | Loadable getTransport(); 36 | 37 | boolean isFollowing(); 38 | 39 | boolean isHoldingPosition(); 40 | 41 | boolean isStasised(); 42 | 43 | boolean isUnderDarkSwarm(); 44 | 45 | boolean isUnderDisruptionWeb(); 46 | 47 | boolean isUnderStorm(); 48 | 49 | boolean isParasited(); 50 | 51 | boolean isPatrolling(); 52 | 53 | boolean isPlagued(); 54 | 55 | boolean isMoving(); 56 | 57 | Position getTargetPosition(); 58 | 59 | Unit getTargetUnit(); 60 | 61 | int getTurnRadius(); 62 | 63 | boolean isStuck(); 64 | 65 | int getSupplyRequired(); 66 | 67 | boolean isHallucination(); 68 | 69 | boolean isBlind(); 70 | 71 | boolean isBraking(); 72 | 73 | boolean isDefenseMatrixed(); 74 | 75 | boolean isEnsnared(); 76 | 77 | double getTopSpeed(); 78 | } 79 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Morphable.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | /** Interface for units that can morph (many Zerg units can). */ 26 | public interface Morphable extends PlayerUnit { 27 | /** 28 | * Morphs this unit into the given unit type. Be aware that "this" object will be obsolete after 29 | * the call and a new object with the same {@link Unit#getId()} will be created. 30 | * 31 | * @param type the target type to morph to 32 | * @return true if the morph command was successfully delivered to Broodwar, false if the command 33 | * was denied (for example due to missing supply or resources). 34 | * @throws IllegalArgumentException if the given type is invalid for this unit 35 | */ 36 | boolean morph(UnitType type); 37 | } 38 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/NuclearMissile.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class NuclearMissile extends PlayerUnitImpl {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/NuclearSilo.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class NuclearSilo extends AddonImpl implements Mechanical { 26 | 27 | protected NuclearSilo(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | 31 | public boolean hasNuke() { 32 | return this.hasNuke; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Observer.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Observer extends MobileUnitImpl implements Robotic, Detector, Mechanical, Cloakable { 24 | @Override 25 | public boolean cloak() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public boolean decloak() { 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Organic.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for organic units. */ 24 | public interface Organic extends PlayerUnit {} 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Overlord.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Overlord extends Transporter implements Organic, Detector, SupplyProvider { 24 | @Override 25 | public int supplyProvided() { 26 | return type.supplyProvided(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Probe.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Probe extends Worker implements Mechanical, Robotic {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Pylon.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class Pylon extends BuildingImpl implements Mechanical, SupplyProvider { 26 | 27 | protected Pylon(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | 31 | @Override 32 | public int supplyProvided() { 33 | return type.supplyProvided(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/RawUnitFactory.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.type.UnitType; 4 | 5 | public class RawUnitFactory extends UnitFactory { 6 | @Override 7 | public UnitImpl createUnit(int unitId, UnitType unitType, int timeSpotted) { 8 | return new RawUnit(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Reaver.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import static org.openbw.bwapi4j.type.UnitCommandType.Train; 24 | import static org.openbw.bwapi4j.type.UnitType.Protoss_Scarab; 25 | 26 | public class Reaver extends MobileUnitImpl implements Mechanical { 27 | public int getScarabCount() { 28 | return this.scarabCount; 29 | } 30 | 31 | public boolean trainScarab() { 32 | return issueCommand(iD, Train, Protoss_Scarab.getId(), -1, -1, -1); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Refinery.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class Refinery extends GasMiningFacilityImpl implements Mechanical { 26 | 27 | protected Refinery(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Resource.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public interface Resource extends Unit { 24 | int getResources(); 25 | 26 | int getInitialResources(); 27 | 28 | int getLastKnownResources(); 29 | 30 | boolean isBeingGathered(); 31 | } 32 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/ResourceDepot.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for main bases and expansions. */ 24 | public interface ResourceDepot extends Building, SupplyProvider { 25 | /** Returns true if workers can deliver resources. Ie. it's completed, not flying, ... */ 26 | boolean isReadyForResources(); 27 | 28 | boolean trainWorker(); 29 | } 30 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Robotic.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for robotic units. */ 24 | public interface Robotic extends PlayerUnit {} 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/ScannerSweep.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class ScannerSweep extends Spell { 24 | 25 | protected ScannerSweep(int timeSpotted) { 26 | super(timeSpotted); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Scarab.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Scarab extends MobileUnitImpl implements Mechanical {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Scourge.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Scourge extends MobileUnitImpl implements Organic, AirAttacker { 24 | @Override 25 | public Weapon getAirWeapon() { 26 | return airWeapon; 27 | } 28 | 29 | @Override 30 | public int getAirWeaponMaxRange() { 31 | return super.getAirWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getAirWeaponMaxCooldown() { 36 | return super.getAirWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getAirWeaponCooldown() { 41 | return super.getAirWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getAirWeaponDamage() { 46 | return super.getAirWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxAirHits() { 51 | return super.getMaxAirHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Shuttle.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Shuttle extends Transporter implements Mechanical, Robotic {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SpecialBuilding.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class SpecialBuilding extends BuildingImpl { 26 | 27 | protected SpecialBuilding(int id, UnitType type, UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SpecialUnit.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class SpecialUnit extends PlayerUnitImpl {} 24 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Spell.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public abstract class Spell extends PlayerUnitImpl { 24 | protected int timeSpotted; 25 | 26 | protected Spell(int timeSpotted) { 27 | this.timeSpotted = timeSpotted; 28 | } 29 | 30 | public int getTimeSpotted() { 31 | return this.timeSpotted; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SpellCaster.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Marker interface for spell casters. */ 24 | public interface SpellCaster extends PlayerUnit { 25 | int getEnergy(); 26 | 27 | int getMaxEnergy(); 28 | } 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SpiderMine.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class SpiderMine extends PlayerUnitImpl { 24 | public boolean isBurrowed() { 25 | return burrowed; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SupplyDepot.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.type.UnitType; 24 | 25 | public class SupplyDepot extends BuildingImpl implements Mechanical, SupplyProvider { 26 | 27 | protected SupplyDepot(UnitType unitType, int timeSpotted) { 28 | super(unitType, timeSpotted); 29 | } 30 | 31 | @Override 32 | public int supplyProvided() { 33 | return type.supplyProvided(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/SupplyProvider.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** Interface for units providing supply (Overlord,...) */ 24 | public interface SupplyProvider extends PlayerUnit { 25 | int supplyProvided(); 26 | } 27 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/TrainingFacility.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import java.util.List; 24 | import org.openbw.bwapi4j.Position; 25 | import org.openbw.bwapi4j.type.UnitType; 26 | 27 | public interface TrainingFacility extends Building { 28 | boolean isTraining(); 29 | 30 | List getTrainingQueue(); 31 | 32 | int getRemainingTrainTime(); 33 | 34 | boolean train(UnitType type); 35 | 36 | boolean canTrain(UnitType type); 37 | 38 | boolean cancelTrain(int slot); 39 | 40 | boolean cancelTrain(); 41 | 42 | boolean setRallyPoint(Position p); 43 | 44 | boolean setRallyPoint(Unit target); 45 | } 46 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Ultralisk.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Ultralisk extends MobileUnitImpl implements Organic, GroundAttacker { 24 | @Override 25 | public Weapon getGroundWeapon() { 26 | return groundWeapon; 27 | } 28 | 29 | @Override 30 | public int getGroundWeaponMaxRange() { 31 | return super.getGroundWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getGroundWeaponMaxCooldown() { 36 | return super.getGroundWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getGroundWeaponCooldown() { 41 | return super.getGroundWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getGroundWeaponDamage() { 46 | return super.getGroundWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxGroundHits() { 51 | return super.getMaxGroundHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/UnsupportedUnitException.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class UnsupportedUnitException extends RuntimeException { 24 | private static final long serialVersionUID = 1L; 25 | 26 | public UnsupportedUnitException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Valkyrie.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Valkyrie extends MobileUnitImpl implements Mechanical, AirAttacker { 24 | @Override 25 | public Weapon getAirWeapon() { 26 | return airWeapon; 27 | } 28 | 29 | @Override 30 | public int getAirWeaponMaxRange() { 31 | return super.getAirWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getAirWeaponMaxCooldown() { 36 | return super.getAirWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getAirWeaponCooldown() { 41 | return super.getAirWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getAirWeaponDamage() { 46 | return super.getAirWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxAirHits() { 51 | return super.getMaxAirHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/VespeneGeyser.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | /** VespeneGeyser is not Gatherable, it needs a {@link GasMiningFacility}. */ 24 | public class VespeneGeyser extends UnitImpl implements Resource { 25 | @Override 26 | public int getResources() { 27 | return this.resources; 28 | } 29 | 30 | @Override 31 | public int getInitialResources() { 32 | return this.initialResources; 33 | } 34 | 35 | @Override 36 | public int getLastKnownResources() { 37 | return this.lastKnownResources; 38 | } 39 | 40 | @Override 41 | public boolean isBeingGathered() { 42 | return this.beingGathered; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Weapon.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | import org.openbw.bwapi4j.ap.BridgeValue; 24 | import org.openbw.bwapi4j.ap.Named; 25 | import org.openbw.bwapi4j.ap.NativeClass; 26 | import org.openbw.bwapi4j.type.WeaponType; 27 | 28 | /** Holds information for a ground/air weapon. */ 29 | @NativeClass(parentName = "BWAPI::Unit") 30 | public class Weapon { 31 | 32 | @BridgeValue(indirection = "type", initializeOnly = true) 33 | @Named(name = "TYPE") 34 | WeaponType type; 35 | 36 | @BridgeValue int cooldown; 37 | 38 | public Weapon(WeaponType type, int cooldown) { 39 | this.type = type; 40 | this.cooldown = cooldown; 41 | } 42 | 43 | public int cooldown() { 44 | return cooldown; 45 | } 46 | 47 | public WeaponType type() { 48 | return type; 49 | } 50 | 51 | public int maxRange() { 52 | return type.maxRange(); 53 | } 54 | 55 | public int maxCooldown() { 56 | return type.damageCooldown(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/unit/Zealot.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.unit; 22 | 23 | public class Zealot extends MobileUnitImpl implements Organic, GroundAttacker { 24 | @Override 25 | public Weapon getGroundWeapon() { 26 | return groundWeapon; 27 | } 28 | 29 | @Override 30 | public int getGroundWeaponMaxRange() { 31 | return super.getGroundWeaponMaxRange(); 32 | } 33 | 34 | @Override 35 | public int getGroundWeaponMaxCooldown() { 36 | return super.getGroundWeaponMaxCooldown(); 37 | } 38 | 39 | @Override 40 | public int getGroundWeaponCooldown() { 41 | return super.getGroundWeaponCooldown(this); 42 | } 43 | 44 | @Override 45 | public int getGroundWeaponDamage() { 46 | return super.getGroundWeaponDamage(); 47 | } 48 | 49 | @Override 50 | public int getMaxGroundHits() { 51 | return super.getMaxGroundHits(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/util/BridgeUtils.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.util; 22 | 23 | public class BridgeUtils { 24 | public static final double parsePreservedDouble(final int i) { 25 | return ((double) i) / 128.0; 26 | } 27 | 28 | /** 29 | * BWAPI 4.2.0: 30 | * https://github.com/bwapi/bwapi/blob/59b14af21b3c881ce06af8b1ea1d63fa3c8b2df0/bwapi/BWAPI/Source/BWAPI/UnitUpdate.cpp#L206-L212 31 | * https://github.com/bwapi/bwapi/blob/59b14af21b3c881ce06af8b1ea1d63fa3c8b2df0/bwapi/BWAPI/Source/BWAPI/BulletImpl.cpp#L93-L97 32 | */ 33 | public static final double parsePreservedBwapiAngle(final double angle) { 34 | return (angle * Math.PI / 128d); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/org/openbw/bwapi4j/util/system/OSType.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package org.openbw.bwapi4j.util.system; 22 | 23 | import java.util.Locale; 24 | 25 | /** 26 | * A small set of enums defining what type of system you are running on. 27 | * 28 | *

The default type means that it is likely to be a *nix. 29 | */ 30 | public enum OSType { 31 | DEFAULT, 32 | MAC, 33 | WINDOWS; 34 | 35 | /** 36 | * @return The type of OS. 37 | *

http://lopica.sourceforge.net/os.html is a source of the various values from {@code 38 | * os.name}. 39 | */ 40 | public static OSType computeType() { 41 | final String osName = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); 42 | 43 | if (osName.contains("win")) { 44 | return WINDOWS; 45 | } else if (osName.contains("mac")) { 46 | return MAC; 47 | } else { 48 | return DEFAULT; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/java/yata/MapPrinter.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | package yata; 22 | 23 | import java.awt.*; 24 | import java.awt.image.BufferedImage; 25 | import java.io.IOException; 26 | import java.nio.file.Path; 27 | import javax.imageio.ImageIO; 28 | import org.openbw.bwapi4j.TilePosition; 29 | import org.openbw.bwapi4j.WalkPosition; 30 | 31 | public class MapPrinter { 32 | private final BufferedImage image; 33 | private final Graphics2D g2d; 34 | 35 | public MapPrinter(final TilePosition mapSize) { 36 | this.image = 37 | new BufferedImage(mapSize.getX() * 4, mapSize.getY() * 4, BufferedImage.TYPE_INT_RGB); 38 | this.g2d = image.createGraphics(); 39 | } 40 | 41 | public void Point(final WalkPosition position, final Color color) { 42 | g2d.setColor(color); 43 | g2d.fillRect(position.getX(), position.getY(), 5, 5); 44 | } 45 | 46 | public void writeImageToFile(Path file) throws IOException { 47 | ImageIO.write(this.image, "png", file.toFile()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /BWAPI4J/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/MarkableClassA.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | public class MarkableClassA { 4 | private static final StaticMarkable staticMarkable = new StaticMarkable(); 5 | private final Markable markable; 6 | 7 | private final int val; 8 | 9 | public MarkableClassA(final int val) { 10 | this.markable = new Markable(staticMarkable); 11 | this.val = val; 12 | } 13 | 14 | public static StaticMarkable getStaticMarkable() { 15 | return staticMarkable; 16 | } 17 | 18 | public Markable getMarkable() { 19 | return this.markable; 20 | } 21 | 22 | public int intValue() { 23 | return this.val; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/MarkableClassB.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | public class MarkableClassB { 4 | private static final StaticMarkable staticMarkable = new StaticMarkable(); 5 | private final Markable markable; 6 | 7 | private final int val; 8 | 9 | public MarkableClassB(final int val) { 10 | this.markable = new Markable(staticMarkable); 11 | this.val = val; 12 | } 13 | 14 | public static StaticMarkable getStaticMarkable() { 15 | return staticMarkable; 16 | } 17 | 18 | public Markable getMarkable() { 19 | return this.markable; 20 | } 21 | 22 | public int intValue() { 23 | return this.val; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/OldMarkable.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | public class OldMarkable { 4 | private int lastMark; 5 | private static int currentMark = 0; 6 | 7 | public OldMarkable() { 8 | lastMark = 0; 9 | } 10 | 11 | public boolean Marked() { 12 | return (lastMark == currentMark); 13 | } 14 | 15 | public void SetMarked() { 16 | lastMark = currentMark; 17 | } 18 | 19 | public void SetUnmarked() { 20 | lastMark = currentMark - 1; 21 | } 22 | 23 | public static void UnmarkAll() { 24 | ++currentMark; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/OldMarkableClassA.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | public class OldMarkableClassA extends OldMarkable { 4 | private final int id; 5 | 6 | public OldMarkableClassA(final int id) { 7 | this.id = id; 8 | } 9 | 10 | public int getId() { 11 | return this.id; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/OldMarkableClassB.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | public class OldMarkableClassB extends OldMarkable { 4 | private final int id; 5 | 6 | public OldMarkableClassB(final int id) { 7 | this.id = id; 8 | } 9 | 10 | public int getId() { 11 | return this.id; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/OldMarkableTest.java: -------------------------------------------------------------------------------- 1 | package bwem; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.junit.Assert; 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | 9 | public class OldMarkableTest { 10 | /** This test fails which is the reason for the new "Markable" approach. */ 11 | @Ignore 12 | @Test 13 | public void testMarkable() { 14 | final int maxElements = 6; 15 | 16 | OldMarkableClassA.UnmarkAll(); 17 | final List a; 18 | a = new ArrayList<>(); 19 | for (int i = 0; i < maxElements; ++i) { 20 | OldMarkableClassA markable = new OldMarkableClassA(i); 21 | if (i == 0 || i == 1 || i == 2) { 22 | markable.SetMarked(); 23 | } 24 | a.add(markable); 25 | } 26 | 27 | OldMarkableClassB.UnmarkAll(); 28 | final List b; 29 | b = new ArrayList<>(); 30 | for (int i = 0; i < maxElements; ++i) { 31 | OldMarkableClassB markable = new OldMarkableClassB(i); 32 | if (i == 3 || i == 4 || i == 5) { 33 | markable.SetMarked(); 34 | } 35 | b.add(markable); 36 | } 37 | 38 | for (int i = 0; i < maxElements; ++i) { 39 | OldMarkableClassA markable = a.get(i); 40 | if (i == 0 || i == 1 || i == 2) { 41 | Assert.assertEquals("index=" + i, true, markable.Marked()); 42 | } else { 43 | Assert.assertEquals("index=" + i, false, markable.Marked()); 44 | } 45 | } 46 | 47 | for (int i = 0; i < maxElements; ++i) { 48 | OldMarkableClassB markable = b.get(i); 49 | if (i == 3 || i == 4 || i == 5) { 50 | Assert.assertEquals("index=" + i, true, markable.Marked()); 51 | } else { 52 | Assert.assertEquals("index=" + i, false, markable.Marked()); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/bwem/util/PairGenericAltitudeComparatorTest.java: -------------------------------------------------------------------------------- 1 | package bwem.util; 2 | 3 | import bwem.typedef.Altitude; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | import org.apache.commons.lang3.tuple.MutablePair; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.openbw.bwapi4j.WalkPosition; 11 | 12 | public class PairGenericAltitudeComparatorTest { 13 | @Test 14 | public void testPairGenericAltitudeComparator() { 15 | final List> list = new ArrayList<>(); 16 | 17 | list.add(new MutablePair<>(new WalkPosition(4, 2), new Altitude(1))); 18 | list.add(new MutablePair<>(new WalkPosition(15, 9), new Altitude(2))); 19 | list.add(new MutablePair<>(new WalkPosition(17, 8), new Altitude(4))); 20 | list.add(new MutablePair<>(new WalkPosition(127, 0), new Altitude(5))); 21 | list.add(new MutablePair<>(new WalkPosition(78, 301), new Altitude(3))); 22 | 23 | // Sort by ascending order. 24 | Collections.sort(list, new PairGenericAltitudeComparator<>()); 25 | 26 | Assert.assertEquals(new MutablePair<>(new WalkPosition(4, 2), new Altitude(1)), list.get(0)); 27 | Assert.assertEquals(new MutablePair<>(new WalkPosition(15, 9), new Altitude(2)), list.get(1)); 28 | Assert.assertEquals(new MutablePair<>(new WalkPosition(78, 301), new Altitude(3)), list.get(2)); 29 | Assert.assertEquals(new MutablePair<>(new WalkPosition(17, 8), new Altitude(4)), list.get(3)); 30 | Assert.assertEquals(new MutablePair<>(new WalkPosition(127, 0), new Altitude(5)), list.get(4)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/mockdata/BWAPI_MapInfo.java: -------------------------------------------------------------------------------- 1 | package mockdata; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | import org.openbw.bwapi4j.TilePosition; 6 | 7 | /** Class for parsing map info from a dummy data set. */ 8 | public class BWAPI_MapInfo { 9 | private final String mapHash; 10 | private final TilePosition mapSize; 11 | private final String mapName; 12 | private final String mapFilename; 13 | 14 | public BWAPI_MapInfo(final String mapHash, final String dataSetBwapiVersion) throws IOException { 15 | this.mapHash = mapHash; 16 | 17 | final List> mapInfo = 18 | DummyDataUtils.readMultiLinesAsStringTokensFromArchiveFile( 19 | DummyDataUtils.compileBwapiDataSetArchiveFilename("MapInfo", dataSetBwapiVersion), 20 | mapHash, 21 | " "); 22 | 23 | final StringBuilder mapFilename = new StringBuilder(); 24 | for (final String token : mapInfo.get(1)) { 25 | mapFilename.append(token); 26 | } 27 | this.mapFilename = mapFilename.toString(); 28 | 29 | final StringBuilder mapName = new StringBuilder(); 30 | for (final String token : mapInfo.get(2)) { 31 | mapName.append(token); 32 | } 33 | this.mapName = mapName.toString(); 34 | 35 | final int x = Integer.parseInt(mapInfo.get(3).get(0)); 36 | final int y = Integer.parseInt(mapInfo.get(3).get(1)); 37 | this.mapSize = new TilePosition(x, y); 38 | } 39 | 40 | public String getMapHash() { 41 | return this.mapHash; 42 | } 43 | 44 | public int getMapTileWidth() { 45 | return this.mapSize.getX(); 46 | } 47 | 48 | public int getMapTileHeight() { 49 | return this.mapSize.getY(); 50 | } 51 | 52 | public String getMapDisplayName() { 53 | return this.mapName; 54 | } 55 | 56 | public String getMapFilename() { 57 | return this.mapFilename; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/WalkPositionTest.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | public class WalkPositionTest { 9 | @Test 10 | public void testArrayListContains() { 11 | final List list = new ArrayList<>(); 12 | list.add(new WalkPosition(0, 0)); 13 | list.add(new WalkPosition(24, 87)); 14 | list.add(new WalkPosition(48, 39)); 15 | list.add(new WalkPosition(361, 92)); 16 | list.add(new WalkPosition(510, 6)); 17 | 18 | Assert.assertTrue(list.contains(new WalkPosition(0, 0))); 19 | Assert.assertTrue(list.contains(new WalkPosition(24, 87))); 20 | Assert.assertTrue(list.contains(new WalkPosition(48, 39))); 21 | Assert.assertTrue(list.contains(new WalkPosition(361, 92))); 22 | Assert.assertTrue(list.contains(new WalkPosition(510, 6))); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/type/UpgradeTypeTest.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.type; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | public class UpgradeTypeTest { 9 | @Test 10 | public void listContainsTest() { 11 | final List upgradeTypes = new ArrayList<>(); 12 | 13 | upgradeTypes.add(UpgradeType.Terran_Infantry_Weapons); 14 | upgradeTypes.add(UpgradeType.Terran_Infantry_Armor); 15 | upgradeTypes.add(UpgradeType.U_238_Shells); 16 | 17 | Assert.assertTrue(upgradeTypes.contains(UpgradeType.Terran_Infantry_Weapons)); 18 | Assert.assertTrue(upgradeTypes.contains(UpgradeType.Terran_Infantry_Armor)); 19 | Assert.assertTrue(upgradeTypes.contains(UpgradeType.U_238_Shells)); 20 | 21 | Assert.assertFalse(upgradeTypes.contains(UpgradeType.Zerg_Flyer_Attacks)); 22 | Assert.assertFalse(upgradeTypes.contains(UpgradeType.Adrenal_Glands)); 23 | Assert.assertFalse(upgradeTypes.contains(UpgradeType.Charon_Boosters)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/unit/BuildingMock.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.Position; 4 | import org.openbw.bwapi4j.TilePosition; 5 | import org.openbw.bwapi4j.type.UnitType; 6 | 7 | public class BuildingMock extends BuildingImpl { 8 | public BuildingMock( 9 | int id, 10 | UnitType type, 11 | int timeSpotted, 12 | final TilePosition lastKnownTilePosition, 13 | final Position lastKnownPosition) { 14 | super(type, timeSpotted); 15 | this.iD = id; 16 | this.lastKnownTilePosition = lastKnownTilePosition; 17 | this.lastKnownPosition = lastKnownPosition; 18 | this.completed = true; 19 | this.hitPoints = maxHitPoints(); 20 | this.shields = maxShields(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/unit/MineralPatchMock.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import bwem.util.BwemExt; 4 | import org.openbw.bwapi4j.Position; 5 | import org.openbw.bwapi4j.TilePosition; 6 | import org.openbw.bwapi4j.type.UnitType; 7 | 8 | public class MineralPatchMock extends MineralPatch implements Resource, Gatherable { 9 | private final int initialResources; 10 | private final TilePosition tilePosition; 11 | 12 | public MineralPatchMock(int id, int initialResources, final TilePosition tilePosition) { 13 | this.iD = id; 14 | this.initialResources = initialResources; 15 | this.tilePosition = tilePosition; 16 | } 17 | 18 | @Override 19 | public int getResources() { 20 | throw new UnsupportedOperationException(); 21 | } 22 | 23 | @Override 24 | public int getInitialResources() { 25 | return this.initialResources; 26 | } 27 | 28 | @Override 29 | public int getLastKnownResources() { 30 | throw new UnsupportedOperationException(); 31 | } 32 | 33 | @Override 34 | public boolean isBeingGathered() { 35 | throw new UnsupportedOperationException(); 36 | } 37 | 38 | @Override 39 | public TilePosition getTilePosition() { 40 | return this.tilePosition; 41 | } 42 | 43 | @Override 44 | public TilePosition getInitialTilePosition() { 45 | return this.tilePosition; 46 | } 47 | 48 | @Override 49 | public Position getInitialPosition() { 50 | return BwemExt.centerOfBuilding( 51 | getInitialTilePosition(), UnitType.Resource_Mineral_Field.tileSize()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/unit/UnitMock.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import org.openbw.bwapi4j.type.UnitType; 4 | 5 | public class UnitMock extends UnitImpl { 6 | public UnitMock(int id, UnitType unitType) { 7 | this.iD = id; 8 | this.type = unitType; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/java/org/openbw/bwapi4j/unit/VespeneGeyserMock.java: -------------------------------------------------------------------------------- 1 | package org.openbw.bwapi4j.unit; 2 | 3 | import bwem.util.BwemExt; 4 | import org.openbw.bwapi4j.Position; 5 | import org.openbw.bwapi4j.TilePosition; 6 | import org.openbw.bwapi4j.type.UnitType; 7 | 8 | public class VespeneGeyserMock extends VespeneGeyser implements Resource { 9 | private final int initialResources; 10 | private final TilePosition tilePosition; 11 | 12 | public VespeneGeyserMock(int id, int initialResources, final TilePosition tilePosition) { 13 | this.iD = id; 14 | this.initialResources = initialResources; 15 | this.tilePosition = tilePosition; 16 | } 17 | 18 | @Override 19 | public int getResources() { 20 | throw new UnsupportedOperationException(); 21 | } 22 | 23 | @Override 24 | public int getInitialResources() { 25 | return this.initialResources; 26 | } 27 | 28 | @Override 29 | public int getLastKnownResources() { 30 | throw new UnsupportedOperationException(); 31 | } 32 | 33 | @Override 34 | public boolean isBeingGathered() { 35 | throw new UnsupportedOperationException(); 36 | } 37 | 38 | @Override 39 | public TilePosition getTilePosition() { 40 | return this.tilePosition; 41 | } 42 | 43 | @Override 44 | public TilePosition getInitialTilePosition() { 45 | return this.tilePosition; 46 | } 47 | 48 | @Override 49 | public Position getInitialPosition() { 50 | return BwemExt.centerOfBuilding( 51 | getInitialTilePosition(), UnitType.Resource_Mineral_Field.tileSize()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_MapInfo_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_MapInfo_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_Neutrals_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_Neutrals_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_getGroundHeight_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_getGroundHeight_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_getStartLocations_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_getStartLocations_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_isBuildable_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_isBuildable_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwapiData_isWalkable_BWAPI-4.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwapiData_isWalkable_BWAPI-4.2.0.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwemData_Bases_Minerals_Geysers_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwemData_Bases_Minerals_Geysers_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwemData_CPPathSamples_1_Node_Min_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwemData_CPPathSamples_1_Node_Min_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwemData_ChokePoints_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwemData_ChokePoints_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4J/src/test/resources/mockdata/DummyBwemData_MiniTileAltitudes_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/BWAPI4J/src/test/resources/mockdata/DummyBwemData_MiniTileAltitudes_BWAPI-4.2.0_BWEM-1.4.1.tar.bz2 -------------------------------------------------------------------------------- /BWAPI4JBridge/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | if (OPENBW) 4 | set(PROJECT_NAME OpenBWAPI4JBridge) 5 | else() 6 | set(PROJECT_NAME BWAPI4JBridge) 7 | endif() 8 | 9 | project(${PROJECT_NAME}) 10 | 11 | include(${CMAKE_CURRENT_LIST_DIR}/flags.cmake) 12 | 13 | if (BWAPI4JBRIDGE_ENABLE_LOGGER) 14 | add_definitions(-DBWAPI4JBRIDGE_ENABLE_LOGGER) 15 | endif() 16 | 17 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 18 | include(${CMAKE_CURRENT_LIST_DIR}/externals.cmake) 19 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi4j.cmake) 20 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi4jbridge.cmake) 21 | include(${CMAKE_CURRENT_LIST_DIR}/spdlog_inc.cmake) 22 | include(${CMAKE_CURRENT_LIST_DIR}/jni_inc.cmake) 23 | include(${CMAKE_CURRENT_LIST_DIR}/ap_inc.cmake) 24 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi_inc.cmake) 25 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi_lib.cmake) 26 | include(${CMAKE_CURRENT_LIST_DIR}/externals/bwem/bwem_inc.cmake) 27 | include(${CMAKE_CURRENT_LIST_DIR}/externals/bwem/bwem_lib.cmake) 28 | -------------------------------------------------------------------------------- /BWAPI4JBridge/ap_inc.cmake: -------------------------------------------------------------------------------- 1 | if (NOT AP_INC_CMAKE_INCLUDE) 2 | set(JNI_AP_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi4j.cmake) 6 | 7 | if_unset_then_set(BWAPI4J_AP_INC_DIR ${BWAPI4J_DIR}/build/generated/source/apt/main) 8 | include_directories(${BWAPI4J_AP_INC_DIR}) 9 | 10 | endif() -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bridge_openbw_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #if [ -f ../../../BWTA2/Makefile ]; then 4 | # cd ../../../BWTA2/ && \ 5 | # make && \ 6 | # cp -f Release/*.so ../BWAPI4J/BWAPI4JBridge/BWAPI4JBridge/Release/ && \ 7 | # cd ../BWAPI4J/BWAPI4JBridge/BWAPI4JBridge/ 8 | #fi 9 | 10 | TARGET_BUILD_DIRECTORY="build_openbw_linux" 11 | 12 | if [ ! -d $TARGET_BUILD_DIRECTORY ]; then 13 | mkdir $TARGET_BUILD_DIRECTORY 14 | fi 15 | 16 | cd $TARGET_BUILD_DIRECTORY && \ 17 | cmake .. -DOPENBW=1 -DOPENBW_ENABLE_UI=1 -DBWAPI4JBRIDGE_ENABLE_LOGGER=1 && \ 18 | make 19 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bridge_openbw_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIR=build_openbw_windows 3 | set TARGET_BUILD_SOLUTION=OpenBWAPI4JBridge.sln 4 | 5 | IF NOT EXIST %TARGET_BUILD_DIR% ( 6 | mkdir %TARGET_BUILD_DIR% 7 | ) 8 | 9 | cd %TARGET_BUILD_DIR% 10 | cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW=1 -DOPENBW_DIR=../externals/openbw/openbw -DOPENBW_ENABLE_UI=1 -DBWAPI4JBRIDGE_ENABLE_LOGGER=1 11 | 12 | IF EXIST %TARGET_BUILD_SOLUTION% ( 13 | %DEV_CMD_BAT% 14 | MSBuild.exe %TARGET_BUILD_SOLUTION% /p:Configuration=Release 15 | ) 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bridge_vanilla_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIR=build_vanilla_windows 3 | set TARGET_BUILD_SOLUTION=BWAPI4JBridge.sln 4 | 5 | IF NOT EXIST %TARGET_BUILD_DIR% ( 6 | mkdir %TARGET_BUILD_DIR% 7 | ) 8 | 9 | cd %TARGET_BUILD_DIR% 10 | cmake .. -DBWAPI4JBRIDGE_ENABLE_LOGGER=1 11 | 12 | IF EXIST %TARGET_BUILD_SOLUTION% ( 13 | %DEV_CMD_BAT% 14 | MSBuild.exe %TARGET_BUILD_SOLUTION% /p:Configuration=Release 15 | ) 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwapi_openbw_linux.sh: -------------------------------------------------------------------------------- 1 | TARGET_BUILD_DIRECTORY="externals/openbw/bwapi/build" 2 | 3 | if [ ! -d $TARGET_BUILD_DIRECTORY ]; then 4 | mkdir $TARGET_BUILD_DIRECTORY 5 | fi 6 | 7 | cd $TARGET_BUILD_DIRECTORY && \ 8 | cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI=1 && \ 9 | make 10 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwapi_openbw_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\..\\..\\..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIRECTORY="externals\\openbw\\bwapi\\build" 3 | set TARGET_SOLUTION="BWAPI.sln" 4 | 5 | IF NOT EXIST %TARGET_BUILD_DIRECTORY% ( 6 | mkdir %TARGET_BUILD_DIRECTORY% 7 | ) 8 | 9 | cd %TARGET_BUILD_DIRECTORY% 10 | cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI=1 -DSDL2_INCLUDE_DIR=%SDL2_INCLUDE_DIR% -DSDL2_LIBRARY=%SDL2_LIBRARY% 11 | 12 | IF EXIST %TARGET_SOLUTION% ( 13 | %DEV_CMD_BAT% 14 | msbuild %TARGET_SOLUTION% /p:Configuration=Release 15 | ) 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwapi_vanilla_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\..\\..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIRECTORY="externals\\bwapi\\bwapi" 3 | set TARGET_SOLUTION="BWAPI.sln" 4 | 5 | cd %TARGET_BUILD_DIRECTORY% 6 | 7 | IF EXIST %TARGET_SOLUTION% ( 8 | %DEV_CMD_BAT% 9 | msbuild %TARGET_SOLUTION% /t:BWAPI;BWAPIClient /p:Configuration=Release_Pipeline 10 | ) 11 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwem_openbw_linux.sh: -------------------------------------------------------------------------------- 1 | TARGET_BUILD_DIRECTORY="externals/bwem/build_openbw_linux" 2 | 3 | if [ ! -d $TARGET_BUILD_DIRECTORY ]; then 4 | mkdir $TARGET_BUILD_DIRECTORY 5 | fi 6 | 7 | cd $TARGET_BUILD_DIRECTORY && \ 8 | cmake .. -DOPENBW=1 && \ 9 | make 10 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwem_openbw_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\..\\..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIR="externals\\bwem\\build_openbw_windows" 3 | set TARGET_BUILD_SOLUTION=OpenBWEM.sln 4 | 5 | IF NOT EXIST %TARGET_BUILD_DIR% ( 6 | mkdir %TARGET_BUILD_DIR% 7 | ) 8 | 9 | cd %TARGET_BUILD_DIR% 10 | cmake .. -DOPENBW=1 11 | 12 | IF EXIST %TARGET_BUILD_SOLUTION% ( 13 | %DEV_CMD_BAT% 14 | MSBuild.exe %TARGET_BUILD_SOLUTION% /p:Configuration=Release 15 | ) 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/build_bwem_vanilla_windows.bat: -------------------------------------------------------------------------------- 1 | set DEV_CMD_BAT="..\\..\\..\\VsDevCmd.bat" 2 | set TARGET_BUILD_DIR="externals\\bwem\\build_vanilla_windows" 3 | set TARGET_BUILD_SOLUTION=BWEM.sln 4 | 5 | IF NOT EXIST %TARGET_BUILD_DIR% ( 6 | mkdir %TARGET_BUILD_DIR% 7 | ) 8 | 9 | cd %TARGET_BUILD_DIR% 10 | cmake .. 11 | 12 | IF EXIST %TARGET_BUILD_SOLUTION% ( 13 | %DEV_CMD_BAT% 14 | MSBuild.exe %TARGET_BUILD_SOLUTION% /p:Configuration=Release 15 | ) 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/bwapi4j.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWAPI4J_CMAKE_INCLUDE) 2 | set(BWAPI4J_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | 6 | if_unset_then_set(BWAPI4J_DIR ${CMAKE_CURRENT_LIST_DIR}/../BWAPI4J) 7 | 8 | endif() 9 | -------------------------------------------------------------------------------- /BWAPI4JBridge/bwapi4jbridge.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWAPI4JBRIDGE_CMAKE_INCLUDE) 2 | set(BWAPI4JBRIDGE_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | 6 | if_unset_then_set(BWAPI4JBRIDGE_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src) 7 | 8 | file(GLOB_RECURSE BWAPI4JBRIDGE_SRCS 9 | ${BWAPI4JBRIDGE_SRC_DIR}/*.h 10 | ${BWAPI4JBRIDGE_SRC_DIR}/*.cpp 11 | ) 12 | 13 | add_library(${PROJECT_NAME} SHARED ${BWAPI4JBRIDGE_SRCS}) 14 | 15 | endif() 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/bwapi_inc.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWAPI_INC_CMAKE_INCLUDE) 2 | set(BWAPI_INC_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/externals.cmake) 6 | 7 | if (OPENBW) 8 | 9 | add_definitions(-DOPENBW) 10 | 11 | if (OPENBW_ENABLE_UI) 12 | add_definitions(-DOPENBW_ENABLE_UI) 13 | endif() 14 | 15 | if_unset_then_set(OPENBW_UPPER_DIR ${BWAPI4JBRIDGE_EXT_DIR}/openbw) 16 | if_unset_then_set(OPENBW_DIR ${OPENBW_UPPER_DIR}/openbw) 17 | if_unset_then_set(OPENBW_BWAPI_DIR ${OPENBW_UPPER_DIR}/bwapi) 18 | 19 | include_directories( 20 | ${OPENBW_DIR} 21 | ${OPENBW_BWAPI_DIR}/bwapi/OpenBWData 22 | ${OPENBW_BWAPI_DIR}/bwapi/include 23 | ${OPENBW_BWAPI_DIR}/bwapi/BWAPI/Source 24 | ${OPENBW_BWAPI_DIR}/bwapi/Util/Source 25 | ${OPENBW_BWAPI_DIR}/bwapi/BWAPICore 26 | ) 27 | 28 | else() 29 | 30 | if_unset_then_set(BWAPI_ROOT_DIR ${BWAPI4JBRIDGE_EXT_DIR}/bwapi) 31 | if_unset_then_set(BWAPI_DIR ${BWAPI_ROOT_DIR}/bwapi) 32 | if_unset_then_set(BWAPI_INC_DIR ${BWAPI_DIR}/include) 33 | 34 | include_directories(${BWAPI_INC_DIR}) 35 | 36 | endif() 37 | 38 | endif() 39 | -------------------------------------------------------------------------------- /BWAPI4JBridge/bwapi_lib.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWAPI_LIB_CMAKE_INCLUDE) 2 | set(BWAPI_LIB_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi_inc.cmake) 6 | 7 | if (OPENBW) 8 | 9 | if (MSVC) 10 | if_unset_then_set(OPENBW_LIB_DIR ${OPENBW_BWAPI_DIR}/build/lib/Release) 11 | else() 12 | if_unset_then_set(OPENBW_LIB_DIR ${OPENBW_BWAPI_DIR}/build/lib) 13 | endif() 14 | 15 | find_library(OpenBWData_LIB NAMES OpenBWData PATHS ${OPENBW_LIB_DIR} NO_DEFAULT_PATH) 16 | find_library(BWAPI_LIB NAMES BWAPI PATHS ${OPENBW_LIB_DIR} NO_DEFAULT_PATH) 17 | find_library(BWAPILIB_LIB NAMES BWAPILIB PATHS ${OPENBW_LIB_DIR} NO_DEFAULT_PATH) 18 | 19 | target_link_libraries(${PROJECT_NAME} 20 | ${OpenBWData_LIB} 21 | ${BWAPI_LIB} 22 | ${BWAPILIB_LIB} 23 | ) 24 | 25 | if (OPENBW_ENABLE_UI) 26 | find_library(openbw_ui_LIB NAMES openbw_ui PATHS ${OPENBW_LIB_DIR} NO_DEFAULT_PATH) 27 | target_link_libraries(${PROJECT_NAME} ${openbw_ui_LIB}) 28 | endif() 29 | 30 | else() 31 | 32 | if_unset_then_set(BWAPI_LIB_DIR ${BWAPI_DIR}/Release) 33 | 34 | find_library(BWAPI_LIB NAMES BWAPILIB PATHS ${BWAPI_LIB_DIR} NO_DEFAULT_PATH) 35 | find_library(BWAPIClient_LIB NAMES BWAPIClient PATHS ${BWAPI_LIB_DIR} NO_DEFAULT_PATH) 36 | 37 | target_link_libraries(${PROJECT_NAME} 38 | ${BWAPI_LIB} 39 | ${BWAPIClient_LIB} 40 | ) 41 | 42 | endif() 43 | 44 | endif() 45 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals.cmake: -------------------------------------------------------------------------------- 1 | if (NOT EXTERNALS_CMAKE_INCLUDE) 2 | set(EXTERNALS_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | 6 | if_unset_then_set(BWAPI4JBRIDGE_EXT_DIR ${CMAKE_CURRENT_LIST_DIR}/externals) 7 | 8 | endif() 9 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals/bwem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | if (OPENBW) 4 | set(PROJECT_NAME OpenBWEM) 5 | else() 6 | set(PROJECT_NAME BWEM) 7 | endif() 8 | 9 | project(${PROJECT_NAME}) 10 | 11 | include(${CMAKE_CURRENT_LIST_DIR}/../../flags.cmake) 12 | include(${CMAKE_CURRENT_LIST_DIR}/bwem.cmake) 13 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals/bwem/bwem.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWEM_CMAKE_INCLUDE) 2 | set(BWEM_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/../../func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/../../bwapi_inc.cmake) 6 | include(${CMAKE_CURRENT_LIST_DIR}/bwem_defs.cmake) 7 | 8 | file(GLOB_RECURSE BWEM_SRCS 9 | ${BWEM_SRC_DIR}/*.cpp 10 | ) 11 | add_library(${PROJECT_NAME} STATIC ${BWEM_SRCS}) 12 | 13 | include(${CMAKE_CURRENT_LIST_DIR}/bwem_inc.cmake) 14 | 15 | endif() 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals/bwem/bwem_defs.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWEM_DEFS_CMAKE_INCLUDE) 2 | set(BWEM_DEFS_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/../../func.cmake) 5 | 6 | if_unset_then_set(BWEM_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/BWEM-community/BWEM) 7 | if_unset_then_set(BWEM_INC_DIR ${BWEM_ROOT_DIR}/include) 8 | if_unset_then_set(BWEM_SRC_DIR ${BWEM_ROOT_DIR}/src) 9 | if_unset_then_set(BWEM_LIB_DIR ${BWEM_ROOT_DIR}/../../Release) 10 | 11 | endif() 12 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals/bwem/bwem_inc.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWEM_INC_CMAKE_INCLUDE) 2 | set(BWEM_INC_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/../../func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/bwem_defs.cmake) 6 | 7 | include_directories(${BWEM_INC_DIR}) 8 | 9 | endif() 10 | -------------------------------------------------------------------------------- /BWAPI4JBridge/externals/bwem/bwem_lib.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BWEM_LIB_CMAKE_INCLUDE) 2 | set(BWEM_LIB_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/../../func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/bwem_defs.cmake) 6 | 7 | if (OPENBW) 8 | find_library(BWEM_LIB NAMES OpenBWEM PATHS ${BWEM_LIB_DIR} NO_DEFAULT_PATH) 9 | else() 10 | find_library(BWEM_LIB NAMES BWEM PATHS ${BWEM_LIB_DIR} NO_DEFAULT_PATH) 11 | endif() 12 | 13 | target_link_libraries(${PROJECT_NAME} ${BWEM_LIB}) 14 | 15 | endif() 16 | -------------------------------------------------------------------------------- /BWAPI4JBridge/flags.cmake: -------------------------------------------------------------------------------- 1 | if (NOT COMPILER_FLAGS_CMAKE_INCLUDE) 2 | set(COMPILER_FLAGS_CMAKE_INCLUDE 1) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 6 | 7 | if(NOT CMAKE_BUILD_TYPE) 8 | set(CMAKE_BUILD_TYPE Release) 9 | endif() 10 | 11 | if (MSVC) 12 | add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DWIN32 -D_WIN32 -D_WINDOWS -D_USRDLL) 13 | 14 | if (NOT OPENBW AND CMAKE_BUILD_TYPE MATCHES Release) 15 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG") 16 | endif() 17 | 18 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/..") 19 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/..") 20 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/..") 21 | else() 22 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g") 23 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -fPIC") 24 | 25 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../Release") 26 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../Release") 27 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../Release") 28 | endif() 29 | 30 | endif() 31 | -------------------------------------------------------------------------------- /BWAPI4JBridge/formatting.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FORMATTER_BIN=clang-format 4 | FORMATTER_TARGET_DIR=src/ 5 | 6 | if [ -x "$(command -v $FORMATTER_BIN)" ]; then 7 | echo Running \`$FORMATTER_BIN\' in directory \`$FORMATTER_TARGET_DIR\' 8 | find $FORMATTER_TARGET_DIR -type f -exec $FORMATTER_BIN -style=file -i {} \; 9 | else 10 | echo error: $FORMATTER_BIN not found. Please run manually or install it on your system. >&2 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /BWAPI4JBridge/func.cmake: -------------------------------------------------------------------------------- 1 | if (NOT FUNC_CMAKE_INCLUDE) 2 | set(FUNC_CMAKE_INCLUDE 1) 3 | 4 | # If the specified variable is not set, then set it to the specified value. 5 | function(if_unset_then_set var val) 6 | if (NOT ${var}) 7 | set(${var} ${val} PARENT_SCOPE) 8 | endif() 9 | endfunction() 10 | 11 | # Throw FATAL_ERROR if the specified directory does not exist. 12 | #function(check_dir_exists dir) 13 | # if (NOT EXISTS ${dir} OR NOT IS_DIRECTORY ${dir}) 14 | # message(FATAL_ERROR "Directory not found: ${dir}") 15 | # endif() 16 | #endfunction() 17 | 18 | # If the specified variable is not set, then set it to the specified directory and check if it exists. 19 | #function(if_unset_then_dir var dir) 20 | # if (NOT ${var}) 21 | # check_dir_exists(${dir}) 22 | # set(${var} ${dir}) 23 | # endif() 24 | #endfunction() 25 | 26 | endif() 27 | -------------------------------------------------------------------------------- /BWAPI4JBridge/jni_inc.cmake: -------------------------------------------------------------------------------- 1 | if (NOT JNI_INC_CMAKE_INCLUDE) 2 | set(JNI_INC_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/bwapi4j.cmake) 6 | 7 | if_unset_then_set(BWAPI4J_JNI_INC_DIR ${BWAPI4J_DIR}/src/native/include) 8 | include_directories(${BWAPI4J_JNI_INC_DIR}) 9 | 10 | find_package(JNI REQUIRED) 11 | include_directories(${JNI_INCLUDE_DIRS}) 12 | 13 | endif() 14 | -------------------------------------------------------------------------------- /BWAPI4JBridge/spdlog_inc.cmake: -------------------------------------------------------------------------------- 1 | if (NOT SPDLOG_INC_CMAKE_INCLUDE) 2 | set(SPDLOG_INC_CMAKE_INCLUDE 1) 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/func.cmake) 5 | 6 | if_unset_then_set(SPDLOG_INC_DIR ${BWAPI4JBRIDGE_EXT_DIR}/spdlog/include) 7 | include_directories(${SPDLOG_INC_DIR}) 8 | 9 | endif() 10 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/BWAPILauncher.cpp: -------------------------------------------------------------------------------- 1 | #ifdef OPENBW 2 | 3 | #include "BWAPILauncher.h" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "BW/BWData.h" 11 | #include "BWAPI/GameImpl.h" 12 | 13 | #include "Globals.h" 14 | 15 | void Bridge::BWAPILauncher::run(JNIEnv *env) { 16 | std::thread mainThread([] { 17 | BW::sacrificeThreadForUI([] { 18 | while (!Bridge::Globals::finished) std::this_thread::sleep_for(std::chrono::seconds(5)); 19 | }); 20 | }); 21 | 22 | try { 23 | BW::GameOwner gameOwner; 24 | 25 | gameOwner.setPrintTextCallback([](const char *str) { 26 | std::string s; 27 | while (*str) { 28 | char c = *str++; 29 | if ((unsigned)c >= 0x20 || c == 9 || c == 10 || c == 13) s += c; 30 | } 31 | printf("%s\n", s.c_str()); 32 | }); 33 | 34 | BW::Game game = gameOwner.getGame(); 35 | BWAPI::BroodwarImpl_handle handle(game); 36 | 37 | do { 38 | handle->autoMenuManager.startGame(); 39 | 40 | while (!handle->bwgame.gameOver()) { 41 | handle->update(); 42 | handle->bwgame.nextFrame(); 43 | 44 | if (!handle->externalModuleConnected) { 45 | std::cerr << "error: no module loaded, exiting" << std::endl; 46 | if (env->ExceptionOccurred()) { 47 | env->ExceptionDescribe(); 48 | } 49 | return; 50 | } 51 | } 52 | handle->update(); 53 | handle->onGameEnd(); 54 | handle->bwgame.leaveGame(); 55 | 56 | } while (!handle->bwgame.gameClosed() && handle->autoMenuManager.autoMenuRestartGame != "" && handle->autoMenuManager.autoMenuRestartGame != "OFF"); 57 | } catch (const std::exception &e) { 58 | printf("Error: %s\n", e.what()); 59 | } 60 | Bridge::Globals::finished = true; 61 | 62 | mainThread.join(); 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/BWAPILauncher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef OPENBW 4 | 5 | #include 6 | 7 | namespace Bridge { 8 | namespace BWAPILauncher { 9 | void run(JNIEnv *env); 10 | } // namespace BWAPILauncher 11 | } // namespace Bridge 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/BridgeEnum.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "JavaRefs.h" 26 | 27 | class BridgeEnum { 28 | public: 29 | void addUpgradeTypeEnums(); 30 | void addTechTypeEnums(); 31 | void addWeaponTypeEnums(); 32 | void addUnitTypeEnums(); 33 | }; 34 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/BridgeMap.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "JavaRefs.h" 26 | 27 | class BridgeMap { 28 | public: 29 | void initialize(JNIEnv *env, jobject bw, const JavaRefs &javaRefs); 30 | }; 31 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/Callbacks.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | struct Callbacks { 29 | jmethodID preFrameCallback; 30 | jmethodID onStartCallback; 31 | jmethodID onEndCallback; 32 | jmethodID onFrameCallback; 33 | jmethodID onSendTextCallback; 34 | jmethodID onReceiveTextCallback; 35 | jmethodID onPlayerLeftCallback; 36 | jmethodID onNukeDetectCallback; 37 | jmethodID onUnitDiscoverCallback; 38 | jmethodID onUnitEvadeCallback; 39 | jmethodID onUnitShowCallback; 40 | jmethodID onUnitHideCallback; 41 | jmethodID onUnitCreateCallback; 42 | jmethodID onUnitDestroyCallback; 43 | jmethodID onUnitMorphCallback; 44 | jmethodID onUnitRenegadeCallback; 45 | jmethodID onUnitCompleteCallback; 46 | jmethodID onSaveGameCallback; 47 | 48 | void initialize(JNIEnv *, jclass); 49 | 50 | void processEvents(JNIEnv *, jobject, const std::list &); 51 | }; 52 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/Globals.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #include "Globals.h" 22 | 23 | #include "BridgeEnum.h" 24 | #include "BridgeMap.h" 25 | 26 | namespace Bridge { 27 | namespace Globals { 28 | bool finished = false; 29 | DataBuffer dataBuffer; 30 | JavaRefs javaRefs; 31 | Callbacks callbacks; 32 | JNIEnv *env; 33 | jobject bw; 34 | 35 | void initialize(JNIEnv *newEnv, jobject newBW) { 36 | env = newEnv; 37 | bw = newBW; 38 | 39 | javaRefs.initialize(env); 40 | 41 | callbacks.initialize(env, Bridge::Globals::javaRefs.bwClass); 42 | } 43 | 44 | void initializeGame(JNIEnv *env, jobject bw) { 45 | BridgeMap bwMap; 46 | bwMap.initialize(env, bw, Bridge::Globals::javaRefs); 47 | } 48 | } // namespace Globals 49 | } // namespace Bridge 50 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/Globals.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "Callbacks.h" 26 | #include "DataBuffer.h" 27 | #include "JavaRefs.h" 28 | 29 | namespace Bridge { 30 | namespace Globals { 31 | extern bool finished; 32 | extern DataBuffer dataBuffer; 33 | extern JavaRefs javaRefs; 34 | extern Callbacks callbacks; 35 | extern JNIEnv *env; 36 | extern jobject bw; 37 | 38 | void initialize(JNIEnv *env, jobject bw); 39 | 40 | void initializeGame(JNIEnv *env, jobject bw); 41 | } // namespace Globals 42 | } // namespace Bridge 43 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/JavaRefs.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #include "JavaRefs.h" 22 | 23 | #include "Logger.h" 24 | 25 | void JavaRefs::initialize(JNIEnv *env) { 26 | LOGGER("Initializing Java references..."); 27 | 28 | listClass = env->FindClass("java/util/List"); 29 | listClass_add = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z"); 30 | 31 | tilePositionClass = env->FindClass("org/openbw/bwapi4j/TilePosition"); 32 | tilePositionConstructor = env->GetMethodID(tilePositionClass, "", "(II)V"); 33 | 34 | bwClass = env->FindClass("org/openbw/bwapi4j/BW"); 35 | 36 | bwMapClass = env->FindClass("org/openbw/bwapi4j/BWMapImpl"); 37 | 38 | LOGGER("Initializing Java references... done"); 39 | } -------------------------------------------------------------------------------- /BWAPI4JBridge/src/JavaRefs.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | struct JavaRefs { 26 | jclass listClass; 27 | jmethodID listClass_add; 28 | 29 | jclass tilePositionClass; 30 | jmethodID tilePositionConstructor; 31 | 32 | jclass bwClass; 33 | 34 | jclass bwMapClass; 35 | 36 | void initialize(JNIEnv *); 37 | }; 38 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/JniBwem.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #include "JniBwem.h" 22 | 23 | namespace Bridge { 24 | JniBwem::JniBwem() {} 25 | 26 | void JniBwem::initialize(BWAPI::Game *game) { getMap().Initialize(game); } 27 | 28 | BWEM::Map &JniBwem::getMap() { return BWEM::Map::Instance(); } 29 | 30 | JniBwem bwem; 31 | } // namespace Bridge 32 | 33 | JNIEXPORT void JNICALL Java_bwem_map_MapInitializerImpl_initialize_1native(JNIEnv *, jobject) { Bridge::bwem.initialize(BWAPI::BroodwarPtr); } 34 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/JniBwem.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "bwem_map_MapInitializerImpl.h" 26 | 27 | namespace Bridge { 28 | class JniBwem { 29 | public: 30 | JniBwem(); 31 | 32 | void initialize(BWAPI::Game *game); 33 | BWEM::Map &getMap(); 34 | 35 | private: 36 | }; 37 | 38 | extern JniBwem bwem; 39 | } // namespace Bridge 40 | -------------------------------------------------------------------------------- /BWAPI4JBridge/src/Unit.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2017-2018 OpenBW Team 4 | // 5 | // This file is part of BWAPI4J. 6 | // 7 | // BWAPI4J is free software: you can redistribute it and/or modify 8 | // it under the terms of the Lesser GNU General Public License as published 9 | // by the Free Software Foundation, version 3 only. 10 | // 11 | // BWAPI4J is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with BWAPI4J. If not, see . 18 | // 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | #include 22 | 23 | #include "org_openbw_bwapi4j_unit_UnitImpl.h" 24 | 25 | JNIEXPORT jboolean JNICALL Java_org_openbw_bwapi4j_unit_UnitImpl_issueCommand(JNIEnv *, jobject, jint unitID, jint unitCommandTypeID, jint targetUnitID, jint x, 26 | jint y, jint extra) { 27 | BWAPI::Unit unit = BWAPI::Broodwar->getUnit(unitID); 28 | if (unit) { 29 | BWAPI::UnitCommand c = BWAPI::UnitCommand(); 30 | c.unit = unit; 31 | c.type = unitCommandTypeID; 32 | c.target = BWAPI::Broodwar->getUnit(targetUnitID); 33 | c.x = x; 34 | c.y = y; 35 | c.extra = extra; 36 | return c.unit->issueCommand(c); 37 | } 38 | return JNI_FALSE; 39 | } 40 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to BWAPI4J 2 | 3 | Thanks for considering to contribute! All contributions are welcome provided they have a reasonable purpose. 4 | 5 | ## Submitting Your Changes 6 | 7 | * [Fork the project](https://help.github.com/articles/fork-a-repo/) and [submit a pull request](https://help.github.com/articles/about-pull-requests/) with your change. 8 | * If this is your first time contributing, also add your name and/or GitHub username profile link to the `CREDITS.md` file. 9 | 10 | ## Reporting a Bug or Requesting a Feature 11 | 12 | Please use our [GitHub Issues](https://github.com/OpenBW/BWAPI4J/issues) section to submit a bug, question, or new feature idea. 13 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.8.3b build {build} 2 | 3 | image: 4 | - Visual Studio 2017 5 | 6 | install: 7 | - git submodule update --init --recursive 8 | - cmd: set appveyor=yes 9 | 10 | environment: 11 | APPVEYOR_DISCORD_WEBHOOK_URL: 12 | secure: X51MbqvQdttlu+D/AvPqOmCFRJGTAk594CXQA9Cv6wqkV+6wn5I4OzHtc2HInZ1sqdfZobFhJSEVnL6d+jedfaNPrqDUbOHWXLJLZIbcBzU2e9IT7zJMbh0t4R9U3rZl0t3QveeZ3I+PNTgnNcq45ZFeZ3o2AjDm+mlskjIFUbg= 13 | 14 | build_script: 15 | - cmd: >- 16 | gradlew.bat clean build buildVanillaBridgeForWindows 17 | 18 | gradlew.bat sourcesJar javadocJar shadowJar 19 | 20 | on_success: 21 | - ps: webhooks/appveyor_discord.ps1 success $env:APPVEYOR_DISCORD_WEBHOOK_URL 22 | on_failure: 23 | - ps: webhooks/appveyor_discord.ps1 failure $env:APPVEYOR_DISCORD_WEBHOOK_URL 24 | 25 | cache: 26 | - '%USERPROFILE%\.gradle' 27 | 28 | artifacts: 29 | - path: 'BWAPI4J\build\libs\*.*' 30 | name: BWAPI4J 31 | -------------------------------------------------------------------------------- /githooks/pre-commit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cache_dir=.cache 4 | gjf=google-java-format-1.6-all-deps.jar 5 | gjf_link=https://github.com/google/google-java-format/releases/download/google-java-format-1.6/$gjf 6 | 7 | echo "Running formatting script..." 8 | 9 | mkdir -p $cache_dir && cd $cache_dir 10 | if [ ! -f $gjf ] 11 | then 12 | echo "Downloading $gjf..." 13 | curl -LJO $gjf_link 14 | chmod 644 $gjf 15 | fi 16 | cd .. 17 | 18 | changed_java_files=$(git diff --cached --name-only --diff-filter=ACMR | grep ".*java$" ) 19 | if [ "${changed_java_files:+1}" ] 20 | then 21 | echo "Applying formatting to:" 22 | echo "$changed_java_files" 23 | java -jar .cache/$gjf --replace $changed_java_files 24 | git add $changed_java_files 25 | fi 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBW/BWAPI4J/bdab3e630da5b927dc9b519e2d7bc2ce16393bf9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'BWAPI4J', 'BWAPI4J-AP' --------------------------------------------------------------------------------