From cd1909c6a4117a65feb0a2f6e62bfcd9a4aa837b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 9 May 2016 11:47:52 +0200 Subject: Fix random test by resetting static state --- src/ch/epfl/xblast/server/Block.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java index 4f3d033..5cb662c 100644 --- a/src/ch/epfl/xblast/server/Block.java +++ b/src/ch/epfl/xblast/server/Block.java @@ -55,7 +55,19 @@ public enum Block { /** * Pseudo-random source for randomized behaviours. */ - private static final Random RANDOM_SOURCE = new Random(RANDOM_SEED); + private static Random RANDOM_SOURCE; + + /** + * Resets the random source used for bonus block spawning. + * Useful for deterministic tests. + */ + public static void resetRandomGenerator() { + RANDOM_SOURCE = new Random(RANDOM_SEED); + } + + static { + resetRandomGenerator(); + } /** * Corresponding bonus, or null. -- cgit v1.2.3