From 2c981f29ce0f677289fb50c1b0ec5366a9fcd66b Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 14 May 2021 00:30:49 +0200 Subject: [PATCH] code cleanup --- .../src/de/steamwar/fightsystem/event/HellsBells.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java index c5c8409..c74f225 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java @@ -29,7 +29,7 @@ public class HellsBells { EAST(1, 0, 0, false), WEST(-1, 0, 0, false); - static final List DIRECTIONS = Arrays.asList(values()); + static final Direction[] DIRECTIONS = values(); int dx; int dy; @@ -43,6 +43,10 @@ public class HellsBells { this.zLength = zLength; } + public static Direction getRandom() { + return Direction.DIRECTIONS[random.nextInt(Direction.DIRECTIONS.length)]; + } + Direction other() { switch (this) { case NORTH: @@ -130,7 +134,7 @@ public class HellsBells { } public void drop() { - Direction direction = Direction.DIRECTIONS.get(random.nextInt(Direction.DIRECTIONS.size())); + Direction direction = Direction.getRandom(); AtomicInteger length = new AtomicInteger(10 + random.nextInt((direction.zLength ? zLength : xLength) - 10)); int width = 5 + random.nextInt(5);