Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adventure hotfixes #4477

Merged
merged 5 commits into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ public boolean checkIfTargetLocation(PointOfInterest locationToCheck) {

public boolean checkIfTargetEnemy(EnemySprite enemy) {
if (targetEnemyData != null) {
return enemy.getData() == targetEnemyData;
return (enemy.getData().match(targetEnemyData));
}
else if (targetSprite == null) {
ArrayList<String> candidateTags = new ArrayList<>(Arrays.asList(enemy.getData().questTags));
16 changes: 16 additions & 0 deletions forge-gui-mobile/src/forge/adventure/data/EnemyData.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
import forge.util.Aggregates;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

/**
* Data class that will be used to read Json configuration files
@@ -90,4 +92,18 @@ public String getName(){
return name;
return "(Unnamed Enemy)";
}

public boolean match(EnemyData other) {
//equals() does not cover cases where data is updated to override speed, displayname, etc
if (this.equals(other))
return true;
if (!this.name.equals(other.name))
return false;
if (questTags.length != other.questTags.length)
return false;
ArrayList<String> myQuestTags = new ArrayList<>(Arrays.asList(questTags));
ArrayList<String> otherQuestTags = new ArrayList<>(Arrays.asList(other.questTags));
myQuestTags.removeAll(otherQuestTags);
return myQuestTags.isEmpty();
}
}