<commit_before>//
//  InteractiveStory.swift
//  InteractiveStory
//
//  Created by <NAME> on 11/13/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import UIKit

enum Story: String {
  case returnTrip
  case touchDown
  case homeward
  case rover
  case cave
  case crate
  case monster
  case droid
  case home
}

extension Story {
  var artwork: UIImage {
    get {
      return UIImage(named: self.rawValue)!
    }
  }
  
  var text: String {
    get {
      switch self {
      case .returnTrip:
        return "On your return trip from studying Saturn's rings, you hear a distress signal that seems to be coming from the surface of Mars. It's strange because there hasn't been a colony there in years. \"Help me, you're my only hope.\""
      case .touchDown:
        return "You deftly land your ship near where the distress signal originated. You didn't notice anything strange on your fly-by, behind you is an abandoned rover from the early 21st century and a small crate."
      case .homeward:
        return "You continue your course to Earth. Two days later, you receive a transmission from HQ saing that they have detected some sort of anomaly on the surface of Mars near an abandoned rover. They ask you to investigate, but ultimately the decision is yours because your mission has already run much longer than planned and supplies are low."
      case .rover:
        return "The rover is covered in dust and most of the solar panels are broken. But you are quite surprised to see the on-board system booted up and running. In fact, there is a message on the screen. \"Come to 28.2342, -81.08273\". These coordinates aren't far but you don't know if your oxygen will last there and back."
      case .cave:
        return "Your EVA suit is equipped with a headlamp which you use to navigate to a cave. After searching for a while your oxygen levels are starting to get pretty low. You know you should go refill your tank, but there's a faint light up ahead."
      case .crate:
        return "Unlike everything else around you the crate seems new and...alien. As you examine the create you notice something glinting on the ground beside it. Aha, a key! It must be for the crate..."
      case .monster:
        return "You pick up the key and try to unlock the crate, but the key breaks off in the keyhole.You scream out in frustration! Your scream alerts a creature that captures you and takes you away..."
      case .droid:
        return "After a long walk slightly uphill, you end up at the top of a small crater. You look around and are overjoyed to see your robot friend, Droid-S1124. It had been lost on a previous mission to Mars. You take it back to your ship and fly back to Earth."
      case .home:
        return "You arrive home on Earth. While your mission was a success, you forever wonder what was sending that signal. Perhaps a future mission will be able to investigate."
      }
    }
  }
}<commit_msg>Create a page object that encapsulates a stage in the story. A page contains two choices a user can make that leads to another Page or stage in the story.<commit_after>//
//  InteractiveStory.swift
//  InteractiveStory
//
//  Created by <NAME> on 11/13/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import UIKit

enum Story: String {
  case returnTrip
  case touchDown
  case homeward
  case rover
  case cave
  case crate
  case monster
  case droid
  case home
}

extension Story {
  var artwork: UIImage {
    get {
      return UIImage(named: self.rawValue)!
    }
  }
  
  var text: String {
    get {
      switch self {
      case .returnTrip:
        return "On your return trip from studying Saturn's rings, you hear a distress signal that seems to be coming from the surface of Mars. It's strange because there hasn't been a colony there in years. \"Help me, you're my only hope.\""
      case .touchDown:
        return "You deftly land your ship near where the distress signal originated. You didn't notice anything strange on your fly-by, behind you is an abandoned rover from the early 21st century and a small crate."
      case .homeward:
        return "You continue your course to Earth. Two days later, you receive a transmission from HQ saing that they have detected some sort of anomaly on the surface of Mars near an abandoned rover. They ask you to investigate, but ultimately the decision is yours because your mission has already run much longer than planned and supplies are low."
      case .rover:
        return "The rover is covered in dust and most of the solar panels are broken. But you are quite surprised to see the on-board system booted up and running. In fact, there is a message on the screen. \"Come to 28.2342, -81.08273\". These coordinates aren't far but you don't know if your oxygen will last there and back."
      case .cave:
        return "Your EVA suit is equipped with a headlamp which you use to navigate to a cave. After searching for a while your oxygen levels are starting to get pretty low. You know you should go refill your tank, but there's a faint light up ahead."
      case .crate:
        return "Unlike everything else around you the crate seems new and...alien. As you examine the create you notice something glinting on the ground beside it. Aha, a key! It must be for the crate..."
      case .monster:
        return "You pick up the key and try to unlock the crate, but the key breaks off in the keyhole.You scream out in frustration! Your scream alerts a creature that captures you and takes you away..."
      case .droid:
        return "After a long walk slightly uphill, you end up at the top of a small crater. You look around and are overjoyed to see your robot friend, Droid-S1124. It had been lost on a previous mission to Mars. You take it back to your ship and fly back to Earth."
      case .home:
        return "You arrive home on Earth. While your mission was a success, you forever wonder what was sending that signal. Perhaps a future mission will be able to investigate."
      }
    }
  }
}

class Page {
  let story: Story
  
  typealias Choice = (title: String, page: Page)
  
  var firstChoice: Choice?
  var secondChoice: Choice?
  
  init(story: Story) {
    self.story = story
  }
}

extension Page {
  
  func addChoice(title: String, story: Story) -> Page {
    let page = Page(story: story)
    return addChoice(title: title, page: page)
  }

  func addChoice(title: String, page: Page) -> Page {
    
    switch (firstChoice, secondChoice) {
    case (.some, .some): break
    case (.none, .none), (.none, .some):
      firstChoice = (title, page)
    case(.some, .none):
      secondChoice = (title, page)
    }
    
    return page
  }
}
{'fraction_non_alphanumeric': 0.059994059994059996, 'fraction_numerical': 0.008613008613008613, 'mean_word_length': 2.9043478260869566, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2478362', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1753, 'n_words': 1019}