Package com.fray.evo.util

Examples of com.fray.evo.util.EcYabotEncoder


    }
  }

  public String doYABOTEvaluate(EcBuildOrder s)
  {
    EcYabotEncoder encoder = new EcYabotEncoder("EC Optimized Build", "EvolutionChamber", "Add description here please.");
   
    ArrayList<String> warnings = new ArrayList<String>();
   
    for (EcAction a : s.getActions())
    {
      if (a.isInvalid(s))
      {
        continue;
      }
      while (!a.canExecute(s, log).can)
      {         
        if (s.seconds >= s.targetSeconds || destination.waypointMissed(s))
        {
          return messages.getString("NoFinishedBuildYet")+"\n"+EcUtil.toString(warnings);
        }
       
        if (destination.getMergedWaypoints().isSatisfied(s))
        {
          String yabot = encoder.done();
          final int max = 770;
          if (yabot.length() > max)
          {
            yabot += "\nBuild was too long. Please trim it by " + (yabot.length() - max) + " characters or try a new build.";
            yabot += "\nThis YABOT string will not work until you fix this!";
          }
          return yabot+"\n"+EcUtil.toString(warnings);
        }
      }
     
      if (!(a instanceof EcActionWait) && !(a instanceof EcActionBuildDrone))
      {
        if(!(a instanceof EcActionExtractorTrick))
        {
          if (a instanceof EcActionMineGas)
          {
            String tag = s.settings.pullThreeWorkersOnly ? "Add_3_drones_to_gas" : "Add_1_drone_to_gas";
            encoder.tag(tag);
          }
          else if (a instanceof EcActionMineMineral)
          {
            String tag = s.settings.pullThreeWorkersOnly ? "Add_3_drones_to_minerals" : "Add_1_drone_to_minerals";
            encoder.tag(tag);
          }
          else
          {
            //get the appropriate YABOT action class
            EcYabotEncoder.Action yabotAction = yabotMapping.get(a.getClass());
            if (yabotAction != null)
            {
              encoder.action(yabotAction);
            }
            else
            {
              warnings.add("YABOT action not found for '" + a.getClass().getName() + "'.");
            }
          }
         
          //enter the rest of the build step info
          encoder.supply((int) s.supplyUsed).minerals((int) s.minerals).gas((int) s.gas).timestamp(s.timestamp()).next();
        }
        else
        {
          // Yabot doesn't support extractor trick so the author suggested telling it to build an extractor and send a cancel string shortly after for the same building
          encoder.supply((int)s.supplyUsed).minerals((int)s.minerals).gas((int)s.gas).timestamp(s.timestamp()).action(EcYabotEncoder.Action.Extractor).tag("Extractor_Trick").next();
          encoder.supply((int)s.supplyUsed).minerals((int)s.minerals).gas((int)s.gas).timestamp(s.timestampIncremented(3)).action(EcYabotEncoder.Action.Extractor).cancel(true).tag("Extractor_Trick").next();
        }
      }
     
      a.execute(s, log);
    }
View Full Code Here

TOP

Related Classes of com.fray.evo.util.EcYabotEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.