Fixes default values for array/set properties of monsters in db.

Removes individual senses properties and replaces with a Set<String>.
This commit is contained in:
2021-06-20 02:14:48 -07:00
committed by Tom Hicks
parent 6151ad889c
commit 2356726e3f
5 changed files with 60 additions and 132 deletions

View File

@@ -74,14 +74,10 @@ public class EditMonsterViewModel extends ViewModel {
private final ChangeTrackedLiveData<ChallengeRating> mChallengeRating;
private final ChangeTrackedLiveData<String> mCustomChallengeRatingDescription;
private final ChangeTrackedLiveData<Integer> mCustomProficiencyBonus;
private final ChangeTrackedLiveData<Integer> mBlindsightRange;
private final ChangeTrackedLiveData<Boolean> mIsBlindBeyondBlindsightRange;
private final ChangeTrackedLiveData<Integer> mDarkvisionRange;
private final ChangeTrackedLiveData<Integer> mTremorsenseRange;
private final ChangeTrackedLiveData<Integer> mTruesightRange;
private final ChangeTrackedLiveData<Integer> mTelepathyRange;
private final ChangeTrackedLiveData<String> mUnderstandsButDescription;
private final ChangeTrackedLiveData<List<Skill>> mSkills;
private final ChangeTrackedLiveData<List<String>> mSenses;
private final ChangeTrackedLiveData<Set<String>> mDamageImmunities;
private final ChangeTrackedLiveData<Set<String>> mDamageResistances;
private final ChangeTrackedLiveData<Set<String>> mDamageVulnerabilities;
@@ -144,14 +140,10 @@ public class EditMonsterViewModel extends ViewModel {
mChallengeRating = new ChangeTrackedLiveData<>(ChallengeRating.ONE_EIGHTH, onDirtied);
mCustomChallengeRatingDescription = new ChangeTrackedLiveData<>("", onDirtied);
mCustomProficiencyBonus = new ChangeTrackedLiveData<>(0, onDirtied);
mBlindsightRange = new ChangeTrackedLiveData<>(0, onDirtied);
mIsBlindBeyondBlindsightRange = new ChangeTrackedLiveData<>(false, onDirtied);
mDarkvisionRange = new ChangeTrackedLiveData<>(0, onDirtied);
mTremorsenseRange = new ChangeTrackedLiveData<>(0, onDirtied);
mTruesightRange = new ChangeTrackedLiveData<>(0, onDirtied);
mTelepathyRange = new ChangeTrackedLiveData<>(0, onDirtied);
mUnderstandsButDescription = new ChangeTrackedLiveData<>("", onDirtied);
mSkills = new ChangeTrackedLiveData<>(new ArrayList<>(), onDirtied);
mSenses = new ChangeTrackedLiveData<>(new ArrayList<>(), onDirtied);
mDamageImmunities = new ChangeTrackedLiveData<>(new HashSet<>(), onDirtied);
mDamageResistances = new ChangeTrackedLiveData<>(new HashSet<>(), onDirtied);
mDamageVulnerabilities = new ChangeTrackedLiveData<>(new HashSet<>(), onDirtied);
@@ -209,21 +201,15 @@ public class EditMonsterViewModel extends ViewModel {
mChallengeRating.resetValue(monster.challengeRating);
mCustomChallengeRatingDescription.resetValue(monster.customChallengeRatingDescription);
mCustomProficiencyBonus.resetValue(monster.customProficiencyBonus);
mBlindsightRange.resetValue(monster.blindsightRange);
mIsBlindBeyondBlindsightRange.resetValue(monster.isBlindBeyondBlindsightRange);
mDarkvisionRange.resetValue(monster.darkvisionRange);
mTremorsenseRange.resetValue(monster.tremorsenseRange);
mTruesightRange.resetValue(monster.truesightRange);
mTelepathyRange.resetValue(monster.telepathyRange);
mUnderstandsButDescription.resetValue(monster.understandsButDescription);
ArrayList<Skill> skills = new ArrayList<>(monster.skills);
if (skills.size() == 0) {
skills.add(new Skill("Acrobatics", AbilityScore.STRENGTH));
skills.add(new Skill("Stealth", AbilityScore.DEXTERITY));
}
Collections.sort(skills, (skill1, skill2) -> skill1.name.compareToIgnoreCase(skill2.name));
mSkills.resetValue(skills);
ArrayList<String> senses = new ArrayList<>(monster.senses);
Collections.sort(senses, String::compareToIgnoreCase);
mSenses.resetValue(senses);
mDamageImmunities.resetValue(monster.damageImmunities);
mDamageResistances.resetValue(monster.damageResistances);
mDamageVulnerabilities.resetValue(monster.damageVulnerabilities);
@@ -750,46 +736,6 @@ public class EditMonsterViewModel extends ViewModel {
return mCustomProficiencyBonus.getValue().toString();
}
public LiveData<Integer> getBlindsightRange() {
return mBlindsightRange;
}
public void setBlindsightRange(int blindsightRange) {
mBlindsightRange.setValue(blindsightRange);
}
public LiveData<Boolean> getIsBlindBeyondBlindsightRange() {
return mIsBlindBeyondBlindsightRange;
}
public void setIsBlindBeyondBlindsightRange(boolean isBlindBeyondBlindsightRange) {
mIsBlindBeyondBlindsightRange.setValue(isBlindBeyondBlindsightRange);
}
public LiveData<Integer> getDarkvisionRange() {
return mDarkvisionRange;
}
public void setDarkvisionRange(int darkvisionRange) {
mDarkvisionRange.setValue(darkvisionRange);
}
public LiveData<Integer> getTremorsenseRange() {
return mTremorsenseRange;
}
public void setTremorsenseRange(int tremorsenseRange) {
mTremorsenseRange.setValue(tremorsenseRange);
}
public LiveData<Integer> getTruesightRange() {
return mTruesightRange;
}
public void setTruesightRange(int truesightRange) {
mTruesightRange.setValue(truesightRange);
}
public LiveData<Integer> getTelepathyRange() {
return mTelepathyRange;
}
@@ -810,6 +756,10 @@ public class EditMonsterViewModel extends ViewModel {
return mSkills;
}
public List<String> getSensesArray() {
return mSenses.getValue();
}
// TODO: add getters and setters for lists of strings (Senses, Damage Immunities, Damage Resistances, Damage Vulnerabilities, and Condition Immunities)
// TODO: add getters and setters for Languages
// TODO: add getters and setters for traits (Abilities, Actions, Reactions, Lair Actions, Legendary Actions, and Regional Actions)
@@ -859,14 +809,10 @@ public class EditMonsterViewModel extends ViewModel {
monster.challengeRating = mChallengeRating.getValue();
monster.customChallengeRatingDescription = mCustomChallengeRatingDescription.getValue();
monster.customProficiencyBonus = mCustomProficiencyBonus.getValue();
monster.blindsightRange = mBlindsightRange.getValue();
monster.isBlindBeyondBlindsightRange = mIsBlindBeyondBlindsightRange.getValue();
monster.darkvisionRange = mDarkvisionRange.getValue();
monster.tremorsenseRange = mTremorsenseRange.getValue();
monster.truesightRange = mTruesightRange.getValue();
monster.telepathyRange = mTelepathyRange.getValue();
monster.understandsButDescription = mUnderstandsButDescription.getValue();
monster.skills = new HashSet<>(mSkills.getValue());
monster.senses = new HashSet<>(mSenses.getValue());
monster.damageImmunities = mDamageImmunities.getValue();
monster.damageResistances = mDamageResistances.getValue();
monster.damageVulnerabilities = mDamageVulnerabilities.getValue();