public void randomMove() { int minimumDifferenceInMovements = 10000; if ((System.nanoTime() - lastTimeRandomlyMoved) > minimumDifferenceInMovements) { int maximumRandom = 500; int minimumRandom = 0; Random r = new Random(System.nanoTime()); int x = r.nextInt(maximumRandom - minimumRandom + 1) + minimumRandom; if (x == 3 && !right) setRight(); if (x == 5 && !left) setLeft(); if (x == 7 && !up) setUp(); if (x == 9 && !down) setDown(); } }
public boolean applyDamage(Ability playerAttack) { Random r = new Random(System.nanoTime()); double d = r.nextDouble(); double damage = playerAttack.getDamage(); System.out.println("applying damage"); if (d > playerAttack.getAccuracy()) { return false; } else { if (weaknesses.size() > 0) { for (int j = 0; j < weaknesses.size(); j++) { if (playerAttack.getTypeOfDamage() == weaknesses.get(j)) { damage = damage * 1.5; break; } } } else if (resistances.size() > 0) { for (int j = 0; j < resistances.size(); j++) { if (playerAttack.getTypeOfDamage() == resistances.get(j)) { damage = damage * .667; } } } health = health - (int) damage; if (health <= 0) dead = true; return true; } }
public Enemy(TileMap tm) { super(tm); lastTimeRandomlyMoved = System.nanoTime(); }