-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RoleCountHelper can indicate how many player in a role easily
- Loading branch information
1 parent
f20253e
commit ae27143
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
} |