MCPcopy Create free account
hub / github.com/Card-Forge/forge / random

Method random

forge-core/src/main/java/forge/util/Aggregates.java:113–121  ·  view source on GitHub ↗
(final T[] source)

Source from the content-addressed store, hash-verified

111 }
112
113 public static final <T> T random(final T[] source) {
114 if (source == null) { return null; }
115
116 switch (source.length) {
117 case 0: return null;
118 case 1: return source[0];
119 default: return source[MyRandom.getRandom().nextInt(source.length)];
120 }
121 }
122
123 // Random - algorithm adapted from Braid's GeneratorFunctions
124 /**

Callers 15

GameTypeEnum · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95
resolveMethod · 0.95

Calls 5

getRandomMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
addMethod · 0.65
setMethod · 0.45

Tested by 7

tryGetCardMethod · 0.76
choosePDRollToIgnoreMethod · 0.76
chooseRollToIgnoreMethod · 0.76
chooseRollToModifyMethod · 0.76
chooseRollToSwapMethod · 0.76
chooseRollSwapValueMethod · 0.76
chooseKeywordForPumpMethod · 0.76