diff --git a/MonsterCards/Models/MonsterViewModel.swift b/MonsterCards/Models/MonsterViewModel.swift
index 4f3e854..1c39817 100644
--- a/MonsterCards/Models/MonsterViewModel.swift
+++ b/MonsterCards/Models/MonsterViewModel.swift
@@ -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)}
}
}
diff --git a/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents b/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents
index 3592774..39ff24a 100644
--- a/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents
+++ b/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents
@@ -40,6 +40,7 @@
+
@@ -69,7 +70,7 @@
-
+
\ No newline at end of file
diff --git a/MonsterCards/Views/EditMonster.swift b/MonsterCards/Views/EditMonster.swift
index 8aaabc2..4b27545 100644
--- a/MonsterCards/Views/EditMonster.swift
+++ b/MonsterCards/Views/EditMonster.swift
@@ -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"))
}
}
diff --git a/MonsterCards/Views/MonsterDetail.swift b/MonsterCards/Views/MonsterDetail.swift
index bb650a1..03165ee 100644
--- a/MonsterCards/Views/MonsterDetail.swift
+++ b/MonsterCards/Views/MonsterDetail.swift
@@ -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)