Migrates Monster class to be storable in roomdb.
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
public class Ability {
|
||||
|
||||
public Ability(String name, String description) {
|
||||
mName = name;
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
private String mDescription;
|
||||
|
||||
public String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mDescription = description;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
public class Action {
|
||||
|
||||
public Action(String name, String description) {
|
||||
mName = name;
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
private String mDescription;
|
||||
|
||||
public String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mDescription = description;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
public class DamageType {
|
||||
|
||||
public DamageType(String name, String note, String type) {
|
||||
mName = name;
|
||||
mNote = note;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String value) {
|
||||
mName = value;
|
||||
}
|
||||
|
||||
private String mNote;
|
||||
|
||||
public String getNote() {
|
||||
return mNote;
|
||||
}
|
||||
|
||||
public void setNote(String value) {
|
||||
mNote = value;
|
||||
}
|
||||
|
||||
private String mType;
|
||||
|
||||
public String getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
public void setType(String value) {
|
||||
mType = value;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,70 +1,69 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public class Skill implements Comparator<Skill>, Comparable<Skill> {
|
||||
|
||||
private String mName;
|
||||
private String mAbilityScoreName;
|
||||
private String mNote;
|
||||
public String name;
|
||||
public AbilityScore abilityScore;
|
||||
public AdvantageType advantageType;
|
||||
public ProficiencyType proficiencyType;
|
||||
|
||||
public Skill(String name, String abilityScoreName) {
|
||||
mName = name;
|
||||
mAbilityScoreName = abilityScoreName;
|
||||
mNote = "";
|
||||
public Skill(String name, AbilityScore abilityScore) {
|
||||
this(name, abilityScore, AdvantageType.NONE, ProficiencyType.PROFICIENT);
|
||||
}
|
||||
|
||||
public Skill(String name, String abilityScoreName, String note) {
|
||||
mName = name;
|
||||
mAbilityScoreName = abilityScoreName;
|
||||
mNote = note;
|
||||
public Skill(String name, AbilityScore abilityScore, AdvantageType advantageType) {
|
||||
this(name, abilityScore, advantageType, ProficiencyType.PROFICIENT);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public String getAbilityScoreName() {
|
||||
return mAbilityScoreName;
|
||||
}
|
||||
|
||||
public void setAbilityScoreName(String abilityScoreName) {
|
||||
mAbilityScoreName = abilityScoreName;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return mNote;
|
||||
public Skill(String name, AbilityScore abilityScore, AdvantageType advantageType, ProficiencyType proficiencyType) {
|
||||
this.name = name;
|
||||
this.abilityScore = abilityScore;
|
||||
this.advantageType = advantageType;
|
||||
this.proficiencyType = proficiencyType;
|
||||
}
|
||||
|
||||
public int getSkillBonus(Monster monster) {
|
||||
int bonus = monster.getAbilityModifier(mAbilityScoreName);
|
||||
if (" (ex)".equals(getNote())) {
|
||||
bonus += 2 * monster.getProficiencyBonus();
|
||||
} else {
|
||||
bonus += monster.getProficiencyBonus();
|
||||
int modifier = monster.getAbilityModifier(abilityScore);
|
||||
switch (proficiencyType) {
|
||||
case PROFICIENT:
|
||||
return modifier + monster.getProficiencyBonus();
|
||||
case EXPERTISE:
|
||||
return modifier + monster.getProficiencyBonus() * 2;
|
||||
case NONE:
|
||||
default:
|
||||
return modifier;
|
||||
}
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public String getText(Monster monster) {
|
||||
int bonus = getSkillBonus(monster);
|
||||
|
||||
return String.format(Locale.US, "%s%s %d", mName.substring(0, 1), mName.substring(1), bonus);
|
||||
return String.format(
|
||||
"%s%s %+d%s",
|
||||
name.substring(0, 1),
|
||||
name.substring(1),
|
||||
bonus,
|
||||
advantageType == AdvantageType.ADVANTAGE ? " A" : advantageType == AdvantageType.DISADVANTAGE ? " D" : ""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Skill o) {
|
||||
return this.getName().compareToIgnoreCase(o.getName());
|
||||
return this.name.compareToIgnoreCase(o.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Skill o1, Skill o2) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
return o1.name.compareToIgnoreCase(o2.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Trait implements Comparator<Trait>, Comparable<Trait> {
|
||||
public class Trait {
|
||||
|
||||
public String name;
|
||||
public String description;
|
||||
@@ -14,36 +9,4 @@ public class Trait implements Comparator<Trait>, Comparable<Trait> {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Trait o) {
|
||||
return compare(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Trait o1, Trait o2) {
|
||||
int result = o1.name.compareToIgnoreCase(o2.name);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return o1.description.compareToIgnoreCase(o2.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Trait)) {
|
||||
return false;
|
||||
}
|
||||
Trait otherTrait = (Trait) obj;
|
||||
if (!Objects.equals(this.name, otherTrait.name)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.description, otherTrait.description)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user