-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTierUtil.java
More file actions
37 lines (33 loc) · 1.3 KB
/
TierUtil.java
File metadata and controls
37 lines (33 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.researchcube.util;
import com.researchcube.research.ResearchTier;
/**
* Validation utility for tier-based research rules.
*/
public final class TierUtil {
private TierUtil() {}
/**
* Validates whether a research operation is allowed based on tier rules:
* - cube.tier >= research.tier
* - drive.tier >= research.tier (higher tier drives can research lower tier research)
*
* @param cubeTier the tier of the cube in the Research Table
* @param driveTier the tier of the drive in the Research Table
* @param researchTier the tier required by the research definition
* @return true if the research can proceed
*/
public static boolean canResearch(ResearchTier cubeTier, ResearchTier driveTier, ResearchTier researchTier) {
if (cubeTier == null || driveTier == null || researchTier == null) {
return false;
}
// Broken drives can never be used
if (!driveTier.isFunctional()) {
return false;
}
// Cube must be at least the research tier
if (!cubeTier.isAtLeast(researchTier)) {
return false;
}
// Drive must be at least the research tier (higher tier drives can research lower tier)
return driveTier.isAtLeast(researchTier);
}
}