Adds legendary actions.
This commit is contained in:
@@ -62,6 +62,7 @@ class MonsterViewModel: ObservableObject {
|
||||
@Published var customProficiencyBonus: Int64
|
||||
@Published var abilities: [AbilityViewModel]
|
||||
@Published var actions: [AbilityViewModel]
|
||||
@Published var legendaryActions: [AbilityViewModel]
|
||||
|
||||
init(_ rawMonster: Monster? = nil) {
|
||||
self.name = ""
|
||||
@@ -116,6 +117,7 @@ class MonsterViewModel: ObservableObject {
|
||||
self.customProficiencyBonus = 0
|
||||
self.abilities = []
|
||||
self.actions = []
|
||||
self.legendaryActions = []
|
||||
|
||||
if (rawMonster != nil) {
|
||||
self.copyFromMonster(monster: rawMonster!)
|
||||
@@ -199,6 +201,9 @@ class MonsterViewModel: ObservableObject {
|
||||
|
||||
self.actions = (monster.actions ?? [])
|
||||
.map {AbilityViewModel($0.name, $0.abilityDescription)}
|
||||
|
||||
self.legendaryActions = (monster.legendaryActions ?? [])
|
||||
.map {AbilityViewModel($0.name, $0.abilityDescription)}
|
||||
}
|
||||
|
||||
func copyToMonster(monster: Monster) {
|
||||
@@ -278,5 +283,7 @@ class MonsterViewModel: ObservableObject {
|
||||
monster.abilities = abilities.map {AbilityViewModel($0.name, $0.abilityDescription)}
|
||||
|
||||
monster.actions = actions.map {AbilityViewModel($0.name, $0.abilityDescription)}
|
||||
|
||||
monster.legendaryActions = legendaryActions.map {AbilityViewModel($0.name, $0.abilityDescription)}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<attribute name="intelligenceScore" attributeType="Integer 64" defaultValueString="10" usesScalarValueType="YES"/>
|
||||
<attribute name="isBlind" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="languages" optional="YES" attributeType="Transformable" valueTransformerName="LanguageViewModelValueTransformer" customClassName="[LanguageViewModel]"/>
|
||||
<attribute name="legendaryActions" optional="YES" attributeType="Transformable" valueTransformerName="AbilityViewModelValueTransformer" customClassName="[AbilityViewModel]"/>
|
||||
<attribute name="name" attributeType="String" defaultValueString="Unnamed Monster"/>
|
||||
<attribute name="naturalArmorBonus" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="otherArmorDescription" attributeType="String" defaultValueString=""/>
|
||||
@@ -69,7 +70,7 @@
|
||||
<relationship name="monster" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Monster" inverseName="skills" inverseEntity="Monster"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="Monster" positionX="-63" positionY="-18" width="128" height="914"/>
|
||||
<element name="Monster" positionX="-63" positionY="-18" width="128" height="929"/>
|
||||
<element name="Skill" positionX="-63" positionY="135" width="128" height="14"/>
|
||||
</elements>
|
||||
</model>
|
||||
@@ -80,6 +80,10 @@ struct EditMonster: View {
|
||||
NavigationLink(
|
||||
"Actions",
|
||||
destination: EditTraits(viewModel: monsterViewModel, path: \.actions, title: "Actions"))
|
||||
|
||||
NavigationLink(
|
||||
"Legendary Actions",
|
||||
destination: EditTraits(viewModel: monsterViewModel, path: \.legendaryActions, title: "Legendary Actions"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ struct MonsterDetail: View {
|
||||
let monsterChallengeRatingDescription = monster.challengeRatingDescription
|
||||
let monsterAbilities: [AbilityViewModel] = monster.abilities ?? []
|
||||
let monsterActions: [AbilityViewModel] = monster.actions ?? []
|
||||
let monsterLegendaryActions: [AbilityViewModel] = monster.legendaryActions ?? []
|
||||
|
||||
BasicInfoView(monster: monster)
|
||||
|
||||
@@ -270,6 +271,18 @@ struct MonsterDetail: View {
|
||||
}
|
||||
|
||||
// Legendary Actions
|
||||
if (monsterLegendaryActions.count > 0) {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Legendary Actions")
|
||||
.fontWeight(.bold)
|
||||
ForEach(monsterLegendaryActions) { action in
|
||||
VStack {
|
||||
Markdown(Document(action.renderedText(monster)))
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
Reference in New Issue
Block a user