Adds skills display to the monster detail view.

This commit is contained in:
2021-03-21 19:49:03 -07:00
parent 0299213dfa
commit f5c3ce57de
4 changed files with 39 additions and 22 deletions

View File

@@ -607,7 +607,14 @@ public class Monster: NSManagedObject {
var skillsDescription: String {
get {
return ""
let sortedSkills = self.skillsArray.sorted {$0.name ?? "" < $1.name ?? ""}
return sortedSkills.reduce("") {
if $0 == "" {
return $1.skillDescription
} else {
return $0 + ", " + $1.skillDescription
}
}
}
}

View File

@@ -20,7 +20,6 @@ public class Skill: NSManagedObject {
name = newValue
}
}
var wrappedProficiency: ProficiencyType {
get {
@@ -66,7 +65,11 @@ public class Skill: NSManagedObject {
var skillDescription: String {
get {
return String(format: "%@ %+d%@", name ?? "", modifier)
var advantageLabel = Monster.advantageLabelStringForType(wrappedAdvantage)
if (advantageLabel != "") {
advantageLabel = " " + advantageLabel
}
return String(format: "%@ %+d%@", name ?? "", modifier, advantageLabel)
}
}
}

View File

@@ -124,7 +124,14 @@ struct MonsterDetail: View {
let savingThrowsDescription = monster.savingThrowsDescription
if (!savingThrowsDescription.isEmpty) {
LabeledField("Saving Throws") {
Text(monster.savingThrowsDescription)
Text(savingThrowsDescription)
}
}
let skillsDescription = monster.skillsDescription
if (!skillsDescription.isEmpty) {
LabeledField("Skills") {
Text(skillsDescription)
}
}
}