Skip to content

Commit

Permalink
feat: RoleCountHelper can indicate how many player in a role easily
Browse files Browse the repository at this point in the history
  • Loading branch information
LapisBerry committed May 27, 2024
1 parent f20253e commit ae27143
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/main/java/com/lapisberry/utils/RoleCountHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.lapisberry.utils;

public final class RoleCountHelper {
public static int getEmperors(int players) {
if (4 <= players && players <= 8) return 1;
return 0;
}

public static int getRoyalists(int players) {
if (4 <= players && players <= 8) return TABLE[players - 4][2];
return 0;
}

public static int getRebels(int players) {
if (4 <= players && players <= 8) return TABLE[players - 4][1];
return 0;
}

public static int getSpies(int players) {
if (4 <= players && players <= 8) return TABLE[players - 4][0];
return 0;
}

// Array of role count
private static final int[][] TABLE = {// sp,rb,ry -> spy, rebel, royalist
{1, 2, 0},// 4 players
{1, 2, 1},// 5 players
{1, 3, 1},// 6 players
{1, 3, 2},// 7 players
{2, 3, 2},// 8 players
{2, 4, 2},// 9 players
{2, 4, 3} // 10 players
};
}

0 comments on commit ae27143

Please sign in to comment.