use first 3 elements in data (MagicEvent) and choiceResults (MagicItemOnStack) to compute hash
parent
f7a4d19c6f
commit
640d3b9adc
|
@ -194,10 +194,12 @@ public class MagicEvent implements MagicCopyable {
|
||||||
|
|
||||||
public long getEventId() {
|
public long getEventId() {
|
||||||
long[] keys = {
|
long[] keys = {
|
||||||
(player != null ? player.getIndex() : 7),
|
(player != null ? player.getIndex() : -1L),
|
||||||
(source != null ? source.getId() : 7),
|
(source != null ? source.getId() : -1L),
|
||||||
(action != null ? action.hashCode() : 7),
|
(action != null ? action.hashCode() : -1L),
|
||||||
(data.length > 0 && data[0] instanceof MagicTarget) ? ((MagicTarget)data[0]).getId() : 7,
|
(data.length > 0 && data[0] instanceof MagicTarget) ? ((MagicTarget)data[0]).getId() : -1L,
|
||||||
|
(data.length > 1 && data[1] instanceof MagicTarget) ? ((MagicTarget)data[1]).getId() : -1L,
|
||||||
|
(data.length > 2 && data[2] instanceof MagicTarget) ? ((MagicTarget)data[2]).getId() : -1L,
|
||||||
};
|
};
|
||||||
return magic.MurmurHash3.hash(keys);
|
return magic.MurmurHash3.hash(keys);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,10 +145,16 @@ public abstract class MagicItemOnStack implements MagicTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getItemId() {
|
public long getItemId() {
|
||||||
return
|
final long[] keys = {
|
||||||
event.getEventId() +
|
event.getEventId(),
|
||||||
((choiceResults.length > 0 && choiceResults[0] instanceof MagicTarget) ?
|
((choiceResults.length > 0 && choiceResults[0] instanceof MagicTarget) ?
|
||||||
((MagicTarget)choiceResults[0]).getId() : 7);
|
((MagicTarget)choiceResults[0]).getId() : -1L),
|
||||||
|
((choiceResults.length > 1 && choiceResults[1] instanceof MagicTarget) ?
|
||||||
|
((MagicTarget)choiceResults[1]).getId() : -1L),
|
||||||
|
((choiceResults.length > 2 && choiceResults[2] instanceof MagicTarget) ?
|
||||||
|
((MagicTarget)choiceResults[2]).getId() : -1L),
|
||||||
|
};
|
||||||
|
return magic.MurmurHash3.hash(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isSpell();
|
public abstract boolean isSpell();
|
||||||
|
|
Loading…
Reference in New Issue