From 041907ab4dc754330a14023844d6d5a07eb6b9b4 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Wed, 7 Sep 2022 13:08:41 -0400 Subject: [PATCH] :bug: Add missing inits --- Sources/JensonKit/Models/JensonEvent.swift | 17 +++++++++++++++++ Sources/JensonKit/Models/JensonFile.swift | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/Sources/JensonKit/Models/JensonEvent.swift b/Sources/JensonKit/Models/JensonEvent.swift index 66c9b83..cdb9505 100644 --- a/Sources/JensonKit/Models/JensonEvent.swift +++ b/Sources/JensonKit/Models/JensonEvent.swift @@ -42,6 +42,13 @@ public struct JensonEvent: Codable { /// The question being asked, if provided. public let question: JensonQuestion? + + public init(type: EventType, who: String, what: String, question: JensonQuestion?) { + self.type = type + self.who = who + self.what = what + self.question = question + } } /// A struct that represents a question event. @@ -51,6 +58,11 @@ public struct JensonQuestion: Codable { /// The list of choices the player can make. public let options: [JensonChoice] + + public init(question: String, options: [JensonChoice]) { + self.question = question + self.options = options + } } /// A struct that represents a choice that can be made by the player. @@ -60,4 +72,9 @@ public struct JensonChoice: Codable { /// The events that follow this choice. public let events: [JensonEvent] + + public init(name: String, events: [JensonEvent]) { + self.name = name + self.events = events + } } diff --git a/Sources/JensonKit/Models/JensonFile.swift b/Sources/JensonKit/Models/JensonFile.swift index e587cc4..2811f20 100644 --- a/Sources/JensonKit/Models/JensonFile.swift +++ b/Sources/JensonKit/Models/JensonFile.swift @@ -20,4 +20,9 @@ public struct JensonFile: Codable { /// The timeline of events that will be played. let timeline: [JensonEvent] + + public init(version: Int, timeline: [JensonEvent]) { + self.version = version + self.timeline = timeline + } }