Cleans up import and export options.
This commit is contained in:
@@ -4,27 +4,46 @@ import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BinderExport {
|
||||
@SerializedName("$schema")
|
||||
public String schema = "https://majinnaibu.com/schemas/binder.schema.json";
|
||||
|
||||
@SerializedName("schemaVersion")
|
||||
public int schemaVersion = 1;
|
||||
|
||||
@SerializedName("collections")
|
||||
public List<CollectionExport> collections = new ArrayList<>();
|
||||
|
||||
@SerializedName("dashboard")
|
||||
public List<Monster> dashboard = new ArrayList<>();
|
||||
|
||||
public static class CollectionExport {
|
||||
@SerializedName("id")
|
||||
public String id;
|
||||
|
||||
@SerializedName("name")
|
||||
public String name;
|
||||
|
||||
@SerializedName("description")
|
||||
public String description;
|
||||
|
||||
@SerializedName("cards")
|
||||
public List<Monster> cards = new ArrayList<>();
|
||||
|
||||
public CollectionExport() {
|
||||
}
|
||||
|
||||
public CollectionExport(String name, List<Monster> cards) {
|
||||
public CollectionExport(String id, String name, String description, List<Monster> cards) {
|
||||
this.id = id != null ? id : UUID.randomUUID().toString();
|
||||
this.name = name != null ? name : "";
|
||||
this.description = description != null ? description : "";
|
||||
this.cards = cards != null ? cards : new ArrayList<>();
|
||||
}
|
||||
|
||||
public CollectionExport(String name, List<Monster> cards) {
|
||||
this(UUID.randomUUID().toString(), name, "", cards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
||||
@@ -30,11 +31,16 @@ import java.util.UUID;
|
||||
@SuppressWarnings("unused")
|
||||
public class Monster {
|
||||
|
||||
@SerializedName("$schema")
|
||||
@Ignore
|
||||
public String schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||
|
||||
@Ignore
|
||||
public int schemaVersion = 1;
|
||||
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
@SerializedName("id")
|
||||
public UUID id;
|
||||
|
||||
@NonNull
|
||||
@@ -438,7 +444,10 @@ public class Monster {
|
||||
}
|
||||
}
|
||||
|
||||
public int getAbilityModifier(@NonNull AbilityScore abilityScore) {
|
||||
public int getAbilityModifier(@Nullable AbilityScore abilityScore) {
|
||||
if (abilityScore == null) {
|
||||
return 0;
|
||||
}
|
||||
switch (abilityScore) {
|
||||
case STRENGTH:
|
||||
return getStrengthModifier();
|
||||
|
||||
@@ -34,13 +34,25 @@ public class Skill implements Comparator<Skill>, Comparable<Skill> {
|
||||
this.proficiencyType = proficiencyType;
|
||||
}
|
||||
|
||||
public AbilityScore getAbilityScore() {
|
||||
if (abilityScore != null) {
|
||||
return abilityScore;
|
||||
}
|
||||
if (name != null) {
|
||||
return AbilityScore.valueOfString(name);
|
||||
}
|
||||
return AbilityScore.STRENGTH;
|
||||
}
|
||||
|
||||
public int getSkillBonus(Monster monster) {
|
||||
int modifier = monster.getAbilityModifier(abilityScore);
|
||||
switch (proficiencyType) {
|
||||
AbilityScore score = getAbilityScore();
|
||||
int modifier = monster != null ? monster.getAbilityModifier(score) : 0;
|
||||
ProficiencyType prof = proficiencyType != null ? proficiencyType : ProficiencyType.PROFICIENT;
|
||||
switch (prof) {
|
||||
case PROFICIENT:
|
||||
return modifier + monster.getProficiencyBonus();
|
||||
return modifier + (monster != null ? monster.getProficiencyBonus() : 0);
|
||||
case EXPERTISE:
|
||||
return modifier + monster.getProficiencyBonus() * 2;
|
||||
return modifier + (monster != null ? monster.getProficiencyBonus() * 2 : 0);
|
||||
case NONE:
|
||||
default:
|
||||
return modifier;
|
||||
|
||||
Reference in New Issue
Block a user