From f45fa3fa96c4ea42dd782f398cf71895f06caae9 Mon Sep 17 00:00:00 2001 From: Koen Yskout Date: Thu, 22 Mar 2018 19:18:38 +0100 Subject: [PATCH] Release v2.1 Fixed a bug related to the radius of a newly created worm --- .../worms/internal/gui/game/commands/AddNewWorm.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/AddNewWorm.java b/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/AddNewWorm.java index ee64903..021a848 100644 --- a/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/AddNewWorm.java +++ b/OGP1718-Worms/src-provided/worms/internal/gui/game/commands/AddNewWorm.java @@ -11,6 +11,9 @@ import worms.util.ModelException; public class AddNewWorm extends InstantaneousCommand { + private static final double MIN_RADIUS = 0.25; + private static final double MAX_RADIUS = Math.pow(2, 1.0/3.0) * MIN_RADIUS; + public AddNewWorm(IFacade facade, PlayGameScreen screen) { super(facade, screen); } @@ -26,8 +29,8 @@ public class AddNewWorm extends InstantaneousCommand { Random random = getScreen().getGameState().getRandom(); int nbWorms = getFacade().getAllWorms(getWorld()).size(); String name = "Worm " + GUIUtils.numberToName(nbWorms++); - // ensures all worms have radius in [0.25, 0.50[, so minimum radius and team size conditions are always fulfilled - double radius = 0.25 * (1.0 + random.nextDouble()); + // ensures minimum radius and team size conditions are always fulfilled + double radius = MIN_RADIUS + (MAX_RADIUS - MIN_RADIUS) * random.nextDouble(); double[] p = GUIUtils.findFreeAdjacentSpot(getFacade(), getWorld(), radius, random);