[AFC] Implemented Maddening Hex

This commit is contained in:
Evan Kranzler 2021-08-02 20:13:54 -04:00
parent dfcb98b951
commit e61f019cd3
3 changed files with 157 additions and 0 deletions

View file

@ -2,6 +2,8 @@ package mage.util;
import java.awt.*;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
/**
* Created by IGOUDT on 5-9-2016.
@ -40,4 +42,19 @@ public final class RandomUtil {
public static void setSeed(long newSeed) {
random.setSeed(newSeed);
}
public static UUID randomFromSet(Set<UUID> uuids) {
if (uuids.size() < 2) {
return uuids.stream().findFirst().orElse(null);
}
int rand = nextInt(uuids.size());
int count = 0;
for (UUID currentId : uuids) {
if (count == rand) {
return currentId;
}
count++;
}
return null;
}
}