Adds damage types and condition immunities to core data so they are saved now.
This commit is contained in:
@@ -627,55 +627,31 @@ public class Monster: NSManagedObject {
|
|||||||
|
|
||||||
// MARK: OTHER
|
// MARK: OTHER
|
||||||
|
|
||||||
var damageVulnerabilitiesArray: [String] {
|
|
||||||
get {
|
|
||||||
return ["Fire", "Poison", "Psychic"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var damageVulnerabilitiesDescription: String {
|
var damageVulnerabilitiesDescription: String {
|
||||||
get {
|
get {
|
||||||
let sortedVulnerabilities = self.damageVulnerabilitiesArray.sorted()
|
let sortedVulnerabilities = self.damageVulnerabilities?.sorted() ?? []
|
||||||
|
|
||||||
return StringHelper.oxfordJoin(sortedVulnerabilities, ", ", ", and ", " and ")
|
return StringHelper.oxfordJoin(sortedVulnerabilities, ", ", ", and ", " and ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var damageResistancesArray: [String] {
|
|
||||||
get {
|
|
||||||
return ["Ice", "Electric"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var damageResistancesDescription: String {
|
var damageResistancesDescription: String {
|
||||||
get {
|
get {
|
||||||
let sortedResistances = self.damageResistancesArray.sorted()
|
let sortedResistances = self.damageResistances?.sorted() ?? []
|
||||||
return StringHelper.oxfordJoin(sortedResistances, ", ", ", and ", " and ")
|
return StringHelper.oxfordJoin(sortedResistances, ", ", ", and ", " and ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var damageImmunitiesArray: [String] {
|
|
||||||
get {
|
|
||||||
return ["Slashing"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var damageImmunitiesDescription: String {
|
var damageImmunitiesDescription: String {
|
||||||
get {
|
get {
|
||||||
let sortedImmunities = self.damageImmunitiesArray.sorted()
|
let sortedImmunities = self.damageImmunities?.sorted() ?? []
|
||||||
return StringHelper.oxfordJoin(sortedImmunities, ", ", ", and ", " and ")
|
return StringHelper.oxfordJoin(sortedImmunities, ", ", ", and ", " and ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var conditionImmunitiesArray: [String] {
|
|
||||||
get {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var conditionImmunitiesDescription: String {
|
var conditionImmunitiesDescription: String {
|
||||||
get {
|
get {
|
||||||
let sortedImmunities = self.conditionImmunitiesArray.sorted()
|
let sortedImmunities = self.conditionImmunities?.sorted() ?? []
|
||||||
return StringHelper.oxfordJoin(sortedImmunities, ", ", ", and ", " and ")
|
return StringHelper.oxfordJoin(sortedImmunities, ", ", ", and ", " and ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,19 +148,19 @@ class MonsterViewModel: ObservableObject {
|
|||||||
self.charismaSavingThrowProficiency = monster.charismaSavingThrowProficiencyEnum
|
self.charismaSavingThrowProficiency = monster.charismaSavingThrowProficiencyEnum
|
||||||
self.skills = (monster.skills?.allObjects.map {SkillViewModel(($0 as! Skill))})!.sorted()
|
self.skills = (monster.skills?.allObjects.map {SkillViewModel(($0 as! Skill))})!.sorted()
|
||||||
|
|
||||||
self.damageImmunities = monster.damageImmunitiesArray
|
self.damageImmunities = (monster.damageImmunities ?? [])
|
||||||
.map {DamageTypeViewModel($0)}
|
.map {DamageTypeViewModel($0)}
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|
||||||
self.damageResistances = monster.damageResistancesArray
|
self.damageResistances = (monster.damageResistances ?? [])
|
||||||
.map {DamageTypeViewModel($0)}
|
.map {DamageTypeViewModel($0)}
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|
||||||
self.damageVulnerabilities = monster.damageVulnerabilitiesArray
|
self.damageVulnerabilities = (monster.damageVulnerabilities ?? [])
|
||||||
.map {DamageTypeViewModel($0)}
|
.map {DamageTypeViewModel($0)}
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|
||||||
self.conditionImmunities = monster.conditionImmunitiesArray
|
self.conditionImmunities = (monster.conditionImmunities ?? [])
|
||||||
.map {DamageTypeViewModel($0)}
|
.map {DamageTypeViewModel($0)}
|
||||||
.sorted()
|
.sorted()
|
||||||
}
|
}
|
||||||
@@ -234,5 +234,9 @@ class MonsterViewModel: ObservableObject {
|
|||||||
|
|
||||||
func copyToRaw() {
|
func copyToRaw() {
|
||||||
|
|
||||||
|
monster.conditionImmunities = conditionImmunities.map {$0.name}
|
||||||
|
monster.damageImmunities = damageImmunities.map {$0.name}
|
||||||
|
monster.damageResistances = damageResistances.map {$0.name}
|
||||||
|
monster.damageVulnerabilities = damageVulnerabilities.map {$0.name}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user