Allowed fractional health deductions per frame

- Fixed boundary penalty system

#story[1291]
main
Connor Taylor-Brown 8 years ago
parent 50d5dd02a2
commit 7eb59cdcfc

@ -378,8 +378,8 @@ public class MockRace extends RaceState {
} }
// Remove one unit of health for every frame spent outside boundary // Remove one unit of health for every frame spent outside boundary
if(!finish && checkBearingInsideCourse(boat.getBearing(), boat.getPosition())) { if(!finish && !GPSCoordinate.isInsideBoundary(boat.getPosition(), getBoundary())) {
boat.updateHealth(-1); boat.updateHealth(-0.1);
} }
this.updateEstimatedTime(boat); this.updateEstimatedTime(boat);

@ -273,7 +273,7 @@ public class RaceServer {
private BoatState parseIndividualBoatState(MockBoat boat) { private BoatState parseIndividualBoatState(MockBoat boat) {
return new BoatState( return new BoatState(
boat.getSourceID(), boat.getSourceID(),
boat.getHealth() (int)boat.getHealth()
); );
} }

@ -106,7 +106,7 @@ public class Boat extends Collider {
/** /**
* Amount of health boat currently has, between 0 and 100 * Amount of health boat currently has, between 0 and 100
*/ */
private int health; private double health;
/** /**
* Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table. * Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table.
@ -441,11 +441,11 @@ public class Boat extends Collider {
isColliding = colliding; isColliding = colliding;
} }
public int getHealth() { public double getHealth() {
return health; return health;
} }
public void setHealth(int health) { public void setHealth(double health) {
this.health = health; this.health = health;
} }
@ -453,7 +453,7 @@ public class Boat extends Collider {
* Add a given amount of HP to boat health * Add a given amount of HP to boat health
* @param delta amount of HP to add * @param delta amount of HP to add
*/ */
public void updateHealth(int delta) { public void updateHealth(double delta) {
health += delta; health += delta;
if(health < 0) health = 0; if(health < 0) health = 0;
else if(health > 100) health = 100; else if(health > 100) health = 100;

Loading…
Cancel
Save