Simplify extraction of player/opponent name from card name

This commit is contained in:
drdev
2016-02-07 21:56:04 +00:00
parent bdc33789b0
commit 8d463f3d5e
2 changed files with 12 additions and 6 deletions

View File

@@ -65,13 +65,10 @@ public class ConquestCommander implements InventoryItem, IXmlWritable {
public String getPlayerName() { public String getPlayerName() {
String name = card.getName(); String name = card.getName();
int idx = name.indexOf(' '); int idx = name.indexOf(',');
if (idx != -1) { if (idx != -1) { //trim everything after the comma
name = name.substring(0, idx); name = name.substring(0, idx);
} }
if (name.endsWith(",") || name.endsWith("-")) {
name = name.substring(0, name.length() - 1).trim();
}
return name; return name;
} }

View File

@@ -83,6 +83,15 @@ public class ConquestEvent {
return avatarCard; return avatarCard;
} }
public String getOpponentName() {
String name = avatar;
int idx = name.indexOf(',');
if (idx != -1) { //trim everything after the comma
name = name.substring(0, idx);
}
return name;
}
public ConquestBattle createBattle(ConquestLocation location0, int tier0) { public ConquestBattle createBattle(ConquestLocation location0, int tier0) {
return new ConquestEventBattle(location0, tier0); return new ConquestEventBattle(location0, tier0);
} }
@@ -171,7 +180,7 @@ public class ConquestEvent {
@Override @Override
public String getOpponentName() { public String getOpponentName() {
return ConquestEvent.this.getAvatar(); return ConquestEvent.this.getOpponentName();
} }
@Override @Override