Adds senses and passive perception.

Also makes modifier calculations return Int instead of Int64.
This commit is contained in:
2021-03-24 17:46:04 -07:00
parent 596186deaa
commit 3ec62789c6
7 changed files with 110 additions and 44 deletions

View File

@@ -625,7 +625,7 @@ public class Monster: NSManagedObject {
}
}
// MARK: OTHER
// MARK: Immunities, Resistances, and Vulnerabilities
var damageVulnerabilitiesDescription: String {
get {
@@ -656,6 +656,40 @@ public class Monster: NSManagedObject {
}
}
// MARK: OTHER
var passivePerception: Int {
get {
let perceptionSkill = skillsArray.first(where: {
StringHelper.safeEqualsIgnoreCase($0.name, "Perception")
})
if (perceptionSkill == nil) {
return wisdomModifier
} else if (perceptionSkill?.wrappedProficiency == ProficiencyType.expertise) {
return wisdomModifier + proficiencyBonus + proficiencyBonus
} else if (perceptionSkill?.wrappedProficiency == ProficiencyType.proficient) {
return wisdomModifier + proficiencyBonus
} else {
return wisdomModifier
}
}
}
var sensesDescription: String {
get {
var modifiedSenses = self.senses?.sorted() ?? []
let hasPassivePerceptionSense = modifiedSenses.contains(where: {
$0.starts(with: "passive Perception")
})
if (!hasPassivePerceptionSense) {
let calculatedPassivePerception = String(format: "passive Perception %+d", passivePerception)
modifiedSenses.append(calculatedPassivePerception)
}
return modifiedSenses.sorted().joined(separator: ", ")
}
}
var languagesArray: [String] {
get {
return ["Common", "Goblin"]