Skip to content

Commit

Permalink
Backend/shuffle #135 (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: aprilywy <[email protected]>
  • Loading branch information
aprilywy and aprilywy authored Feb 22, 2024
1 parent 92f6366 commit 0fc5431
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package tw.waterballsa.gaas.citadels.util;

import java.util.List;
import java.util.Random;

public class CitadelsUtils {

public static <T> void shuffle(List<T> cards) {
Random rd = new Random();

for (int i = cards.size() - 1; i > 0; i--) {
int j = rd.nextInt(i + 1);

T temp = cards.get(i);
cards.set(i, cards.get(j));
cards.set(j, temp);
}
}
}

0 comments on commit 0fc5431

Please sign in to comment.