collision

This commit is contained in:
Leen Dereu
2018-03-23 13:50:00 +01:00
parent 0111516595
commit 3807eb5d0f

View File

@@ -593,8 +593,12 @@ public class Worm {
subtractActionPoints(cost);
}
public void collision() {
public void collision(Worm smallestWorm, Worm largestWorm) {
long total = 1 + (new Random().nextLong() * (10 - 1));
long loseSmallest = total/(largestWorm.getOrientation()/(smallestWorm.getOrientation()+largestWorm.getOrientation()));
long loseLargest = total - loseSmallest;
smallestWorm.decreaseHitPoints(loseSmallest);
largestWorm.decreaseHitPoints(loseLargest);
}
//===================================================================================
@@ -769,7 +773,7 @@ public class Worm {
//===================================================================================
@Basic @Raw
public long gethitPoints() {
public long getHitPoints() {
return this.hitPoints;
}
@@ -782,6 +786,10 @@ public class Worm {
private long hitPoints;
public void decreaseHitPoints(long value) {
setHitPoints(getHitPoints() - value);
}
//===================================================================================
// endregion
}