Exemplo n.º 1
0
 @Override
 public void pursue() {
   final Clan currBoss = Me.getBoss();
   if (currBoss != Me) {
     success(currBoss);
     Me.addReport(GobLog.findSomeone(currBoss, "same old master"));
     return;
   }
   if (attemptsLeft-- > 0) {
     Clan candidate = Me.myShire().getRandOfCensus();
     final double resp = Me.FB.randomValueInPriority().compare(Me, candidate, Me);
     if (Me != candidate && !Me.isSomeBossOf(candidate)) {
       Double d = respectMemo.get(candidate);
       if (d == null) {
         respectMemo.put(candidate, resp);
       } else {
         respectMemo.put(candidate, resp + d);
       }
     }
   } else {
     Clan bestClan = null;
     double max = 0;
     for (Clan c : respectMemo.keySet()) {
       double d = respectMemo.get(c);
       if (d > max) {
         max = d;
         bestClan = c;
       }
     }
     if (max > 0) {
       Me.join(
           bestClan); // TODO boss should be able to reject (cuz minions cost money) ... in that
                      // case just offer service?
       success(bestClan);
       Me.addReport(GobLog.findSomeone(bestClan, "new master"));
     } else {
       if (Me.myOrder() == null) {
         Order.createBy(Me);
         success(Me);
         Me.addReport(GobLog.createOrder(false));
       } else {
         success();
         Me.addReport(GobLog.createOrder(true));
       }
     }
   }
 }