Adds skills display to the monster detail view.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user