Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Destini-iOS13.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1100;
LastUpgradeCheck = 1100;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = "The App Brewery";
TargetAttributes = {
AD7631CF22FC5E7E00C6E71B = {
Expand Down Expand Up @@ -228,6 +228,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -288,6 +289,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
30 changes: 28 additions & 2 deletions Destini-iOS13/Controller/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,38 @@ class ViewController: UIViewController {
@IBOutlet weak var storyLabel: UILabel!
@IBOutlet weak var choice1Button: UIButton!
@IBOutlet weak var choice2Button: UIButton!
var storyBrain = StoryBrain()






override func viewDidLoad() {
super.viewDidLoad()


updateUI()
}


@IBAction func choiceMade(_ sender: UIButton) {

// save user's choice
let userChoice = sender.currentTitle!

// determine next question based on user choice
storyBrain.nextChoice(userChoice)

updateUI()

}

func updateUI() {
let tempCurrentStory = storyBrain.currentStory
storyLabel.text = storyBrain.allStories[tempCurrentStory].title
choice1Button.setTitle(storyBrain.allStories[tempCurrentStory].choice1, for: .normal)
choice2Button.setTitle(storyBrain.allStories[tempCurrentStory].choice2, for: .normal)

}

}

16 changes: 16 additions & 0 deletions Destini-iOS13/Model/Story.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@
//

import Foundation

struct Story {
var title: String
var choice1: String
var choice2: String
var choice1Destination: Int
var choice2Destination: Int

init(title: String, choice1 c1: String,choice1Destination: Int, choice2 c2: String, choice2Destination: Int){
self.title = title
self.choice1 = c1
self.choice2 = c2
self.choice1Destination = choice1Destination
self.choice2Destination = choice2Destination
}
}
61 changes: 61 additions & 0 deletions Destini-iOS13/Model/StoryBrain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,65 @@

import Foundation

struct StoryBrain {
var currentStory = 0
let allStories = [
Story(
title: "Your car has blown a tire on a winding road in the middle of nowhere with no cell phone reception. You decide to hitchhike. A rusty pickup truck rumbles to a stop next to you. A man with a wide brimmed hat with soulless eyes opens the passenger door for you and asks: 'Need a ride, boy?'.",
choice1: "I'll hop in. Thanks for the help!",
choice1Destination: 2,
choice2: "Better ask him if he's a murderer first.",
choice2Destination: 1
),
Story(
title: "He nods slowly, unfazed by the question.",
choice1: "At least he's honest. I'll climb in.",
choice1Destination: 2,
choice2: "Wait, I know how to change a tire.",
choice2Destination: 3
),
Story(
title: "As you begin to drive, the stranger starts talking about his relationship with his mother. He gets angrier and angrier by the minute. He asks you to open the glovebox. Inside you find a bloody knife, two severed fingers, and a cassette tape of Elton John. He reaches for the glove box.",
choice1: "I love Elton John! Hand him the cassette tape.",
choice1Destination: 5,
choice2: "It's him or me! You take the knife and stab him.",
choice2Destination: 4
),
Story(
title: "What? Such a cop out! Did you know traffic accidents are the second leading cause of accidental death for most adult age groups?",
choice1: "The",
choice1Destination: 0,
choice2: "End",
choice2Destination: 0
),
Story(
title: "As you smash through the guardrail and careen towards the jagged rocks below you reflect on the dubious wisdom of stabbing someone while they are driving a car you are in.",
choice1: "The",
choice1Destination: 0,
choice2: "End",
choice2Destination: 0
),
Story(
title: "You bond with the murderer while crooning verses of 'Can you feel the love tonight'. He drops you off at the next town. Before you go he asks you if you know any good places to dump bodies. You reply: 'Try the pier.'",
choice1: "The",
choice1Destination: 0,
choice2: "End",
choice2Destination: 0
)

]

mutating func nextChoice(_ userChoice: String) {
// create variable for current stories details
let currentStoryDetails = allStories[currentStory]

if userChoice == currentStoryDetails.choice1 {
currentStory = currentStoryDetails.choice1Destination
} else if userChoice == currentStoryDetails.choice2 {
currentStory = currentStoryDetails.choice2Destination
}
}

}


23 changes: 17 additions & 6 deletions Destini-iOS13/View/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -34,7 +36,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="wordWrap" translatesAutoresizingMaskIntoConstraints="NO" id="9QG-pg-Frw">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="wordWrap" translatesAutoresizingMaskIntoConstraints="NO" id="9QG-pg-Frw">
<rect key="frame" x="0.0" y="598" width="374" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="3Xd-kg-zdV"/>
Expand All @@ -49,8 +51,11 @@
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="clipsToBounds" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="choiceMade:" destination="BYZ-38-t0r" eventType="touchUpInside" id="LHF-N6-F3w"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="wordWrap" translatesAutoresizingMaskIntoConstraints="NO" id="fwF-55-PpX">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="wordWrap" translatesAutoresizingMaskIntoConstraints="NO" id="fwF-55-PpX">
<rect key="frame" x="0.0" y="718" width="374" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="ymn-43-hmb"/>
Expand All @@ -65,18 +70,21 @@
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="clipsToBounds" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="choiceMade:" destination="BYZ-38-t0r" eventType="touchUpInside" id="M9h-Gs-CSU"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="b0T-eg-tGE" secondAttribute="trailing" id="1lZ-W6-uyL"/>
<constraint firstItem="b0T-eg-tGE" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="Rb1-bv-uBs"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="b0T-eg-tGE" secondAttribute="bottom" id="YbR-3B-JmC"/>
<constraint firstItem="b0T-eg-tGE" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="ivh-d2-Ivg"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="choice1Button" destination="9QG-pg-Frw" id="aKS-Il-M1J"/>
Expand All @@ -93,5 +101,8 @@
<image name="background" width="958" height="1793"/>
<image name="choice1Background" width="1370.5" height="363"/>
<image name="choice2Background" width="1370.5" height="363"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>