mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
[AFC] Implemented Maddening Hex
This commit is contained in:
parent
dfcb98b951
commit
e61f019cd3
3 changed files with 157 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue