Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class AlphaStrategy extends Strategy{
- List<Elf> allElves;
- List<Portal> allPortals;
- Location defensivePortalLoc;
- Location aggressivePortalLoc;
- void use() {
- Commands.participants.clear();
- initializeVariables();
- initializeCustomVariables();
- handleElves();
- handlePortals();
- }
- boolean choose() {
- return Utils.g.getMyCastle().distance(Utils.g.getEnemyCastle()) >= 4000;
- }
- void handleElves() {
- for (Elf elf : allElves){
- if (Commands.willElfSurvive(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyPortals()))))
- Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyPortals())));
- if (Commands.willElfSurvive(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyLivingElves()))))
- Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyLivingElves())));
- Commands.evadeSurvival(elf, 1000, 5);
- Commands.buildPortal(elf, defensivePortalLoc);
- if (Utils.getBuildingByLocation(defensivePortalLoc) == null)
- Commands.moveTowardsLocation(elf, defensivePortalLoc, true);
- Commands.buildPortal(elf, aggressivePortalLoc);
- if (Utils.getBuildingByLocation(aggressivePortalLoc) == null)
- Commands.moveTowardsLocation(elf, aggressivePortalLoc, true);
- Commands.moveTowardsTarget(elf, Utils.getAllObjectsInRange(Arrays.asList(Utils.g.getEnemyPortals()), elf.location, Utils.getMaxRange()));
- Commands.moveTowardsTarget(elf, Utils.getAllObjectsInRange(Arrays.asList(Utils.g.getEnemyLivingElves()), elf.location, Utils.getMaxRange()));
- Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyCastle())));
- Commands.moveTowardsLocation(elf, Utils.g.getEnemyCastle(), false);
- }
- }
- void handlePortals() {
- allPortals.sort(Comparator.comparingInt(portal -> portal.distance(Utils.g.getMyCastle())));
- for (Portal portal : allPortals){
- if (Utils.g.getEnemyLavaGiants().length > 0 && Utils.getClosestObjectToObject(Utils.g.getEnemyLavaGiants(), portal).distance(portal) <= 2500)
- Commands.summon(portal, "IceTroll");
- if (Utils.g.getEnemyLivingElves().length > 0 && Utils.getClosestObjectToObject(Utils.g.getEnemyLivingElves(), portal).distance(portal) <= 2500)
- Commands.summon(portal, "IceTroll");
- Commands.summon(portal, "LavaGiant");
- }
- }
- int getPriorityNumber() {
- return 0;
- }
- void initializeVariables() {
- Commands.minMana = 110;
- Commands.maxIceTrollAmount = 5;
- Commands.minLavaGiantUsableHealth = 5;
- }
- void initializeCustomVariables() {
- allElves = new LinkedList<>(Arrays.asList(Utils.g.getMyLivingElves()));
- allPortals = new LinkedList<>(Arrays.asList(Utils.g.getMyPortals()));
- defensivePortalLoc = Utils.g.getMyCastle().location.towards(Utils.g.getEnemyCastle(), Utils.g.castleSize + Utils.g.portalSize + 1);
- aggressivePortalLoc = Utils.g.getMyCastle().location.towards(Utils.g.getEnemyCastle(), Utils.g.castleSize + Utils.g.portalSize + 1800);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement