public SoldierRobot(RobotController rc) throws GameActionException { super(rc); NavSystem.init(this); if (Clock.getRoundNum() < 10) { soldierState = soldierState.SCOUTING; } else { ChannelType channel = EncampmentJobSystem.findJob(); if (channel != null) { unassigned = false; EncampmentJobSystem.updateJobTaken(); } // TODO: this will f**k up if we ever build artillery for non-nuke bots // LEARN THE STRATEGY Message message = BroadcastSystem.read(ChannelType.STRATEGY); if (message.isValid && message.body < Strategy.values().length && message.body >= 0) { strategy = Strategy.values()[message.body]; } else { // we couldn't read the strategy channel MapLocation[] alliedEncampmentSquares = rc.senseAlliedEncampmentSquares(); if (alliedEncampmentSquares.length == 0) { strategy = Strategy.ECON; } else { Robot robot = (Robot) rc.senseObjectAtLocation(alliedEncampmentSquares[0]); RobotInfo robotInfo = rc.senseRobotInfo(robot); if (robotInfo.type == RobotType.ARTILLERY) { strategy = Strategy.NUKE; } else { strategy = Strategy.ECON; } } } // rc.setIndicatorString(2, strategy.toString()); rallyPoint = findRallyPoint(); rSquared = DataCache.rushDistSquared / 4; initializeMining(); } }
@Extension // for some reason when running mvn from commandline the build fails, // if BuildTrigger is not fully qualified here!? public static class DescriptorImpl extends hudson.tasks.BuildTrigger.DescriptorImpl { public static final String[] THRESHOLD_VALUES = { Result.SUCCESS.toString(), Result.UNSTABLE.toString(), Result.FAILURE.toString(), Result.ABORTED.toString() }; public static final Strategy[] STRATEGY_VALUES = Strategy.values(); @Override public String getDisplayName() { return hudson.plugins.downstream_ext.Messages.DownstreamTrigger_DisplayName(); } @Override public String getHelpFile() { return "/plugin/downstream-ext/help.html"; } @Override public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException { return new DownstreamTrigger( formData.getString("childProjects"), formData.getString("threshold"), formData.has("onlyIfSCMChanges") && formData.getBoolean("onlyIfSCMChanges"), formData.getString("strategy"), formData.has("triggerOnlyOnceWhenMatrixEnds") && formData.getBoolean("triggerOnlyOnceWhenMatrixEnds")); } public boolean isMatrixProject(AbstractProject project) { return project instanceof MatrixProject; } @Extension public static class ItemListenerImpl extends ItemListener { @Override public void onRenamed(Item item, String oldName, String newName) { // update DownstreamTrigger of other projects that point to this object. // can't we generalize this? for (Project<?, ?> p : Hudson.getInstance().getProjects()) { DownstreamTrigger t = p.getPublishersList().get(DownstreamTrigger.class); if (t != null) { if (t.onJobRenamed(oldName, newName)) { try { p.save(); } catch (IOException e) { LOGGER.log( Level.WARNING, "Failed to persist project setting during rename from " + oldName + " to " + newName, e); } } } } } @Override public void onDeleted(Item item) { executors.remove(item); } } }