60 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.the5gi.util;
 | |
| 
 | |
| public class GameHelper {
 | |
| 
 | |
|     private static Role Winner = null;
 | |
| 
 | |
|     //Format: Detectives:Sheriffs:Survivalists:Mercenaries:Traitors:Assassins:LoneWolf:Jester
 | |
|     public static GameDecision getGameDecision(int[] PlayerRolesLeft, int PlayersLeft, boolean doRush) {
 | |
|         int InnocentRoles = PlayersLeft - (PlayerRolesLeft[4] + PlayerRolesLeft[5] + PlayerRolesLeft[6] + PlayerRolesLeft[7]);
 | |
|         int NeutralRoles = PlayerRolesLeft[6] + PlayerRolesLeft[7];
 | |
|         int TraitorRoles = PlayerRolesLeft[4] + PlayerRolesLeft[5];
 | |
| 
 | |
| 
 | |
|         if (NeutralRoles == 0 && TraitorRoles > 0) {
 | |
| 
 | |
|             if (InnocentRoles > TraitorRoles && doRush) {
 | |
|                 Winner = null;
 | |
|                 return GameDecision.RUSH;
 | |
|             }
 | |
| 
 | |
|             if (TraitorRoles > InnocentRoles) {
 | |
|                 Winner = Role.INNOCENT;
 | |
|                 return GameDecision.END;
 | |
|             }
 | |
| 
 | |
|             if (TraitorRoles == InnocentRoles) {
 | |
|                 Winner = null;
 | |
|                 return GameDecision.OVERTIME;
 | |
|             }
 | |
|         } else if (NeutralRoles > 0 && TraitorRoles == 0) {
 | |
|             if (NeutralRoles == InnocentRoles) {
 | |
|                 Winner = null;
 | |
|                 return GameDecision.OVERTIME;
 | |
|             }
 | |
| 
 | |
|             if (NeutralRoles > InnocentRoles) {
 | |
|                 Winner = Role.INNOCENT;
 | |
|                 return GameDecision.END;
 | |
|             }
 | |
| 
 | |
|             if (InnocentRoles > NeutralRoles && doRush) {
 | |
|                 Winner = null;
 | |
|                 return GameDecision.RUSH;
 | |
|             }
 | |
| 
 | |
|             if (InnocentRoles > NeutralRoles) {
 | |
|                 Winner = null;
 | |
|                 return GameDecision.OVERTIME;
 | |
|             }
 | |
| 
 | |
|         }
 | |
|         return null;
 | |
|     }
 | |
| 
 | |
|     public static Role getWinner() {
 | |
|         return Winner;
 | |
|     }
 | |
| 
 | |
| }
 |