Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Uy on 10.12.2016.
- */
- public class Dungeon {
- public static void main(String[] args) {
- boolean isPriestAlive = true;
- boolean isWarriorAlive = true;
- boolean isThiefAlive = true;
- boolean isMageAlive = true;
- boolean isMageDeadEarlier = false;
- boolean isWarriorDeadEarlier = false;
- int aliveAdventurers = 4;
- int lives = 0;
- for(int i = 1; i < 101; i++) {
- int goblins = i;
- boolean hasRevived = false;
- while(goblins != 0) {
- if(isThiefAlive) {
- goblins = goblins < 1 ? 0 : goblins - 1;//53
- }
- if(isMageAlive) {
- goblins = goblins < 10 ? 0 : goblins - 10;//43
- }
- if(isWarriorAlive) {
- goblins = goblins < 1 ? 0 : goblins - 1;//43
- }
- if(isPriestAlive && !hasRevived) {
- if(!isWarriorAlive && !isWarriorDeadEarlier) {
- hasRevived = true;
- isWarriorAlive = true;
- aliveAdventurers++;
- } else if(!isMageAlive && !isMageDeadEarlier) {
- hasRevived = true;
- isMageAlive = true;
- aliveAdventurers++;
- }
- }
- if(!isWarriorAlive && !isPriestAlive && !isMageAlive && isThiefAlive) {
- break;
- }
- if(aliveAdventurers*10 <= goblins) {
- if(isWarriorAlive) {
- isWarriorAlive = false;
- aliveAdventurers--;
- } else if(isMageAlive) {
- isMageAlive = false;
- aliveAdventurers--;
- } else if(isPriestAlive) {
- isPriestAlive = false;
- aliveAdventurers--;
- }
- }
- }
- if(!isWarriorAlive) {
- isWarriorDeadEarlier = true;
- }
- if(!isMageAlive) {
- isMageDeadEarlier = true;
- }
- lives += goblins;
- System.out.println("i: " + i + " " + goblins);
- }
- System.out.println(lives + aliveAdventurers + 17);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement