Пример #1
0
 public void automate() {
   int turn = 0;
   while (!(p1.checkLoss() || p2.checkLoss())) {
     // guarantee the fight finishes in a timely manner
     if (turn > 50) {
       p1.pleasure(5 * (turn - 50), this, p2);
       p2.pleasure(5 * (turn - 50), this, p1);
     }
     turn += 1;
     phase = 1;
     p1.regen(this);
     p2.regen(this);
     p1act = ((NPC) p1).actFast(this);
     p2act = ((NPC) p2).actFast(this);
     clear();
     if (Global.isDebugOn(DebugFlags.DEBUG_SCENE)) {
       System.out.println(p1.name() + " uses " + p1act.getLabel(this));
       System.out.println(p2.name() + " uses " + p2act.getLabel(this));
     }
     if (p1.pet != null && p2.pet != null) {
       petbattle(p1.pet, p2.pet);
     } else if (p1.pet != null) {
       p1.pet.act(this, p2);
     } else if (p2.pet != null) {
       p2.pet.act(this, p1);
     }
     useSkills();
     p1.eot(this, p2, p2act);
     p2.eot(this, p1, p1act);
     checkStamina(p1);
     checkStamina(p2);
     getStance().decay(this);
     getStance().checkOngoing(this);
     phase = 0;
   }
   if (p1.checkLoss() && p2.checkLoss()) {
     state = eval();
     p1.evalChallenges(this, null);
     p2.evalChallenges(this, null);
     p2.draw(this, state);
     winner = Optional.of(Global.noneCharacter());
     end();
     return;
   }
   if (p1.checkLoss()) {
     state = eval();
     p1.evalChallenges(this, p2);
     p2.evalChallenges(this, p2);
     p2.victory(this, state);
     doVictory(p2, p1);
     winner = Optional.of(p2);
     end();
     return;
   }
   if (p2.checkLoss()) {
     state = eval();
     p1.evalChallenges(this, p1);
     p2.evalChallenges(this, p1);
     p1.victory(this, state);
     doVictory(p1, p2);
     winner = Optional.of(p1);
     end();
     return;
   }
 }