23 public Map<String, String>
getTokenReplacements(String ruleId, Object entity, Map<String, MemoryAPI> memoryMap) {
25 SectorEntityToken target =
null;
26 PersonAPI person =
null;
27 MarketAPI market =
null;
28 FactionAPI faction =
null;
29 FactionAPI personFaction =
null;
30 if (entity instanceof SectorEntityToken) {
31 target = (SectorEntityToken) entity;
32 market = target.getMarket();
33 faction = target.getFaction();
36 if (entity instanceof CampaignFleetAPI && market ==
null) {
37 market = Misc.getSourceMarket((CampaignFleetAPI) entity);
40 if (entity instanceof SectorEntityToken) {
41 person = ((SectorEntityToken) entity).getActivePerson();
45 if (entity instanceof CampaignFleetAPI) {
46 person = ((CampaignFleetAPI) entity).getCommander();
47 }
else if (entity instanceof PersonAPI ){
48 person = (PersonAPI) entity;
53 personFaction = person.getFaction();
58 Map<String, String> map =
new HashMap<String, String>();
60 map.put(
"$Playername",
Global.
getSector().getCharacterData().getName());
61 map.put(
"$playername",
Global.
getSector().getCharacterData().getName());
62 map.put(
"$playerName",
Global.
getSector().getCharacterData().getName());
63 map.put(
"$PlayerName",
Global.
getSector().getCharacterData().getName());
65 map.put(
"$playerFirstName",
Global.
getSector().getCharacterData().getPerson().getName().getFirst());
66 map.put(
"$playerFirstname",
Global.
getSector().getCharacterData().getPerson().getName().getFirst());
67 map.put(
"$playerLastName",
Global.
getSector().getCharacterData().getPerson().getName().getLast());
68 map.put(
"$playerLastname",
Global.
getSector().getCharacterData().getPerson().getName().getLast());
71 String honorific =
Global.
getSector().getCharacterData().getHonorific();
72 if (playerPerson !=
null) {
73 if (playerPerson.isMale()) {
74 map.put(
"$playerSirOrMadam",
"sir");
75 map.put(
"$PlayerSirOrMadam",
"Sir");
77 map.put(
"$playerBrotherOrSister",
"brother");
78 map.put(
"$PlayerBrotherOrSister",
"Brother");
80 map.put(
"$playerHisOrHer",
"his");
81 map.put(
"$PlayerHisOrHer",
"His");
82 map.put(
"$playerHimOrHer",
"him");
83 map.put(
"$PlayerHimOrHer",
"Him");
84 map.put(
"$playerHeOrShe",
"he");
85 map.put(
"$PlayerHeOrShe",
"He");
87 map.put(
"$playerSirOrMadam",
"ma'am");
88 map.put(
"$PlayerSirOrMadam",
"Ma'am");
90 map.put(
"$playerBrotherOrSister",
"sister");
91 map.put(
"$PlayerBrotherOrSister",
"Sister");
93 map.put(
"$playerHisOrHer",
"her");
94 map.put(
"$PlayerHisOrHer",
"Her");
95 map.put(
"$playerHimOrHer",
"her");
96 map.put(
"$PlayerHimOrHer",
"Her");
97 map.put(
"$playerHeOrShe",
"she");
98 map.put(
"$PlayerHeOrShe",
"She");
101 if (honorific !=
null && !honorific.isEmpty()) {
102 map.put(
"$playerSirOrMadam", Misc.lcFirst(honorific));
103 map.put(
"$PlayerSirOrMadam", honorific);
105 if (!Misc.SIR.toLowerCase().equals(honorific.toLowerCase()) &&
106 !Misc.MAAM.toLowerCase().equals(honorific.toLowerCase())) {
107 map.put(
"$playerBrotherOrSister",
"walker");
108 map.put(
"$PlayerBrotherOrSister",
"Walker");
113 if (market !=
null) {
115 map.put(
"$marketName", market.getName());
117 if (target.getLocation() instanceof StarSystemAPI) {
118 map.put(
"$marketSystem", ((StarSystemAPI)target.getLocation()).getBaseName() +
" star system");
120 map.put(
"$marketSystem",
"hyperspace");
123 MemoryAPI mem = market.getMemoryWithoutUpdate();
124 if (mem.contains(MemFlags.MEMORY_KEY_PLAYER_HOSTILE_ACTIVITY_NEAR_MARKET)) {
125 float expire = mem.getExpire(MemFlags.MEMORY_KEY_PLAYER_HOSTILE_ACTIVITY_NEAR_MARKET);
126 String days = Misc.getAtLeastStringForDays((
int) expire);
127 map.put(
"$playerHostileTimeoutStr", days.toLowerCase());
128 mem.set(
"$playerHostileTimeoutStr", days.toLowerCase(), 0);
132 if (target !=
null) {
133 map.put(
"$entityName", target.getName());
134 map.put(
"$fleetName", target.getName().toLowerCase());
135 map.put(
"$relayName", target.getName());
138 if (target.getCustomEntityType() !=
null) {
139 if (target.getCustomEntitySpec() !=
null) {
140 CustomEntitySpecAPI spec = target.getCustomEntitySpec();
141 map.put(
"$nameInText", spec.getNameInText());
142 map.put(
"$shortName", spec.getShortName());
143 map.put(
"$isOrAre", spec.getIsOrAre());
144 map.put(
"$aOrAn", spec.getAOrAn());
150 if (target.getFaction() !=
null) {
151 String factionName = target.getFaction().getEntityNamePrefix();
152 if (factionName ==
null || factionName.isEmpty()) {
153 factionName = target.getFaction().getDisplayName();
156 map.put(
"$factionAOrAn", target.getFaction().getPersonNamePrefixAOrAn());
158 map.put(
"$factionIsOrAre", target.getFaction().getDisplayNameIsOrAre());
160 map.put(
"$faction", factionName);
161 map.put(
"$ownerFaction", factionName);
162 map.put(
"$marketFaction", factionName);
163 map.put(
"$Faction", Misc.ucFirst(factionName));
164 map.put(
"$OwnerFaction", Misc.ucFirst(factionName));
165 map.put(
"$MarketFaction", Misc.ucFirst(factionName));
166 map.put(
"$theFaction", target.getFaction().getDisplayNameWithArticle());
167 map.put(
"$theOwnerFaction", target.getFaction().getDisplayNameWithArticle());
168 map.put(
"$theMarketFaction", target.getFaction().getDisplayNameWithArticle());
169 map.put(
"$TheFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
170 map.put(
"$TheOwnerFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
171 map.put(
"$TheMarketFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
173 map.put(
"$factionLong", target.getFaction().getDisplayNameLong());
174 map.put(
"$FactionLong", Misc.ucFirst(target.getFaction().getDisplayNameLong()));
175 map.put(
"$theFactionLong", target.getFaction().getDisplayNameLongWithArticle());
176 map.put(
"$TheFactionLong", Misc.ucFirst(target.getFaction().getDisplayNameLongWithArticle()));
180 if (target !=
null) {
181 map.put(
"$entityName", target.getName());
182 map.put(
"$fleetName", target.getName().toLowerCase());
183 map.put(
"$relayName", target.getName());
187 if (target.getFaction() !=
null) {
188 String factionName = target.getFaction().getEntityNamePrefix();
189 if (factionName ==
null || factionName.isEmpty()) {
190 factionName = target.getFaction().getDisplayName();
193 map.put(
"$factionIsOrAre", target.getFaction().getDisplayNameIsOrAre());
195 map.put(
"$faction", factionName);
196 map.put(
"$ownerFaction", factionName);
197 map.put(
"$marketFaction", factionName);
198 map.put(
"$Faction", Misc.ucFirst(factionName));
199 map.put(
"$OwnerFaction", Misc.ucFirst(factionName));
200 map.put(
"$MarketFaction", Misc.ucFirst(factionName));
201 map.put(
"$theFaction", target.getFaction().getDisplayNameWithArticle());
202 map.put(
"$theOwnerFaction", target.getFaction().getDisplayNameWithArticle());
203 map.put(
"$theMarketFaction", target.getFaction().getDisplayNameWithArticle());
204 map.put(
"$TheFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
205 map.put(
"$TheOwnerFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
206 map.put(
"$TheMarketFaction", Misc.ucFirst(target.getFaction().getDisplayNameWithArticle()));
208 map.put(
"$factionLong", target.getFaction().getDisplayNameLong());
209 map.put(
"$FactionLong", Misc.ucFirst(target.getFaction().getDisplayNameLong()));
210 map.put(
"$theFactionLong", target.getFaction().getDisplayNameLongWithArticle());
211 map.put(
"$TheFactionLong", Misc.ucFirst(target.getFaction().getDisplayNameLongWithArticle()));
216 String shipOrFleet =
"fleet";
217 if (playerFleet.getFleetData().getMembersListCopy().size() == 1) {
218 shipOrFleet =
"ship";
219 if (playerFleet.getFleetData().getMembersListCopy().get(0).isFighterWing()) {
220 shipOrFleet =
"fighter wing";
223 map.put(
"$shipOrFleet", shipOrFleet);
224 map.put(
"$fleetOrShip", shipOrFleet);
225 map.put(
"$ShipOrFleet", Misc.ucFirst(shipOrFleet));
226 map.put(
"$FleetOrShip", Misc.ucFirst(shipOrFleet));
228 if (target instanceof CampaignFleetAPI) {
229 CampaignFleetAPI fleet = (CampaignFleetAPI) target;
230 String otherShipOrFleet =
"fleet";
231 if (fleet.getFleetData().getMembersListCopy().size() == 1) {
232 shipOrFleet =
"ship";
233 if (fleet.getFleetData().getMembersListCopy().get(0).isFighterWing()) {
234 shipOrFleet =
"fighter wing";
237 map.put(
"$otherShipOrFleet", otherShipOrFleet);
239 map.put(
"$otherFleetName", fleet.getName().toLowerCase());
242 if (person !=
null) {
243 if (person.isMale()) {
244 map.put(
"$hisOrHer",
"his");
245 map.put(
"$HisOrHer",
"His");
246 map.put(
"$himOrHer",
"him");
247 map.put(
"$HimOrHer",
"Him");
248 map.put(
"$heOrShe",
"he");
249 map.put(
"$HeOrShe",
"He");
250 map.put(
"$himOrHerself",
"himself");
251 map.put(
"$HimOrHerself",
"Himself");
252 map.put(
"$manOrWoman",
"man");
253 map.put(
"$ManOrWoman",
"Man");
254 map.put(
"$brotherOrSister",
"brother");
255 map.put(
"$BrotherOrSister",
"Brother");
256 map.put(
"$sirOrMadam",
"sir");
257 map.put(
"$SirOrMadam",
"Sir");
259 map.put(
"$hisOrHer",
"her");
260 map.put(
"$HisOrHer",
"Her");
261 map.put(
"$himOrHer",
"her");
262 map.put(
"$HimOrHer",
"Her");
263 map.put(
"$heOrShe",
"she");
264 map.put(
"$HeOrShe",
"She");
265 map.put(
"$himOrHerself",
"herself");
266 map.put(
"$HimOrHerself",
"Herself");
267 map.put(
"$manOrWoman",
"woman");
268 map.put(
"$ManOrWoman",
"Woman");
269 map.put(
"$brotherOrSister",
"sister");
270 map.put(
"$BrotherOrSister",
"Sister");
271 map.put(
"$sirOrMadam",
"ma'am");
272 map.put(
"$SirOrMadam",
"Ma'am");
275 if (person.getRank() !=
null) {
276 map.put(
"$personRank", person.getRank().toLowerCase());
277 map.put(
"$PersonRank", Misc.ucFirst(person.getRank()));
280 if (person.getPost() !=
null) {
281 map.put(
"$personPost", person.getPost().toLowerCase());
282 map.put(
"$PersonPost", Misc.ucFirst(person.getPost()));
285 map.put(
"$PersonName", person.getName().getFullName());
286 map.put(
"$personName", person.getName().getFullName());
287 map.put(
"$personFirstName", person.getName().getFirst());
288 map.put(
"$personLastName", person.getName().getLast());
292 if (faction !=
null) {
293 float rel = faction.getRelationship(Factions.PLAYER);
294 RepLevel level = RepLevel.getLevelFor(rel);
295 map.put(
"$relAdjective", level.getDisplayName().toLowerCase());
298 if (personFaction !=
null) {
299 String factionName = personFaction.getEntityNamePrefix();
300 if (factionName ==
null || factionName.isEmpty()) {
301 factionName = personFaction.getDisplayName();
304 map.put(
"$personFactionIsOrAre", personFaction.getDisplayNameIsOrAre());
306 map.put(
"$personFaction", factionName);
307 map.put(
"$PersonFaction", Misc.ucFirst(factionName));
308 map.put(
"$thePersonFaction", personFaction.getDisplayNameWithArticle());
309 map.put(
"$ThePersonFaction", Misc.ucFirst(personFaction.getDisplayNameWithArticle()));
311 map.put(
"$personFactionLong", personFaction.getDisplayNameLong());
312 map.put(
"$PersonFactionLong", Misc.ucFirst(personFaction.getDisplayNameLong()));
313 map.put(
"$thePersonFactionLong", personFaction.getDisplayNameLongWithArticle());
314 map.put(
"$ThePersonFactionLong", Misc.ucFirst(personFaction.getDisplayNameLongWithArticle()));