small fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import worms.programs.UnaryExpression;
|
|||||||
import worms.util.Coordinate;
|
import worms.util.Coordinate;
|
||||||
|
|
||||||
import java.io.Console;
|
import java.io.Console;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.function.DoubleBinaryOperator;
|
import java.util.function.DoubleBinaryOperator;
|
||||||
|
|
||||||
@@ -21,5 +22,14 @@ public class Main {
|
|||||||
{ false, false, false, false } };
|
{ false, false, false, false } };
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
||||||
|
int x =ThreadLocalRandom.current().nextInt(0, 15) / 2;
|
||||||
|
x += (x % 2 == 0 ? 1:0);
|
||||||
|
System.out.println(x);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,9 @@ public class Bazooka extends Projectile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRandomHitPoints() {
|
protected int getRandomHitPoints() {
|
||||||
return ThreadLocalRandom.current().nextInt(15) / 2;
|
int nb =ThreadLocalRandom.current().nextInt(15) / 2;
|
||||||
|
nb += (nb % 2 == 0 ? 1:0);
|
||||||
|
return nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,7 +16,7 @@ public class Rifle extends Projectile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRandomHitPoints() {
|
protected int getRandomHitPoints() {
|
||||||
return ThreadLocalRandom.current().nextInt(6) * 2;
|
return ThreadLocalRandom.current().nextInt(1,6) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -590,7 +590,20 @@ public class World {
|
|||||||
}
|
}
|
||||||
else if (item1 instanceof Worm && item2 instanceof Projectile ||
|
else if (item1 instanceof Worm && item2 instanceof Projectile ||
|
||||||
item1 instanceof Projectile && item2 instanceof Worm) {
|
item1 instanceof Projectile && item2 instanceof Worm) {
|
||||||
// TODO hit by projectile, projectile gets random hit points
|
|
||||||
|
Worm worm = null;
|
||||||
|
Projectile proj = null;
|
||||||
|
if (item1 instanceof Worm) {
|
||||||
|
worm = (Worm) item1;
|
||||||
|
proj = (Projectile) item2;
|
||||||
|
} else {
|
||||||
|
worm = (Worm) item2;
|
||||||
|
proj = (Projectile) item1;
|
||||||
|
}
|
||||||
|
|
||||||
|
proj.hit(worm);
|
||||||
|
proj.setHitPoints(proj.getRandomHitPoints());
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (item1 instanceof Food && item2 instanceof Food) {
|
else if (item1 instanceof Food && item2 instanceof Food) {
|
||||||
if (((Food) item1).isPoisonous()) ((Food) item1).heal();
|
if (((Food) item1).isPoisonous()) ((Food) item1).heal();
|
||||||
|
@@ -83,7 +83,6 @@ public class Statement<T> {
|
|||||||
* @param type
|
* @param type
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Action(Type type, Expression<Double> value) {
|
public Action(Type type, Expression<Double> value) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
Reference in New Issue
Block a user