Creates initial app database class and adds minimal DTO support for monsters.
This commit is contained in:
		| @@ -2,11 +2,11 @@ | |||||||
|   "formatVersion": 1, |   "formatVersion": 1, | ||||||
|   "database": { |   "database": { | ||||||
|     "version": 1, |     "version": 1, | ||||||
|     "identityHash": "db1293d2f490940b55ca1f4f56b21b1a", |     "identityHash": "a9371223372fb64522cc40f5529ada09", | ||||||
|     "entities": [ |     "entities": [ | ||||||
|       { |       { | ||||||
|         "tableName": "Monster", |         "tableName": "Monster", | ||||||
|         "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `blindsight_range` INTEGER NOT NULL DEFAULT 0, `is_blind_beyond_blindsight_range` INTEGER NOT NULL DEFAULT false, `darkvision_range` INTEGER NOT NULL DEFAULT 0, `tremorsense_range` INTEGER NOT NULL DEFAULT 0, `truesight_range` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `skills` TEXT, `damage_immunities` TEXT, `damage_resistances` TEXT, `damage_vulnerabilities` TEXT, `condition_immunities` TEXT, `languages` TEXT, `abilities` TEXT, `actions` TEXT, `reactions` TEXT, `lair_actions` TEXT, `legendary_actions` TEXT, `regional_actions` TEXT, PRIMARY KEY(`id`))", |         "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))", | ||||||
|         "fields": [ |         "fields": [ | ||||||
|           { |           { | ||||||
|             "fieldPath": "id", |             "fieldPath": "id", | ||||||
| @@ -20,405 +20,6 @@ | |||||||
|             "affinity": "TEXT", |             "affinity": "TEXT", | ||||||
|             "notNull": true, |             "notNull": true, | ||||||
|             "defaultValue": "''" |             "defaultValue": "''" | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "size", |  | ||||||
|             "columnName": "size", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "type", |  | ||||||
|             "columnName": "type", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "subtype", |  | ||||||
|             "columnName": "subtype", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "alignment", |  | ||||||
|             "columnName": "alignment", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "strengthScore", |  | ||||||
|             "columnName": "strength_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "strengthSavingThrowAdvantage", |  | ||||||
|             "columnName": "strength_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "strengthSavingThrowProficiency", |  | ||||||
|             "columnName": "strength_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "dexterityScore", |  | ||||||
|             "columnName": "dexterity_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "dexteritySavingThrowAdvantage", |  | ||||||
|             "columnName": "dexterity_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "dexteritySavingThrowProficiency", |  | ||||||
|             "columnName": "dexterity_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "constitutionScore", |  | ||||||
|             "columnName": "constitution_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "constitutionSavingThrowAdvantage", |  | ||||||
|             "columnName": "constitution_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "constitutionSavingThrowProficiency", |  | ||||||
|             "columnName": "constitution_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "intelligenceScore", |  | ||||||
|             "columnName": "intelligence_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "intelligenceSavingThrowAdvantage", |  | ||||||
|             "columnName": "intelligence_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "intelligenceSavingThrowProficiency", |  | ||||||
|             "columnName": "intelligence_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "wisdomScore", |  | ||||||
|             "columnName": "wisdom_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "wisdomSavingThrowAdvantage", |  | ||||||
|             "columnName": "wisdom_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "wisdomSavingThrowProficiency", |  | ||||||
|             "columnName": "wisdom_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "charismaScore", |  | ||||||
|             "columnName": "charisma_score", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "10" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "charismaSavingThrowAdvantage", |  | ||||||
|             "columnName": "charisma_saving_throw_advantage", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "charismaSavingThrowProficiency", |  | ||||||
|             "columnName": "charisma_saving_throw_proficiency", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "armorType", |  | ||||||
|             "columnName": "armor_type", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'none'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "shieldBonus", |  | ||||||
|             "columnName": "shield_bonus", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "naturalArmorBonus", |  | ||||||
|             "columnName": "natural_armor_bonus", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "otherArmorDescription", |  | ||||||
|             "columnName": "other_armor_description", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "hitDice", |  | ||||||
|             "columnName": "hit_dice", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "1" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "hasCustomHP", |  | ||||||
|             "columnName": "has_custom_hit_points", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "customHPDescription", |  | ||||||
|             "columnName": "custom_hit_points_description", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "walkSpeed", |  | ||||||
|             "columnName": "walk_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "burrowSpeed", |  | ||||||
|             "columnName": "burrow_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "climbSpeed", |  | ||||||
|             "columnName": "climb_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "flySpeed", |  | ||||||
|             "columnName": "fly_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "canHover", |  | ||||||
|             "columnName": "can_hover", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "false" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "swimSpeed", |  | ||||||
|             "columnName": "swim_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "hasCustomSpeed", |  | ||||||
|             "columnName": "has_custom_speed", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "false" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "customSpeedDescription", |  | ||||||
|             "columnName": "custom_speed_description", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "challengeRating", |  | ||||||
|             "columnName": "challenge_rating", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "'1'" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "customChallengeRatingDescription", |  | ||||||
|             "columnName": "custom_challenge_rating_description", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "customProficiencyBonus", |  | ||||||
|             "columnName": "custom_proficiency_bonus", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "blindsightRange", |  | ||||||
|             "columnName": "blindsight_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "isBlindBeyondBlindsightRange", |  | ||||||
|             "columnName": "is_blind_beyond_blindsight_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "false" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "darkvisionRange", |  | ||||||
|             "columnName": "darkvision_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "tremorsenseRange", |  | ||||||
|             "columnName": "tremorsense_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "truesightRange", |  | ||||||
|             "columnName": "truesight_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "telepathyRange", |  | ||||||
|             "columnName": "telepathy_range", |  | ||||||
|             "affinity": "INTEGER", |  | ||||||
|             "notNull": true, |  | ||||||
|             "defaultValue": "0" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "understandsButDescription", |  | ||||||
|             "columnName": "understands_but_description", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false, |  | ||||||
|             "defaultValue": "''" |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "skills", |  | ||||||
|             "columnName": "skills", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "damageImmunities", |  | ||||||
|             "columnName": "damage_immunities", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "damageResistances", |  | ||||||
|             "columnName": "damage_resistances", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "damageVulnerabilities", |  | ||||||
|             "columnName": "damage_vulnerabilities", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "conditionImmunities", |  | ||||||
|             "columnName": "condition_immunities", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "languages", |  | ||||||
|             "columnName": "languages", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "abilities", |  | ||||||
|             "columnName": "abilities", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "actions", |  | ||||||
|             "columnName": "actions", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "reactions", |  | ||||||
|             "columnName": "reactions", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "lairActions", |  | ||||||
|             "columnName": "lair_actions", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "legendaryActions", |  | ||||||
|             "columnName": "legendary_actions", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           }, |  | ||||||
|           { |  | ||||||
|             "fieldPath": "regionalActions", |  | ||||||
|             "columnName": "regional_actions", |  | ||||||
|             "affinity": "TEXT", |  | ||||||
|             "notNull": false |  | ||||||
|           } |           } | ||||||
|         ], |         ], | ||||||
|         "primaryKey": { |         "primaryKey": { | ||||||
| @@ -434,7 +35,7 @@ | |||||||
|     "views": [], |     "views": [], | ||||||
|     "setupQueries": [ |     "setupQueries": [ | ||||||
|       "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", |       "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||||||
|       "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'db1293d2f490940b55ca1f4f56b21b1a')" |       "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a9371223372fb64522cc40f5529ada09')" | ||||||
|     ] |     ] | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @@ -4,27 +4,12 @@ import androidx.room.Database; | |||||||
| import androidx.room.RoomDatabase; | import androidx.room.RoomDatabase; | ||||||
| import androidx.room.TypeConverters; | import androidx.room.TypeConverters; | ||||||
|  |  | ||||||
|  | import com.majinnaibu.monstercards.converters.UUIDConverter; | ||||||
| import com.majinnaibu.monstercards.data.MonsterDAO; | import com.majinnaibu.monstercards.data.MonsterDAO; | ||||||
| import com.majinnaibu.monstercards.data.converters.ArmorTypeConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.ChallengeRatingConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.ListOfTraitsConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.SetOfLanguageConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.SetOfSkillConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.SetOfStringConverter; |  | ||||||
| import com.majinnaibu.monstercards.data.converters.UUIDConverter; |  | ||||||
| import com.majinnaibu.monstercards.models.Monster; | import com.majinnaibu.monstercards.models.Monster; | ||||||
| import com.majinnaibu.monstercards.models.MonsterFTS; |  | ||||||
|  |  | ||||||
| @Database(entities = {Monster.class, MonsterFTS.class}, version = 3) | @Database(entities = {Monster.class}, version=1) | ||||||
| @TypeConverters({ | @TypeConverters({UUIDConverter.class}) | ||||||
|         ArmorTypeConverter.class, |  | ||||||
|         ChallengeRatingConverter.class, |  | ||||||
|         ListOfTraitsConverter.class, |  | ||||||
|         SetOfLanguageConverter.class, |  | ||||||
|         SetOfSkillConverter.class, |  | ||||||
|         SetOfStringConverter.class, |  | ||||||
|         UUIDConverter.class, |  | ||||||
| }) |  | ||||||
| public abstract class AppDatabase extends RoomDatabase { | public abstract class AppDatabase extends RoomDatabase { | ||||||
|     public abstract MonsterDAO monsterDAO(); |     public abstract MonsterDAO monsterDAO(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,18 @@ | |||||||
|  | package com.majinnaibu.monstercards.converters; | ||||||
|  |  | ||||||
|  | import androidx.room.TypeConverter; | ||||||
|  |  | ||||||
|  | import java.util.UUID; | ||||||
|  |  | ||||||
|  | public class UUIDConverter { | ||||||
|  |  | ||||||
|  |     @TypeConverter | ||||||
|  |     public static String fromUUID(UUID uuid) { | ||||||
|  |         return uuid.toString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @TypeConverter | ||||||
|  |     public static UUID uuidFromString(String string) { | ||||||
|  |         return UUID.fromString(string); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,7 +4,6 @@ package com.majinnaibu.monstercards.data; | |||||||
| import androidx.room.Dao; | import androidx.room.Dao; | ||||||
| import androidx.room.Delete; | import androidx.room.Delete; | ||||||
| import androidx.room.Insert; | import androidx.room.Insert; | ||||||
| import androidx.room.OnConflictStrategy; |  | ||||||
| import androidx.room.Query; | import androidx.room.Query; | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.models.Monster; | import com.majinnaibu.monstercards.models.Monster; | ||||||
| @@ -16,24 +15,18 @@ import io.reactivex.rxjava3.core.Flowable; | |||||||
|  |  | ||||||
| @Dao | @Dao | ||||||
| public interface MonsterDAO { | public interface MonsterDAO { | ||||||
|     @Query("SELECT * FROM monsters") |     @Query("SELECT * FROM monster") | ||||||
|     Flowable<List<Monster>> getAll(); |     Flowable<List<Monster>> getAll(); | ||||||
|  |  | ||||||
|     @Query("SELECT * FROM monsters WHERE id IN (:monsterIds)") |     @Query("SELECT * FROM monster WHERE id IN (:monsterIds)") | ||||||
|     Flowable<List<Monster>> loadAllByIds(String[] monsterIds); |     Flowable<List<Monster>> loadAllByIds(String[] monsterIds); | ||||||
|  |  | ||||||
|     @Query("SELECT * FROM monsters WHERE name LIKE :name LIMIT 1") |     @Query("SELECT * FROM monster WHERE name LIKE :name LIMIT 1") | ||||||
|     Flowable<Monster> findByName(String name); |     Flowable<Monster> findByName(String name); | ||||||
|  |  | ||||||
|     @Query("SELECT monsters.* FROM monsters JOIN monsters_fts ON monsters.oid = monsters_fts.docid WHERE monsters_fts MATCH :searchText") |  | ||||||
|     Flowable<List<Monster>> search(String searchText); |  | ||||||
|  |  | ||||||
|     @Insert |     @Insert | ||||||
|     Completable insertAll(Monster... monsters); |     Completable insertAll(Monster... monsters); | ||||||
|  |  | ||||||
|     @Insert(onConflict = OnConflictStrategy.REPLACE) |  | ||||||
|     Completable save(Monster... monsters); |  | ||||||
|  |  | ||||||
|     @Delete |     @Delete | ||||||
|     Completable delete(Monster monster); |     Completable delete(Monster monster); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,11 @@ | |||||||
| package com.majinnaibu.monstercards.models; | package com.majinnaibu.monstercards.models; | ||||||
|  |  | ||||||
|  | import androidx.annotation.NonNull; | ||||||
|  | import androidx.room.ColumnInfo; | ||||||
|  | import androidx.room.Entity; | ||||||
|  | import androidx.room.Ignore; | ||||||
|  | import androidx.room.PrimaryKey; | ||||||
|  |  | ||||||
| import com.majinnaibu.monstercards.helpers.StringHelper; | import com.majinnaibu.monstercards.helpers.StringHelper; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| @@ -9,11 +15,23 @@ import java.util.HashSet; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  | import java.util.UUID; | ||||||
|  |  | ||||||
|  | @Entity | ||||||
| public class Monster { | public class Monster { | ||||||
|  |  | ||||||
|  |     @PrimaryKey | ||||||
|  |     @NonNull | ||||||
|  |     public UUID id; | ||||||
|  |  | ||||||
|  |     @NonNull | ||||||
|  |     @ColumnInfo(defaultValue = "") | ||||||
|  |     public String name; | ||||||
|  |  | ||||||
|     public Monster() { |     public Monster() { | ||||||
|  |         name = ""; | ||||||
|         mAbilities = new ArrayList<>(); |         mAbilities = new ArrayList<>(); | ||||||
|  |         mActions = new ArrayList<>(); | ||||||
|         mConditionImmunities = new HashSet<>(); |         mConditionImmunities = new HashSet<>(); | ||||||
|         mDamageTypes = new HashSet<>(); |         mDamageTypes = new HashSet<>(); | ||||||
|         mLanguages = new HashSet<>(); |         mLanguages = new HashSet<>(); | ||||||
| @@ -21,42 +39,46 @@ public class Monster { | |||||||
|         mSkills = new HashSet<>(); |         mSkills = new HashSet<>(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private String mName; |     @Ignore() | ||||||
|     public String getName() { |  | ||||||
|         return mName; |  | ||||||
|     } |  | ||||||
|     public void setName(String value) { |  | ||||||
|         mName = value; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private String mSize; |     private String mSize; | ||||||
|  |  | ||||||
|     public String getSize() { |     public String getSize() { | ||||||
|         return mSize; |         return mSize; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSize(String value) { |     public void setSize(String value) { | ||||||
|         mSize = value; |         mSize = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mType; |     private String mType; | ||||||
|  |  | ||||||
|     public String getType() { |     public String getType() { | ||||||
|         return mType; |         return mType; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setType(String value) { |     public void setType(String value) { | ||||||
|         mType = value; |         mType = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mTag; |     private String mTag; | ||||||
|  |  | ||||||
|     public String getTag() { |     public String getTag() { | ||||||
|         return mTag; |         return mTag; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setTag(String value) { |     public void setTag(String value) { | ||||||
|         mTag = value; |         mTag = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mAlignment; |     private String mAlignment; | ||||||
|  |  | ||||||
|     public String getAlignment() { |     public String getAlignment() { | ||||||
|         return mAlignment; |         return mAlignment; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setAlignment(String value) { |     public void setAlignment(String value) { | ||||||
|         mAlignment = value; |         mAlignment = value; | ||||||
|     } |     } | ||||||
| @@ -120,7 +142,7 @@ public class Monster { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static int getAbilityModifierForScore(int score) { |     public static int getAbilityModifierForScore(int score) { | ||||||
|         return (int)Math.floor((score-10)/2.0); |         return (int) Math.floor((score - 10) / 2.0); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getAbilityModifier(String abilityScoreName) { |     public int getAbilityModifier(String abilityScoreName) { | ||||||
| @@ -128,100 +150,136 @@ public class Monster { | |||||||
|         return getAbilityModifierForScore(score); |         return getAbilityModifierForScore(score); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mStrengthScore; |     private int mStrengthScore; | ||||||
|  |  | ||||||
|     public int getStrengthScore() { |     public int getStrengthScore() { | ||||||
|         return mStrengthScore; |         return mStrengthScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setStrengthScore(int value) { |     public void setStrengthScore(int value) { | ||||||
|         mStrengthScore = value; |         mStrengthScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getStrengthModifier() { |     public int getStrengthModifier() { | ||||||
|         return getAbilityModifierForScore(getStrengthScore()); |         return getAbilityModifierForScore(getStrengthScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mDexterityScore; |     private int mDexterityScore; | ||||||
|  |  | ||||||
|     public int getDexterityScore() { |     public int getDexterityScore() { | ||||||
|         return mDexterityScore; |         return mDexterityScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setDexterityScore(int value) { |     public void setDexterityScore(int value) { | ||||||
|         mDexterityScore = value; |         mDexterityScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getDexterityModifier() { |     public int getDexterityModifier() { | ||||||
|         return getAbilityModifierForScore(getDexterityScore()); |         return getAbilityModifierForScore(getDexterityScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mConstitutionScore; |     private int mConstitutionScore; | ||||||
|  |  | ||||||
|     public int getConstitutionScore() { |     public int getConstitutionScore() { | ||||||
|         return mConstitutionScore; |         return mConstitutionScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setConstitutionScore(int value) { |     public void setConstitutionScore(int value) { | ||||||
|         mConstitutionScore = value; |         mConstitutionScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getConstitutionModifier() { |     public int getConstitutionModifier() { | ||||||
|         return getAbilityModifierForScore(getConstitutionScore()); |         return getAbilityModifierForScore(getConstitutionScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mIntelligenceScore; |     private int mIntelligenceScore; | ||||||
|  |  | ||||||
|     public int getIntelligenceScore() { |     public int getIntelligenceScore() { | ||||||
|         return mIntelligenceScore; |         return mIntelligenceScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setIntelligenceScore(int value) { |     public void setIntelligenceScore(int value) { | ||||||
|         mIntelligenceScore = value; |         mIntelligenceScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getIntelligenceModifier() { |     public int getIntelligenceModifier() { | ||||||
|         return getAbilityModifierForScore(getIntelligenceScore()); |         return getAbilityModifierForScore(getIntelligenceScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mWisdomScore; |     private int mWisdomScore; | ||||||
|  |  | ||||||
|     public int getWisdomScore() { |     public int getWisdomScore() { | ||||||
|         return mWisdomScore; |         return mWisdomScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setWisdomScore(int value) { |     public void setWisdomScore(int value) { | ||||||
|         mWisdomScore = value; |         mWisdomScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getWisdomModifier() { |     public int getWisdomModifier() { | ||||||
|         return getAbilityModifierForScore(getWisdomScore()); |         return getAbilityModifierForScore(getWisdomScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mCharismaScore; |     private int mCharismaScore; | ||||||
|  |  | ||||||
|     public int getCharismaScore() { |     public int getCharismaScore() { | ||||||
|         return mCharismaScore; |         return mCharismaScore; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCharismaScore(int value) { |     public void setCharismaScore(int value) { | ||||||
|         mCharismaScore = value; |         mCharismaScore = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public int getCharismaModifier() { |     public int getCharismaModifier() { | ||||||
|         return getAbilityModifierForScore(getCharismaScore()); |         return getAbilityModifierForScore(getCharismaScore()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mArmorName; |     private String mArmorName; | ||||||
|  |  | ||||||
|     public String getArmorName() { |     public String getArmorName() { | ||||||
|         return mArmorName; |         return mArmorName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setArmorName(String value) { |     public void setArmorName(String value) { | ||||||
|         mArmorName = value; |         mArmorName = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mShieldBonus; |     private int mShieldBonus; | ||||||
|  |  | ||||||
|     public int getShieldBonus() { |     public int getShieldBonus() { | ||||||
|         return mShieldBonus; |         return mShieldBonus; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setShieldBonus(int value) { |     public void setShieldBonus(int value) { | ||||||
|         mShieldBonus = value; |         mShieldBonus = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mNaturalArmorBonus; |     private int mNaturalArmorBonus; | ||||||
|  |  | ||||||
|     public int getNaturalArmorBonus() { |     public int getNaturalArmorBonus() { | ||||||
|         return mNaturalArmorBonus; |         return mNaturalArmorBonus; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setNaturalArmorBonus(int value) { |     public void setNaturalArmorBonus(int value) { | ||||||
|         mNaturalArmorBonus = value; |         mNaturalArmorBonus = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mOtherArmorDescription; |     private String mOtherArmorDescription; | ||||||
|  |  | ||||||
|     public String getOtherArmorDescription() { |     public String getOtherArmorDescription() { | ||||||
|         return mOtherArmorDescription; |         return mOtherArmorDescription; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setOtherArmorDescription(String value) { |     public void setOtherArmorDescription(String value) { | ||||||
|         mOtherArmorDescription = value; |         mOtherArmorDescription = value; | ||||||
|     } |     } | ||||||
| @@ -232,7 +290,7 @@ public class Monster { | |||||||
|         if (StringHelper.isNullOrEmpty(armorName) || "none".equals(armorName)) { |         if (StringHelper.isNullOrEmpty(armorName) || "none".equals(armorName)) { | ||||||
|             // 10 + dexMod + 2 for shieldBonus "15" or "17 (shield)" |             // 10 + dexMod + 2 for shieldBonus "15" or "17 (shield)" | ||||||
|             return String.format(Locale.US, "%d%s", BASE_ARMOR_CLASS + getDexterityModifier() + getShieldBonus(), hasShield ? " (shield)" : ""); |             return String.format(Locale.US, "%d%s", BASE_ARMOR_CLASS + getDexterityModifier() + getShieldBonus(), hasShield ? " (shield)" : ""); | ||||||
|         } else if("natural armor".equals(armorName)) { |         } else if ("natural armor".equals(armorName)) { | ||||||
|             // 10 + dexMod + naturalArmorBonus + 2 for shieldBonus "16 (natural armor)" or "18 (natural armor, shield)" |             // 10 + dexMod + naturalArmorBonus + 2 for shieldBonus "16 (natural armor)" or "18 (natural armor, shield)" | ||||||
|             return String.format(Locale.US, "%d (natural armor%s)", BASE_ARMOR_CLASS + getDexterityModifier() + getNaturalArmorBonus() + getShieldBonus(), hasShield ? ", shield" : ""); |             return String.format(Locale.US, "%d (natural armor%s)", BASE_ARMOR_CLASS + getDexterityModifier() + getNaturalArmorBonus() + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("mage armor".equals(armorName)) { |         } else if ("mage armor".equals(armorName)) { | ||||||
| @@ -258,7 +316,7 @@ public class Monster { | |||||||
|             return String.format(Locale.US, "%d (scale mail%s)", SCALE_MAIL_ARMOR_CLASS + Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); |             return String.format(Locale.US, "%d (scale mail%s)", SCALE_MAIL_ARMOR_CLASS + Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("breastplate".equals(armorName)) { |         } else if ("breastplate".equals(armorName)) { | ||||||
|             // 14 + Min(2, dexMod) + 2 for shield "16 (breastplate)" |             // 14 + Min(2, dexMod) + 2 for shield "16 (breastplate)" | ||||||
|             return String.format(Locale.US, "%d (breastplate%s)", BREASTPLATE_ARMOR_CLASS +Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); |             return String.format(Locale.US, "%d (breastplate%s)", BREASTPLATE_ARMOR_CLASS + Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("half plate".equals(armorName)) { |         } else if ("half plate".equals(armorName)) { | ||||||
|             // 15 + Min(2, dexMod) + 2 for shield "17 (half plate)" |             // 15 + Min(2, dexMod) + 2 for shield "17 (half plate)" | ||||||
|             return String.format(Locale.US, "%d (half plate%s)", HALF_PLATE_ARMOR_CLASS + Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); |             return String.format(Locale.US, "%d (half plate%s)", HALF_PLATE_ARMOR_CLASS + Math.min(2, getDexterityModifier()) + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
| @@ -270,10 +328,10 @@ public class Monster { | |||||||
|             return String.format(Locale.US, "%d (chain mail%s)", CHAIN_MAIL_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield" : ""); |             return String.format(Locale.US, "%d (chain mail%s)", CHAIN_MAIL_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("splint".equals(armorName)) { |         } else if ("splint".equals(armorName)) { | ||||||
|             // 17 + 2 for shield "17 (splint)" |             // 17 + 2 for shield "17 (splint)" | ||||||
|             return String.format(Locale.US, "%d (splint%s)", SPLINT_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield": ""); |             return String.format(Locale.US, "%d (splint%s)", SPLINT_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("plate".equals(armorName)) { |         } else if ("plate".equals(armorName)) { | ||||||
|             // 18 + 2 for shield "18 (plate)" |             // 18 + 2 for shield "18 (plate)" | ||||||
|             return String.format(Locale.US, "%d (plate%s)", PLATE_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield": ""); |             return String.format(Locale.US, "%d (plate%s)", PLATE_ARMOR_CLASS + getShieldBonus(), hasShield ? ", shield" : ""); | ||||||
|         } else if ("other".equals(armorName)) { |         } else if ("other".equals(armorName)) { | ||||||
|             // pure string value shield check does nothing just copies the string from otherArmorDesc |             // pure string value shield check does nothing just copies the string from otherArmorDesc | ||||||
|             return getOtherArmorDescription(); |             return getOtherArmorDescription(); | ||||||
| @@ -297,26 +355,35 @@ public class Monster { | |||||||
|     private static final int SPLINT_ARMOR_CLASS = BASE_ARMOR_CLASS + 7; |     private static final int SPLINT_ARMOR_CLASS = BASE_ARMOR_CLASS + 7; | ||||||
|     private static final int PLATE_ARMOR_CLASS = BASE_ARMOR_CLASS + 8; |     private static final int PLATE_ARMOR_CLASS = BASE_ARMOR_CLASS + 8; | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mHitDice; |     private int mHitDice; | ||||||
|  |  | ||||||
|     public int getHitDice() { |     public int getHitDice() { | ||||||
|         return mHitDice; |         return mHitDice; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setHitDice(int value) { |     public void setHitDice(int value) { | ||||||
|         mHitDice = value; |         mHitDice = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private boolean mCustomHP; |     private boolean mCustomHP; | ||||||
|  |  | ||||||
|     public boolean getCustomHP() { |     public boolean getCustomHP() { | ||||||
|         return mCustomHP; |         return mCustomHP; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCustomHP(boolean value) { |     public void setCustomHP(boolean value) { | ||||||
|         mCustomHP = value; |         mCustomHP = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mHPText; |     private String mHPText; | ||||||
|  |  | ||||||
|     public String getHPText() { |     public String getHPText() { | ||||||
|         return mHPText; |         return mHPText; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setHPText(String value) { |     public void setHPText(String value) { | ||||||
|         mHPText = value; |         mHPText = value; | ||||||
|     } |     } | ||||||
| @@ -328,6 +395,9 @@ public class Monster { | |||||||
|             int hitDice = getHitDice(); |             int hitDice = getHitDice(); | ||||||
|             int dieSize = getHitDieForSize(getSize()); |             int dieSize = getHitDieForSize(getSize()); | ||||||
|             int conMod = getConstitutionModifier(); |             int conMod = getConstitutionModifier(); | ||||||
|  |             // For PC style calculations use this | ||||||
|  |             //int hpTotal = (int) Math.max(1, Math.ceil(dieSize + conMod + (hitDice - 1) * ((dieSize + 1) / 2.0 + conMod))); | ||||||
|  |             // For monster style calculations use this | ||||||
|             int hpTotal = (int) Math.max(1, Math.ceil(hitDice * ((dieSize + 1) / 2.0 + conMod))); |             int hpTotal = (int) Math.max(1, Math.ceil(hitDice * ((dieSize + 1) / 2.0 + conMod))); | ||||||
|             return String.format(Locale.US, "%d (%dd%d %+d)", hpTotal, hitDice, dieSize, conMod * hitDice); |             return String.format(Locale.US, "%d (%dd%d %+d)", hpTotal, hitDice, dieSize, conMod * hitDice); | ||||||
|         } |         } | ||||||
| @@ -351,66 +421,90 @@ public class Monster { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mSpeed; |     private String mSpeed; | ||||||
|  |  | ||||||
|     public String getSpeed() { |     public String getSpeed() { | ||||||
|         return mSpeed; |         return mSpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSpeed(String value) { |     public void setSpeed(String value) { | ||||||
|         mSpeed = value; |         mSpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mBurrowSpeed; |     private String mBurrowSpeed; | ||||||
|  |  | ||||||
|     public String getBurrowSpeed() { |     public String getBurrowSpeed() { | ||||||
|         return mBurrowSpeed; |         return mBurrowSpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setBurrowSpeed(String value) { |     public void setBurrowSpeed(String value) { | ||||||
|         mBurrowSpeed = value; |         mBurrowSpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mClimbSpeed; |     private String mClimbSpeed; | ||||||
|  |  | ||||||
|     public String getClimbSpeed() { |     public String getClimbSpeed() { | ||||||
|         return mClimbSpeed; |         return mClimbSpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setClimbSpeed(String value) { |     public void setClimbSpeed(String value) { | ||||||
|         mClimbSpeed = value; |         mClimbSpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mFlySpeed; |     private String mFlySpeed; | ||||||
|  |  | ||||||
|     public String getFlySpeed() { |     public String getFlySpeed() { | ||||||
|         return mFlySpeed; |         return mFlySpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setFlySpeed(String value) { |     public void setFlySpeed(String value) { | ||||||
|         mFlySpeed = value; |         mFlySpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private boolean mHover; |     private boolean mHover; | ||||||
|  |  | ||||||
|     public boolean getHover() { |     public boolean getHover() { | ||||||
|         return mHover; |         return mHover; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setHover(boolean value) { |     public void setHover(boolean value) { | ||||||
|         mHover = value; |         mHover = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mSwimSpeed; |     private String mSwimSpeed; | ||||||
|  |  | ||||||
|     public String getSwimSpeed() { |     public String getSwimSpeed() { | ||||||
|         return mSwimSpeed; |         return mSwimSpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSwimSpeed(String value) { |     public void setSwimSpeed(String value) { | ||||||
|         mSwimSpeed = value; |         mSwimSpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private boolean mCustomSpeed; |     private boolean mCustomSpeed; | ||||||
|  |  | ||||||
|     public boolean getCustomSpeed() { |     public boolean getCustomSpeed() { | ||||||
|         return mCustomSpeed; |         return mCustomSpeed; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCustomSpeed(boolean value) { |     public void setCustomSpeed(boolean value) { | ||||||
|         mCustomSpeed = value; |         mCustomSpeed = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mSpeedDescription; |     private String mSpeedDescription; | ||||||
|  |  | ||||||
|     public String getSpeedDescription() { |     public String getSpeedDescription() { | ||||||
|         return mSpeedDescription; |         return mSpeedDescription; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSpeedDescription(String value) { |     public void setSpeedDescription(String value) { | ||||||
|         mSpeedDescription = value; |         mSpeedDescription = value; | ||||||
|     } |     } | ||||||
| @@ -469,16 +563,21 @@ public class Monster { | |||||||
|         return String.format(Locale.US, "%d (%+d)", getCharismaScore(), getCharismaModifier()); |         return String.format(Locale.US, "%d (%+d)", getCharismaScore(), getCharismaModifier()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private HashSet<SavingThrow> mSavingThrows; |     private HashSet<SavingThrow> mSavingThrows; | ||||||
|  |  | ||||||
|     public Set<SavingThrow> getSavingThrows() { |     public Set<SavingThrow> getSavingThrows() { | ||||||
|         return mSavingThrows; |         return mSavingThrows; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addSavingThrow(SavingThrow savingThrow) { |     public void addSavingThrow(SavingThrow savingThrow) { | ||||||
|         mSavingThrows.add(savingThrow); |         mSavingThrows.add(savingThrow); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeSavingThrow(SavingThrow savingThrow) { |     public void removeSavingThrow(SavingThrow savingThrow) { | ||||||
|         mSavingThrows.remove(savingThrow); |         mSavingThrows.remove(savingThrow); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearSavingThrows() { |     public void clearSavingThrows() { | ||||||
|         mSavingThrows.clear(); |         mSavingThrows.clear(); | ||||||
|     } |     } | ||||||
| @@ -495,7 +594,7 @@ public class Monster { | |||||||
|             } |             } | ||||||
|             String name = st.getName(); |             String name = st.getName(); | ||||||
|  |  | ||||||
|             sb.append(String.format(Locale.US, "%s%s %+d", name.substring(0,1).toUpperCase(Locale.US), name.substring(1), getAbilityModifier(name) + getProficiencyBonus())); |             sb.append(String.format(Locale.US, "%s%s %+d", name.substring(0, 1).toUpperCase(Locale.US), name.substring(1), getAbilityModifier(name) + getProficiencyBonus())); | ||||||
|             isFirst = false; |             isFirst = false; | ||||||
|         } |         } | ||||||
|         return sb.toString(); |         return sb.toString(); | ||||||
| @@ -506,61 +605,61 @@ public class Monster { | |||||||
|         if ("*".equals(challengeRating)) { |         if ("*".equals(challengeRating)) { | ||||||
|             return getCustomProficiencyBonus(); |             return getCustomProficiencyBonus(); | ||||||
|         } else if ( |         } else if ( | ||||||
|             "0".equals(challengeRating) || |                 "0".equals(challengeRating) || | ||||||
|             "1/8".equals(challengeRating) || |                         "1/8".equals(challengeRating) || | ||||||
|             "1/4".equals(challengeRating) || |                         "1/4".equals(challengeRating) || | ||||||
|             "1/2".equals(challengeRating) || |                         "1/2".equals(challengeRating) || | ||||||
|             "1".equals(challengeRating) || |                         "1".equals(challengeRating) || | ||||||
|             "2".equals(challengeRating) || |                         "2".equals(challengeRating) || | ||||||
|             "3".equals(challengeRating) || |                         "3".equals(challengeRating) || | ||||||
|             "4".equals(challengeRating) |                         "4".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 2; |             return 2; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "5".equals(challengeRating) || |                 "5".equals(challengeRating) || | ||||||
|             "6".equals(challengeRating) || |                         "6".equals(challengeRating) || | ||||||
|             "7".equals(challengeRating) || |                         "7".equals(challengeRating) || | ||||||
|             "8".equals(challengeRating) |                         "8".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 3; |             return 3; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "9".equals(challengeRating) || |                 "9".equals(challengeRating) || | ||||||
|             "10".equals(challengeRating) || |                         "10".equals(challengeRating) || | ||||||
|             "11".equals(challengeRating) || |                         "11".equals(challengeRating) || | ||||||
|             "12".equals(challengeRating) |                         "12".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 4; |             return 4; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "13".equals(challengeRating) || |                 "13".equals(challengeRating) || | ||||||
|             "14".equals(challengeRating) || |                         "14".equals(challengeRating) || | ||||||
|             "15".equals(challengeRating) || |                         "15".equals(challengeRating) || | ||||||
|             "16".equals(challengeRating) |                         "16".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 5; |             return 5; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "17".equals(challengeRating) || |                 "17".equals(challengeRating) || | ||||||
|             "18".equals(challengeRating) || |                         "18".equals(challengeRating) || | ||||||
|             "19".equals(challengeRating) || |                         "19".equals(challengeRating) || | ||||||
|             "20".equals(challengeRating) |                         "20".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 6; |             return 6; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "21".equals(challengeRating) || |                 "21".equals(challengeRating) || | ||||||
|             "22".equals(challengeRating) || |                         "22".equals(challengeRating) || | ||||||
|             "23".equals(challengeRating) || |                         "23".equals(challengeRating) || | ||||||
|             "24".equals(challengeRating) |                         "24".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 7; |             return 7; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "25".equals(challengeRating) || |                 "25".equals(challengeRating) || | ||||||
|             "26".equals(challengeRating) || |                         "26".equals(challengeRating) || | ||||||
|             "27".equals(challengeRating) || |                         "27".equals(challengeRating) || | ||||||
|             "28".equals(challengeRating) |                         "28".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 8; |             return 8; | ||||||
|         } else if ( |         } else if ( | ||||||
|             "29".equals(challengeRating) || |                 "29".equals(challengeRating) || | ||||||
|             "30".equals(challengeRating) |                         "30".equals(challengeRating) | ||||||
|         ) { |         ) { | ||||||
|             return 9; |             return 9; | ||||||
|         } else { |         } else { | ||||||
| @@ -568,41 +667,55 @@ public class Monster { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mChallengeRating; |     private String mChallengeRating; | ||||||
|  |  | ||||||
|     public String getChallengeRating() { |     public String getChallengeRating() { | ||||||
|         return mChallengeRating; |         return mChallengeRating; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setChallengeRating(String challengeRating) { |     public void setChallengeRating(String challengeRating) { | ||||||
|         mChallengeRating = challengeRating; |         mChallengeRating = challengeRating; | ||||||
|         // TODO: update proficiency bonus based on CR |         // TODO: update proficiency bonus based on CR | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mCustomChallengeRating; |     private String mCustomChallengeRating; | ||||||
|  |  | ||||||
|     public String getCustomChallengeRating() { |     public String getCustomChallengeRating() { | ||||||
|         return mCustomChallengeRating; |         return mCustomChallengeRating; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCustomChallengeRating(String challengeRating) { |     public void setCustomChallengeRating(String challengeRating) { | ||||||
|         mCustomChallengeRating = challengeRating; |         mCustomChallengeRating = challengeRating; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mCustomProficiencyBonus; |     private int mCustomProficiencyBonus; | ||||||
|  |  | ||||||
|     public int getCustomProficiencyBonus() { |     public int getCustomProficiencyBonus() { | ||||||
|         return mCustomProficiencyBonus; |         return mCustomProficiencyBonus; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCustomProficiencyBonus(int proficiencyBonus) { |     public void setCustomProficiencyBonus(int proficiencyBonus) { | ||||||
|         mCustomProficiencyBonus = proficiencyBonus; |         mCustomProficiencyBonus = proficiencyBonus; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private HashSet<Skill> mSkills; |     private HashSet<Skill> mSkills; | ||||||
|  |  | ||||||
|     public Set<Skill> getSkills() { |     public Set<Skill> getSkills() { | ||||||
|         return mSkills; |         return mSkills; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addSkill(Skill skill) { |     public void addSkill(Skill skill) { | ||||||
|         mSkills.add(skill); |         mSkills.add(skill); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeSkill(Skill skill) { |     public void removeSkill(Skill skill) { | ||||||
|         mSkills.remove(skill); |         mSkills.remove(skill); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearSkill(Skill skill) { |     public void clearSkill(Skill skill) { | ||||||
|         mSkills.clear(); |         mSkills.clear(); | ||||||
|     } |     } | ||||||
| @@ -624,17 +737,22 @@ public class Monster { | |||||||
|         return sb.toString(); |         return sb.toString(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private HashSet<DamageType> mDamageTypes; |     private HashSet<DamageType> mDamageTypes; | ||||||
|  |  | ||||||
|     public Set<DamageType> getDamageTypes() { |     public Set<DamageType> getDamageTypes() { | ||||||
|         return mDamageTypes; |         return mDamageTypes; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addDamageType(DamageType damageType) { |     public void addDamageType(DamageType damageType) { | ||||||
|         // TODO: make this remove the damage type with the same name if it exists first |         // TODO: make this remove the damage type with the same name if it exists first | ||||||
|         mDamageTypes.add(damageType); |         mDamageTypes.add(damageType); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeDamageType(DamageType damageType) { |     public void removeDamageType(DamageType damageType) { | ||||||
|         mDamageTypes.remove(damageType); |         mDamageTypes.remove(damageType); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearDamageTypes() { |     public void clearDamageTypes() { | ||||||
|         mDamageTypes.clear(); |         mDamageTypes.clear(); | ||||||
|     } |     } | ||||||
| @@ -649,6 +767,7 @@ public class Monster { | |||||||
|         Collections.sort(vulnerabilities); |         Collections.sort(vulnerabilities); | ||||||
|         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); |         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String getDamageResistancesDescription() { |     public String getDamageResistancesDescription() { | ||||||
|         ArrayList<String> vulnerabilities = new ArrayList<>(); |         ArrayList<String> vulnerabilities = new ArrayList<>(); | ||||||
|         for (DamageType damageType : mDamageTypes) { |         for (DamageType damageType : mDamageTypes) { | ||||||
| @@ -659,6 +778,7 @@ public class Monster { | |||||||
|         Collections.sort(vulnerabilities); |         Collections.sort(vulnerabilities); | ||||||
|         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); |         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String getDamageImmunitiesDescription() { |     public String getDamageImmunitiesDescription() { | ||||||
|         ArrayList<String> vulnerabilities = new ArrayList<>(); |         ArrayList<String> vulnerabilities = new ArrayList<>(); | ||||||
|         for (DamageType damageType : mDamageTypes) { |         for (DamageType damageType : mDamageTypes) { | ||||||
| @@ -670,18 +790,23 @@ public class Monster { | |||||||
|         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); |         return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private HashSet<String> mConditionImmunities; |     private HashSet<String> mConditionImmunities; | ||||||
|  |  | ||||||
|     public Set<String> getConditionImmunities() { |     public Set<String> getConditionImmunities() { | ||||||
|         return mConditionImmunities; |         return mConditionImmunities; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addConditionImmunity(String condition) { |     public void addConditionImmunity(String condition) { | ||||||
|         // TODO: filter out duplicates |         // TODO: filter out duplicates | ||||||
|         mConditionImmunities.add(condition); |         mConditionImmunities.add(condition); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeConditionImmunity(String condition) { |     public void removeConditionImmunity(String condition) { | ||||||
|         // TODO: make sure this works even though we're using strings |         // TODO: make sure this works even though we're using strings | ||||||
|         mConditionImmunities.remove(condition); |         mConditionImmunities.remove(condition); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearConditionImmunities() { |     public void clearConditionImmunities() { | ||||||
|         mConditionImmunities.clear(); |         mConditionImmunities.clear(); | ||||||
|     } |     } | ||||||
| @@ -692,42 +817,57 @@ public class Monster { | |||||||
|         return StringHelper.oxfordJoin(", ", ", and ", " and ", immunities); |         return StringHelper.oxfordJoin(", ", ", and ", " and ", immunities); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mBlindsight; |     private String mBlindsight; | ||||||
|  |  | ||||||
|     public String getBlindsight() { |     public String getBlindsight() { | ||||||
|         return mBlindsight; |         return mBlindsight; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setBlindsight(String value) { |     public void setBlindsight(String value) { | ||||||
|         mBlindsight = value; |         mBlindsight = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private boolean mIsBlind; |     private boolean mIsBlind; | ||||||
|  |  | ||||||
|     public boolean getIsBlind() { |     public boolean getIsBlind() { | ||||||
|         return mIsBlind; |         return mIsBlind; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setIsBlind(boolean value) { |     public void setIsBlind(boolean value) { | ||||||
|         mIsBlind = value; |         mIsBlind = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mDarkvision; |     private String mDarkvision; | ||||||
|  |  | ||||||
|     public String getDarkvision() { |     public String getDarkvision() { | ||||||
|         return mDarkvision; |         return mDarkvision; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setDarkvision(String value) { |     public void setDarkvision(String value) { | ||||||
|         mDarkvision = value; |         mDarkvision = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mTremorsense; |     private String mTremorsense; | ||||||
|  |  | ||||||
|     public String getTremorsense() { |     public String getTremorsense() { | ||||||
|         return mTremorsense; |         return mTremorsense; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setTremorsense(String value) { |     public void setTremorsense(String value) { | ||||||
|         mTremorsense = value; |         mTremorsense = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mTruesight; |     private String mTruesight; | ||||||
|  |  | ||||||
|     public String getTruesight() { |     public String getTruesight() { | ||||||
|         return mTruesight; |         return mTruesight; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setTruesight(String value) { |     public void setTruesight(String value) { | ||||||
|         mTruesight = value; |         mTruesight = value; | ||||||
|     } |     } | ||||||
| @@ -756,32 +896,43 @@ public class Monster { | |||||||
|         return StringHelper.join(", ", parts); |         return StringHelper.join(", ", parts); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private HashSet<Language> mLanguages; |     private HashSet<Language> mLanguages; | ||||||
|  |  | ||||||
|     public Set<Language> getLanguages() { |     public Set<Language> getLanguages() { | ||||||
|         return mLanguages; |         return mLanguages; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addLanguage(Language value) { |     public void addLanguage(Language value) { | ||||||
|         mLanguages.add(value); |         mLanguages.add(value); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeLanguage(Language value) { |     public void removeLanguage(Language value) { | ||||||
|         mLanguages.remove(value); |         mLanguages.remove(value); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearLanguages() { |     public void clearLanguages() { | ||||||
|         mLanguages.clear(); |         mLanguages.clear(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private int mTelepathy; |     private int mTelepathy; | ||||||
|  |  | ||||||
|     public int getTelepathy() { |     public int getTelepathy() { | ||||||
|         return mTelepathy; |         return mTelepathy; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setTelepathy(int value) { |     public void setTelepathy(int value) { | ||||||
|         mTelepathy = value; |         mTelepathy = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private String mUnderstandsBut; |     private String mUnderstandsBut; | ||||||
|  |  | ||||||
|     public String getUnderstandsBut() { |     public String getUnderstandsBut() { | ||||||
|         return mUnderstandsBut; |         return mUnderstandsBut; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setUnderstandsBut(String value) { |     public void setUnderstandsBut(String value) { | ||||||
|         mUnderstandsBut = value; |         mUnderstandsBut = value; | ||||||
|     } |     } | ||||||
| @@ -919,16 +1070,21 @@ public class Monster { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|     private ArrayList<Ability> mAbilities; |     private ArrayList<Ability> mAbilities; | ||||||
|  |  | ||||||
|     public List<Ability> getAbilities() { |     public List<Ability> getAbilities() { | ||||||
|         return mAbilities; |         return mAbilities; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addAbility(Ability ability) { |     public void addAbility(Ability ability) { | ||||||
|         mAbilities.add(ability); |         mAbilities.add(ability); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void removeAbility(Ability ability) { |     public void removeAbility(Ability ability) { | ||||||
|         mAbilities.remove(ability); |         mAbilities.remove(ability); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void clearAbilities() { |     public void clearAbilities() { | ||||||
|         mAbilities.clear(); |         mAbilities.clear(); | ||||||
|     } |     } | ||||||
| @@ -959,7 +1115,7 @@ public class Monster { | |||||||
|  |  | ||||||
|     public int getSavingThrow(String name) { |     public int getSavingThrow(String name) { | ||||||
|         Set<SavingThrow> sts = getSavingThrows(); |         Set<SavingThrow> sts = getSavingThrows(); | ||||||
|         for(SavingThrow st : sts) { |         for (SavingThrow st : sts) { | ||||||
|             if (name.equals(st.getName())) { |             if (name.equals(st.getName())) { | ||||||
|                 return getAbilityModifier(name) + getProficiencyBonus(); |                 return getAbilityModifier(name) + getProficiencyBonus(); | ||||||
|             } |             } | ||||||
| @@ -979,4 +1135,31 @@ public class Monster { | |||||||
|         return getProficiencyBonus() + getAbilityModifier(abilityScoreName); |         return getProficiencyBonus() + getAbilityModifier(abilityScoreName); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public List<String> getActionDescriptions() { | ||||||
|  |         ArrayList<String> actions = new ArrayList<>(); | ||||||
|  |         for (Action action : getActions()) { | ||||||
|  |             actions.add(getPlaceholderReplacedText(String.format("__%s__ %s", action.getName(), action.getDescription()))); | ||||||
|  |         } | ||||||
|  |         return actions; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Ignore() | ||||||
|  |     private ArrayList<Action> mActions; | ||||||
|  |  | ||||||
|  |     public List<Action> getActions() { | ||||||
|  |         return mActions; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void addAction(Action ability) { | ||||||
|  |         mActions.add(ability); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void removeAction(Action ability) { | ||||||
|  |         mActions.remove(ability); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void clearActions() { | ||||||
|  |         mActions.clear(); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ public class MonsterFragment extends Fragment { | |||||||
|         // TODO: remove this block make the monster ID a parameter to the view and get the monster from saved data (sqlite) |         // TODO: remove this block make the monster ID a parameter to the view and get the monster from saved data (sqlite) | ||||||
|         Monster monster = new Monster(); |         Monster monster = new Monster(); | ||||||
|         // Name |         // Name | ||||||
|         monster.setName("Pixie"); |         monster.name ="Pixie"; | ||||||
|         // Meta |         // Meta | ||||||
|         monster.setSize("tiny"); |         monster.setSize("tiny"); | ||||||
|         monster.setType("fey"); |         monster.setType("fey"); | ||||||
|   | |||||||
| @@ -13,105 +13,79 @@ public class MonsterViewModel extends ViewModel { | |||||||
|  |  | ||||||
|     public MonsterViewModel() { |     public MonsterViewModel() { | ||||||
|         mMonster = null; |         mMonster = null; | ||||||
|         mName = new MutableLiveData<>(); |         mAbilities = new MutableLiveData<>(); | ||||||
|         mName.setValue(""); |         mAbilities.setValue(new ArrayList<String>()); | ||||||
|         mMeta = new MutableLiveData<>(); |         mActions = new MutableLiveData<>(); | ||||||
|         mMeta.setValue(""); |         mActions.setValue(new ArrayList<String>()); | ||||||
|         mArmorClass = new MutableLiveData<>(); |         mArmorClass = new MutableLiveData<>(); | ||||||
|         mArmorClass.setValue(""); |         mArmorClass.setValue(""); | ||||||
|  |         mChallenge = new MutableLiveData<>(); | ||||||
|  |         mChallenge.setValue(""); | ||||||
|  |         mCharisma = new MutableLiveData<>(); | ||||||
|  |         mCharisma.setValue(""); | ||||||
|  |         mConditionImmunities = new MutableLiveData<>(); | ||||||
|  |         mConditionImmunities.setValue(""); | ||||||
|  |         mConstitution = new MutableLiveData<>(); | ||||||
|  |         mConstitution.setValue(""); | ||||||
|  |         mDamageImmunities = new MutableLiveData<>(); | ||||||
|  |         mDamageImmunities.setValue(""); | ||||||
|  |         mDamageResistances = new MutableLiveData<>(); | ||||||
|  |         mDamageResistances.setValue(""); | ||||||
|  |         mDamageVulnerabilities = new MutableLiveData<>(); | ||||||
|  |         mDamageVulnerabilities.setValue(""); | ||||||
|  |         mDexterity = new MutableLiveData<>(); | ||||||
|  |         mDexterity.setValue(""); | ||||||
|         mHitPoints = new MutableLiveData<>(); |         mHitPoints = new MutableLiveData<>(); | ||||||
|         mHitPoints.setValue(""); |         mHitPoints.setValue(""); | ||||||
|  |         mIntelligence = new MutableLiveData<>(); | ||||||
|  |         mIntelligence.setValue(""); | ||||||
|  |         mLanguages = new MutableLiveData<>(); | ||||||
|  |         mLanguages.setValue(""); | ||||||
|  |         mMeta = new MutableLiveData<>(); | ||||||
|  |         mMeta.setValue(""); | ||||||
|  |         mName = new MutableLiveData<>(); | ||||||
|  |         mName.setValue(""); | ||||||
|  |         mSavingThrows = new MutableLiveData<>(); | ||||||
|  |         mSavingThrows.setValue(""); | ||||||
|  |         mSenses = new MutableLiveData<>(); | ||||||
|  |         mSenses.setValue(""); | ||||||
|  |         mSkills = new MutableLiveData<>(); | ||||||
|  |         mSkills.setValue(""); | ||||||
|         mSpeed = new MutableLiveData<>(); |         mSpeed = new MutableLiveData<>(); | ||||||
|         mSpeed.setValue(""); |         mSpeed.setValue(""); | ||||||
|         mStrength = new MutableLiveData<>(); |         mStrength = new MutableLiveData<>(); | ||||||
|         mStrength.setValue(""); |         mStrength.setValue(""); | ||||||
|         mDexterity = new MutableLiveData<>(); |  | ||||||
|         mDexterity.setValue(""); |  | ||||||
|         mConstitution = new MutableLiveData<>(); |  | ||||||
|         mConstitution.setValue(""); |  | ||||||
|         mIntelligence = new MutableLiveData<>(); |  | ||||||
|         mIntelligence.setValue(""); |  | ||||||
|         mWisdom = new MutableLiveData<>(); |         mWisdom = new MutableLiveData<>(); | ||||||
|         mWisdom.setValue(""); |         mWisdom.setValue(""); | ||||||
|         mCharisma = new MutableLiveData<>(); |  | ||||||
|         mCharisma.setValue(""); |  | ||||||
|         mSavingThrows = new MutableLiveData<>(); |  | ||||||
|         mSavingThrows.setValue(""); |  | ||||||
|         mSkills = new MutableLiveData<>(); |  | ||||||
|         mSkills.setValue(""); |  | ||||||
|         mDamageVulnerabilities = new MutableLiveData<>(); |  | ||||||
|         mDamageVulnerabilities.setValue(""); |  | ||||||
|         mDamageResistances = new MutableLiveData<>(); |  | ||||||
|         mDamageResistances.setValue(""); |  | ||||||
|         mDamageImmunities = new MutableLiveData<>(); |  | ||||||
|         mDamageImmunities.setValue(""); |  | ||||||
|         mConditionImmunities = new MutableLiveData<>(); |  | ||||||
|         mConditionImmunities.setValue(""); |  | ||||||
|         mSenses = new MutableLiveData<>(); |  | ||||||
|         mSenses.setValue(""); |  | ||||||
|         mLanguages = new MutableLiveData<>(); |  | ||||||
|         mLanguages.setValue(""); |  | ||||||
|         mChallenge = new MutableLiveData<>(); |  | ||||||
|         mChallenge.setValue(""); |  | ||||||
|         mAbilities = new MutableLiveData<>(); |  | ||||||
|         mAbilities.setValue(new ArrayList<String>()); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private MutableLiveData<String> mName; |     private MutableLiveData<List<String>> mAbilities; | ||||||
|     public LiveData<String> getName() { |     public LiveData<List<String>> getAbilities() { | ||||||
|         return mName; |         return mAbilities; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mMeta; |     private MutableLiveData<List<String>> mActions; | ||||||
|     public LiveData<String> getMeta() { |     public LiveData<List<String>> getActions() { | ||||||
|         return mMeta; |         return mActions; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mArmorClass; |     private MutableLiveData<String> mArmorClass; | ||||||
|     public LiveData<String> getArmorClass() { |     public LiveData<String> getArmorClass() { | ||||||
|         return mArmorClass; |         return mArmorClass; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mHitPoints; |     private MutableLiveData<String> mChallenge; | ||||||
|     public LiveData<String> getHitPoints() { |     public LiveData<String> getChallenge() { | ||||||
|         return mHitPoints; |         return mChallenge; | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mSpeed; |  | ||||||
|     public LiveData<String> getSpeed() { |  | ||||||
|         return mSpeed; |  | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mStrength; |  | ||||||
|     public LiveData<String> getStrength() { |  | ||||||
|         return mStrength; |  | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mDexterity; |  | ||||||
|     public LiveData<String> getDexterity() { |  | ||||||
|         return mDexterity; |  | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mConstitution; |  | ||||||
|     public LiveData<String> getConstitution() { |  | ||||||
|         return mConstitution; |  | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mIntelligence; |  | ||||||
|     public LiveData<String> getIntelligence() { |  | ||||||
|         return mIntelligence; |  | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mWisdom; |  | ||||||
|     public LiveData<String> getWisdom() { |  | ||||||
|         return mWisdom; |  | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mCharisma; |     private MutableLiveData<String> mCharisma; | ||||||
|     public LiveData<String> getCharisma() { |     public LiveData<String> getCharisma() { | ||||||
|         return mCharisma; |         return mCharisma; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mSavingThrows; |     private MutableLiveData<String> mConditionImmunities; | ||||||
|     public LiveData<String> getSavingThrows() { |     public LiveData<String> getConditionImmunities() { | ||||||
|         return mSavingThrows; |         return mConditionImmunities; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mSkills; |     private MutableLiveData<String> mConstitution; | ||||||
|     public LiveData<String> getSkills() { |     public LiveData<String> getConstitution() { | ||||||
|         return mSkills; |         return mConstitution; | ||||||
|     } |  | ||||||
|     private MutableLiveData<String> mDamageVulnerabilities; |  | ||||||
|     public LiveData<String> getDamageVulnerabilities() { |  | ||||||
|         return mDamageVulnerabilities; |  | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mDamageResistances; |     private MutableLiveData<String> mDamageResistances; | ||||||
|     public LiveData<String> getDamageResistances() { |     public LiveData<String> getDamageResistances() { | ||||||
| @@ -121,50 +95,84 @@ public class MonsterViewModel extends ViewModel { | |||||||
|     public LiveData<String> getDamageImmunities() { |     public LiveData<String> getDamageImmunities() { | ||||||
|         return mDamageImmunities; |         return mDamageImmunities; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mConditionImmunities; |     private MutableLiveData<String> mDamageVulnerabilities; | ||||||
|     public LiveData<String> getConditionImmunities() { |     public LiveData<String> getDamageVulnerabilities() { | ||||||
|         return mConditionImmunities; |         return mDamageVulnerabilities; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mSenses; |     private MutableLiveData<String> mDexterity; | ||||||
|     public LiveData<String> getSenses() { |     public LiveData<String> getDexterity() { | ||||||
|         return mSenses; |         return mDexterity; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mHitPoints; | ||||||
|  |     public LiveData<String> getHitPoints() { | ||||||
|  |         return mHitPoints; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mIntelligence; | ||||||
|  |     public LiveData<String> getIntelligence() { | ||||||
|  |         return mIntelligence; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mLanguages; |     private MutableLiveData<String> mLanguages; | ||||||
|     public LiveData<String> getLanguages() { |     public LiveData<String> getLanguages() { | ||||||
|         return mLanguages; |         return mLanguages; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<String> mChallenge; |     private MutableLiveData<String> mMeta; | ||||||
|     public LiveData<String> getChallenge() { |     public LiveData<String> getMeta() { | ||||||
|         return mChallenge; |         return mMeta; | ||||||
|     } |     } | ||||||
|     private MutableLiveData<List<String>> mAbilities; |     private MutableLiveData<String> mName; | ||||||
|     public LiveData<List<String>> getAbilities() { |     public LiveData<String> getName() { | ||||||
|         return mAbilities; |         return mName; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mSavingThrows; | ||||||
|  |     public LiveData<String> getSavingThrows() { | ||||||
|  |         return mSavingThrows; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mSenses; | ||||||
|  |     public LiveData<String> getSenses() { | ||||||
|  |         return mSenses; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mSkills; | ||||||
|  |     public LiveData<String> getSkills() { | ||||||
|  |         return mSkills; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mSpeed; | ||||||
|  |     public LiveData<String> getSpeed() { | ||||||
|  |         return mSpeed; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mStrength; | ||||||
|  |     public LiveData<String> getStrength() { | ||||||
|  |         return mStrength; | ||||||
|  |     } | ||||||
|  |     private MutableLiveData<String> mWisdom; | ||||||
|  |     public LiveData<String> getWisdom() { | ||||||
|  |         return mWisdom; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private Monster mMonster; |     private Monster mMonster; | ||||||
|     public void setMonster(Monster monster) { |     public void setMonster(Monster monster) { | ||||||
|         mMonster = monster; |         mMonster = monster; | ||||||
|         mName.setValue(mMonster.getName()); |  | ||||||
|         mMeta.setValue(mMonster.getMeta()); |         mAbilities.setValue(mMonster.getAbilityDescriptions()); | ||||||
|  |         mActions.setValue(mMonster.getActionDescriptions()); | ||||||
|         mArmorClass.setValue(mMonster.getArmorClass()); |         mArmorClass.setValue(mMonster.getArmorClass()); | ||||||
|  |         mChallenge.setValue(mMonster.getChallengeRatingDescription()); | ||||||
|  |         mCharisma.setValue(monster.getCharismaDescription()); | ||||||
|  |         mConditionImmunities.setValue(mMonster.getConditionImmunitiesDescription()); | ||||||
|  |         mConstitution.setValue(monster.getConstitutionDescription()); | ||||||
|  |         mDamageImmunities.setValue(mMonster.getDamageImmunitiesDescription()); | ||||||
|  |         mDamageResistances.setValue(mMonster.getDamageResistancesDescription()); | ||||||
|  |         mDamageVulnerabilities.setValue(mMonster.getDamageVulnerabilitiesDescription()); | ||||||
|  |         mDexterity.setValue(monster.getDexterityDescription()); | ||||||
|         mHitPoints.setValue(mMonster.getHitPoints()); |         mHitPoints.setValue(mMonster.getHitPoints()); | ||||||
|  |         mIntelligence.setValue(monster.getIntelligenceDescription()); | ||||||
|  |         mLanguages.setValue(mMonster.getLanguagesDescription()); | ||||||
|  |         mMeta.setValue(mMonster.getMeta()); | ||||||
|  |         mName.setValue(mMonster.name); | ||||||
|  |         mSavingThrows.setValue(monster.getSavingThrowsDescription()); | ||||||
|  |         mSenses.setValue(monster.getSensesDescription()); | ||||||
|  |         mSkills.setValue(monster.getSkillsDescription()); | ||||||
|         mSpeed.setValue(mMonster.getSpeedText()); |         mSpeed.setValue(mMonster.getSpeedText()); | ||||||
|         mStrength.setValue(monster.getStrengthDescription()); |         mStrength.setValue(monster.getStrengthDescription()); | ||||||
|         mDexterity.setValue(monster.getDexterityDescription()); |  | ||||||
|         mConstitution.setValue(monster.getConstitutionDescription()); |  | ||||||
|         mIntelligence.setValue(monster.getIntelligenceDescription()); |  | ||||||
|         mWisdom.setValue(monster.getWisdomDescription()); |         mWisdom.setValue(monster.getWisdomDescription()); | ||||||
|         mCharisma.setValue(monster.getCharismaDescription()); |  | ||||||
|         mSavingThrows.setValue(monster.getSavingThrowsDescription()); |  | ||||||
|         mSkills.setValue(monster.getSkillsDescription()); |  | ||||||
|         mDamageVulnerabilities.setValue(mMonster.getDamageVulnerabilitiesDescription()); |  | ||||||
|         mDamageResistances.setValue(mMonster.getDamageResistancesDescription()); |  | ||||||
|         mDamageImmunities.setValue(mMonster.getDamageImmunitiesDescription()); |  | ||||||
|         mConditionImmunities.setValue(mMonster.getConditionImmunitiesDescription()); |  | ||||||
|         mSenses.setValue(monster.getSensesDescription()); |  | ||||||
|         mLanguages.setValue(mMonster.getLanguagesDescription()); |  | ||||||
|         mChallenge.setValue(mMonster.getChallengeRatingDescription()); |  | ||||||
|         mAbilities.setValue(mMonster.getAbilityDescriptions()); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user
	 Tom Hicks
						Tom Hicks