Merge commit 'd1e3c3f5f313057e5a81a4333906ef5d79adea83' as 'Android'
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Language implements Comparator<Language>, Comparable<Language> {
|
||||
|
||||
private String mName;
|
||||
private boolean mSpeaks;
|
||||
|
||||
public Language(String name, boolean speaks) {
|
||||
mName = name;
|
||||
mSpeaks = speaks;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String value) {
|
||||
mName = value;
|
||||
}
|
||||
|
||||
public boolean getSpeaks() {
|
||||
return mSpeaks;
|
||||
}
|
||||
|
||||
public void setSpeaks(boolean value) {
|
||||
mSpeaks = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Language o) {
|
||||
if (this.mSpeaks && !o.mSpeaks) {
|
||||
return -1;
|
||||
}
|
||||
if (!this.mSpeaks && o.mSpeaks) {
|
||||
return 1;
|
||||
}
|
||||
return this.mName.compareToIgnoreCase(o.mName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(@NonNull Language o1, Language o2) {
|
||||
if (o1.mSpeaks && !o2.mSpeaks) {
|
||||
return -1;
|
||||
}
|
||||
if (!o1.mSpeaks && o2.mSpeaks) {
|
||||
return 1;
|
||||
}
|
||||
return o1.mName.compareToIgnoreCase(o2.mName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Language)) {
|
||||
return false;
|
||||
}
|
||||
Language otherLanguage = (Language) obj;
|
||||
if (!Objects.equals(this.mName, otherLanguage.mName)) {
|
||||
return false;
|
||||
}
|
||||
if (this.mSpeaks != otherLanguage.mSpeaks) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Fts4;
|
||||
|
||||
@Entity(tableName = "monsters_fts")
|
||||
@Fts4(contentEntity = Monster.class)
|
||||
public class MonsterFTS {
|
||||
public String name;
|
||||
public String size;
|
||||
public String type;
|
||||
public String subtype;
|
||||
public String alignment;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.majinnaibu.monstercards.models;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public class Skill implements Comparator<Skill>, Comparable<Skill> {
|
||||
|
||||
public String name;
|
||||
public AbilityScore abilityScore;
|
||||
public AdvantageType advantageType;
|
||||
public ProficiencyType proficiencyType;
|
||||
|
||||
public Skill(String name, AbilityScore abilityScore) {
|
||||
this(name, abilityScore, AdvantageType.NONE, ProficiencyType.PROFICIENT);
|
||||
}
|
||||
|
||||
public Skill(String name, AbilityScore abilityScore, AdvantageType advantageType) {
|
||||
this(name, abilityScore, advantageType, ProficiencyType.PROFICIENT);
|
||||
}
|
||||
|
||||
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 modifier = monster.getAbilityModifier(abilityScore);
|
||||
switch (proficiencyType) {
|
||||
case PROFICIENT:
|
||||
return modifier + monster.getProficiencyBonus();
|
||||
case EXPERTISE:
|
||||
return modifier + monster.getProficiencyBonus() * 2;
|
||||
case NONE:
|
||||
default:
|
||||
return modifier;
|
||||
}
|
||||
}
|
||||
|
||||
public String getText(Monster monster) {
|
||||
int bonus = getSkillBonus(monster);
|
||||
|
||||
return String.format(
|
||||
"%s%s %+d%s",
|
||||
name.charAt(0),
|
||||
name.substring(1),
|
||||
bonus,
|
||||
advantageType == AdvantageType.ADVANTAGE ? " A" : advantageType == AdvantageType.DISADVANTAGE ? " D" : ""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Skill o) {
|
||||
return this.name.compareToIgnoreCase(o.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Skill o1, Skill o2) {
|
||||
return o1.name.compareToIgnoreCase(o2.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Skill)) {
|
||||
return false;
|
||||
}
|
||||
Skill otherSkill = (Skill) obj;
|
||||
if (!Objects.equals(this.name, otherSkill.name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.abilityScore != otherSkill.abilityScore) {
|
||||
return false;
|
||||
}
|
||||
if (this.advantageType != otherSkill.advantageType) {
|
||||
return false;
|
||||
}
|
||||
if (this.proficiencyType != otherSkill.proficiencyType) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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 String name;
|
||||
public String description;
|
||||
|
||||
public Trait(String name, String description) {
|
||||
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