Starsector API
Loading...
Searching...
No Matches
RepLevel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.campaign;
2
3public enum RepLevel {
4
5 VENGEFUL("Vengeful", getT4(), 1f),
6 HOSTILE("Hostile", getT3(), getT4()),
7 INHOSPITABLE("Inhospitable", getT2(), getT3()),
8 SUSPICIOUS("Suspicious", getT1(), getT2()),
9 NEUTRAL("Neutral", 0, getT1()),
10 FAVORABLE("Favorable", getT1(), getT2()),
11 WELCOMING("Welcoming", getT2(), getT3()),
12 FRIENDLY("Friendly", getT3(), getT4()),
13 COOPERATIVE("Cooperative", getT4(), 1f);
14
15
16 private final String displayName;
17 private final float max;
18 private final float min;
19 private RepLevel(String displayName, float min, float max) {
20 this.displayName = displayName;
21 this.min = min;
22 this.max = max;
23 }
24 public String getDisplayName() {
25 return displayName;
26 }
27
29 if (this == VENGEFUL) return HOSTILE;
30 if (this == HOSTILE) return INHOSPITABLE;
31 if (this == INHOSPITABLE) return SUSPICIOUS;
32 if (this == SUSPICIOUS) return NEUTRAL;
33 if (this == NEUTRAL) return FAVORABLE;
34 if (this == FAVORABLE) return WELCOMING;
35 if (this == WELCOMING) return FRIENDLY;
36 if (this == FRIENDLY) return COOPERATIVE;
37
38 return COOPERATIVE;
39 }
40
42 if (this == HOSTILE) return VENGEFUL;
43 if (this == INHOSPITABLE) return HOSTILE;
44 if (this == SUSPICIOUS) return INHOSPITABLE;
45 if (this == NEUTRAL) return SUSPICIOUS;
46 if (this == FAVORABLE) return NEUTRAL;
47 if (this == WELCOMING) return FAVORABLE;
48 if (this == FRIENDLY) return WELCOMING;
49 if (this == COOPERATIVE) return FRIENDLY;
50
51 return VENGEFUL;
52 }
53
58 public float getMin() {
59 return min;
60 }
65 public float getMax() {
66 return max;
67 }
68 public boolean isAtWorst(RepLevel level) {
69 return ordinal() >= level.ordinal();
70 }
71 public boolean isAtBest(RepLevel level) {
72 return ordinal() <= level.ordinal();
73 }
74
75 public boolean isNeutral() {
76 return this == NEUTRAL;
77 }
78
79 public boolean isPositive() {
80 return isAtWorst(RepLevel.FAVORABLE);
81 }
82
83 public boolean isNegative() {
84 return isAtBest(RepLevel.SUSPICIOUS);
85 }
86
87 private static final float T1 = 0.09f;
88 private static final float T2 = 0.24f;
89 private static final float T3 = 0.49f;
90 private static final float T4 = 0.74f;
91// private static final float T1 = 0.1f;
92// private static final float T2 = 0.25f;
93// private static final float T3 = 0.5f;
94// private static final float T4 = 0.75f;
95 public static RepLevel getLevelFor(float r) {
96 if (r >= 0) {
97 int rel = getRepInt(r);
98 if (rel <= getRepInt(T1)) return NEUTRAL;
99 if (rel <= getRepInt(T2)) return FAVORABLE;
100 if (rel <= getRepInt(T3)) return WELCOMING;
101 if (rel <= getRepInt(T4)) return FRIENDLY;
102 return COOPERATIVE;
103 } else {
104 r = -r;
105 int rel = getRepInt(r);
106 if (rel <= getRepInt(T1)) return NEUTRAL;
107 if (rel <= getRepInt(T2)) return SUSPICIOUS;
108 if (rel <= getRepInt(T3)) return INHOSPITABLE;
109 if (rel <= getRepInt(T4)) return HOSTILE;
110 return VENGEFUL;
111 }
112 }
113
114 public static int getRepInt(float f) {
115 return (int) Math.round(f * 100f);
116 }
117
118 public static float getT1() {
119 return T1;
120 }
121 public static float getT2() {
122 return T2;
123 }
124 public static float getT3() {
125 return T3;
126 }
127 public static float getT4() {
128 return T4;
129 }
130
131
132}
133
134
135
136
137
static RepLevel getLevelFor(float r)
Definition RepLevel.java:95
boolean isAtWorst(RepLevel level)
Definition RepLevel.java:68
boolean isAtBest(RepLevel level)
Definition RepLevel.java:71