forked from External/mage
tests: fixed random fails in RadiateTest (wrong MOR predicate code, #9550)
This commit is contained in:
parent
e92031a3bb
commit
6f12d62882
5 changed files with 32 additions and 10 deletions
|
|
@ -36,6 +36,11 @@ public interface MageObject extends MageItem, Serializable, Copyable<MageObject>
|
|||
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Warning, don't use it as a key - multiple objects can have same parts of the id in rare use cases
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getIdName();
|
||||
|
||||
String getLogName();
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
@Override
|
||||
public int compareTo(MageObjectReference o) {
|
||||
if (o.getSourceId() == null || this.sourceId == null || Objects.equals(o.getSourceId(), this.sourceId)) {
|
||||
return o.getZoneChangeCounter() - this.zoneChangeCounter;
|
||||
return Integer.compare(o.getZoneChangeCounter(), this.zoneChangeCounter);
|
||||
}
|
||||
return o.getSourceId().compareTo(sourceId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,27 @@ public class MageObjectReferencePredicate implements Predicate<MageItem> {
|
|||
}
|
||||
|
||||
public String getName(Game game) {
|
||||
UUID id = null;
|
||||
String name = null;
|
||||
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null) {
|
||||
return permanent.getIdName();
|
||||
id = permanent.getId();
|
||||
name = permanent.getName();
|
||||
}
|
||||
|
||||
Player player = game.getPlayer(mor.getSourceId());
|
||||
if (player != null) {
|
||||
return player.getName();
|
||||
id = player.getId();
|
||||
name = player.getName();
|
||||
}
|
||||
|
||||
// workaround to use unique keys for choose dialog (getIdName can't be used here)
|
||||
if (id != null) {
|
||||
return String.format("%s [%s]", name, id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue