Class Randomizer
java.lang.Object
server.Randomizer
全伺服器共用的偽亂數工具類,封裝單一
Random 實例的靜態存取介面。
提供 nextInt、nextBoolean、nextDouble、nextFloat、
nextLong、nextBytes 等基本型別隨機方法,以及常用的範圍整數
rand(lbound, ubound) 與成功率判斷 isSuccess(rate)。
全域共享同一個 java.util.Random,不保證執行緒安全的統計獨立性,
但對遊戲玩法而言已足夠;凡需要隨機數的 server.* 子系統
(如 RandomRewards、戰鬥計算、掉落判定等)均依賴本類別。
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSuccess(int rate) static final booleanstatic final voidnextBytes(byte[] bytes) static final doublestatic final floatstatic final intnextInt()static final intnextInt(int arg0) static final longnextLong()static final intrand(int lbound, int ubound)
-
Constructor Details
-
Randomizer
public Randomizer()
-
-
Method Details
-
nextInt
public static final int nextInt() -
nextInt
public static final int nextInt(int arg0) -
nextBytes
public static final void nextBytes(byte[] bytes) -
nextBoolean
public static final boolean nextBoolean() -
nextDouble
public static final double nextDouble() -
nextFloat
public static final float nextFloat() -
nextLong
public static final long nextLong() -
rand
public static final int rand(int lbound, int ubound) -
isSuccess
public static boolean isSuccess(int rate)
-