daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static class AlphaStrategy extends Strategy{
  2.  
  3.         List<Elf> allElves;
  4.         List<Portal> allPortals;
  5.  
  6.         Location defensivePortalLoc;
  7.         Location aggressivePortalLoc;
  8.  
  9.         void use() {
  10.  
  11.             Commands.participants.clear();
  12.  
  13.             initializeVariables();
  14.             initializeCustomVariables();
  15.  
  16.             handleElves();
  17.             handlePortals();
  18.  
  19.         }
  20.  
  21.  
  22.         boolean choose() {
  23.  
  24.             return Utils.g.getMyCastle().distance(Utils.g.getEnemyCastle()) >= 4000;
  25.  
  26.         }
  27.  
  28.  
  29.         void handleElves() {
  30.  
  31.             for (Elf elf : allElves){
  32.  
  33.                 if (Commands.willElfSurvive(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyPortals()))))
  34.                     Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyPortals())));
  35.  
  36.                 if (Commands.willElfSurvive(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyLivingElves()))))
  37.                     Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyLivingElves())));
  38.  
  39.                 Commands.evadeSurvival(elf, 1000, 5);
  40.  
  41.                 Commands.buildPortal(elf, defensivePortalLoc);
  42.  
  43.                 if (Utils.getBuildingByLocation(defensivePortalLoc) == null)
  44.                     Commands.moveTowardsLocation(elf, defensivePortalLoc, true);
  45.  
  46.                 Commands.buildPortal(elf, aggressivePortalLoc);
  47.  
  48.                 if (Utils.getBuildingByLocation(aggressivePortalLoc) == null)
  49.                     Commands.moveTowardsLocation(elf, aggressivePortalLoc, true);
  50.  
  51.                 Commands.moveTowardsTarget(elf, Utils.getAllObjectsInRange(Arrays.asList(Utils.g.getEnemyPortals()), elf.location, Utils.getMaxRange()));
  52.                 Commands.moveTowardsTarget(elf, Utils.getAllObjectsInRange(Arrays.asList(Utils.g.getEnemyLivingElves()), elf.location, Utils.getMaxRange()));
  53.  
  54.                 Commands.attackObject(elf, Commands.getBestObjectToAttack(elf, Arrays.asList(Utils.g.getEnemyCastle())));
  55.                 Commands.moveTowardsLocation(elf, Utils.g.getEnemyCastle(), false);
  56.  
  57.             }
  58.  
  59.         }
  60.  
  61.  
  62.         void handlePortals() {
  63.  
  64.             allPortals.sort(Comparator.comparingInt(portal -> portal.distance(Utils.g.getMyCastle())));
  65.             for (Portal portal : allPortals){
  66.  
  67.                 if (Utils.g.getEnemyLavaGiants().length > 0 && Utils.getClosestObjectToObject(Utils.g.getEnemyLavaGiants(), portal).distance(portal) <= 2500)
  68.                     Commands.summon(portal, "IceTroll");
  69.                 if (Utils.g.getEnemyLivingElves().length > 0 && Utils.getClosestObjectToObject(Utils.g.getEnemyLivingElves(), portal).distance(portal) <= 2500)
  70.                     Commands.summon(portal, "IceTroll");
  71.  
  72.                 Commands.summon(portal, "LavaGiant");
  73.  
  74.             }
  75.  
  76.         }
  77.  
  78.  
  79.         int getPriorityNumber() {
  80.             return 0;
  81.         }
  82.  
  83.  
  84.         void initializeVariables() {
  85.             Commands.minMana = 110;
  86.             Commands.maxIceTrollAmount = 5;
  87.             Commands.minLavaGiantUsableHealth = 5;
  88.         }
  89.  
  90.  
  91.         void initializeCustomVariables() {
  92.             allElves = new LinkedList<>(Arrays.asList(Utils.g.getMyLivingElves()));
  93.             allPortals = new LinkedList<>(Arrays.asList(Utils.g.getMyPortals()));
  94.  
  95.             defensivePortalLoc = Utils.g.getMyCastle().location.towards(Utils.g.getEnemyCastle(), Utils.g.castleSize + Utils.g.portalSize + 1);
  96.             aggressivePortalLoc = Utils.g.getMyCastle().location.towards(Utils.g.getEnemyCastle(), Utils.g.castleSize + Utils.g.portalSize + 1800);
  97.         }
  98.  
  99.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top