-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Categories #18
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,37 @@ It most importantly provides the nextMessage and responseForMessage: methods. Wh | |
|
||
You can also provide an image representation of the character you strive to implement using the designated initializer of this class. | ||
*/ | ||
|
||
|
||
|
||
// Implementation of Topics | ||
enum Topic : String { | ||
case none = "none", Science = "Science", Apples = "Apples", Relativity = "Relativity", Physics = "Physics" // Add Topics here | ||
var description: String { | ||
switch(self) { | ||
case .none: | ||
return "none" | ||
case .Science: | ||
return "Science" | ||
case .Apples: | ||
return "Apples" | ||
case .Relativity: | ||
return "Relativity" | ||
case .Physics: | ||
return "Physics" | ||
} | ||
} | ||
} | ||
// Stores actual topic | ||
var theCurrentTopic = Topic.none | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nenn's einfach |
||
|
||
func changeTopic(changeRequest: Topic) { | ||
|
||
} | ||
|
||
|
||
|
||
|
||
class Chatter { | ||
|
||
/// Visual representation of the chatter. | ||
|
@@ -47,6 +78,21 @@ class Chatter { | |
|
||
- returns: A chat message the chat partner can respond to. | ||
*/ | ||
|
||
// Implementation of Topics | ||
var possibleTopics: [Topic] = [.none] // Add your Topics here | ||
var sayYesToTopicChangeWith = ["Yes, lets talk about that 😊"] | ||
var sayNoToTopicChangeWith = ["No, that is not what I want to talk with you about 😡"] | ||
var askForATopicChange = ["Lets talk about"] | ||
func responseForTopicChange(newTopic: Topic) -> (boolChange: Bool, changeText: String) { | ||
if(self.possibleTopics.contains(newTopic)) { | ||
return (true, self.sayYesToTopicChangeWith.randomElement()) | ||
} else { | ||
return (false, self.sayNoToTopicChangeWith.randomElement()) | ||
} | ||
} | ||
|
||
|
||
func nextMessage() -> Message { | ||
return [ | ||
Message(content: "Say, do you like butterflies?", type: .QuestionBool), | ||
|
@@ -114,6 +160,10 @@ class Chatter { | |
Message(content: "Good one 😉", type: .Statement), | ||
Message(content: "😀😀", type: .Statement) | ||
].randomElement() | ||
default: | ||
return [ | ||
Message(content: "Okay, Themawechsel", type: .Statement) | ||
].randomElement() | ||
} | ||
} | ||
|
||
|
@@ -150,7 +200,6 @@ Message instances represent a chat message and the meta data associated with it. | |
You can use the available properties to configure a text message with additional information that may help to understand the message's content. | ||
*/ | ||
struct Message: CustomStringConvertible { | ||
|
||
/// The message content | ||
let content: String | ||
|
||
|
@@ -159,7 +208,7 @@ struct Message: CustomStringConvertible { | |
|
||
/// The available message types. | ||
enum MessageType { | ||
case Statement, Joke, QuestionBool, QuestionWhy | ||
case Statement, Joke, QuestionBool, QuestionWhy, changeTopic | ||
} | ||
|
||
var description: String { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Einstein.swift | ||
// chatter | ||
// | ||
// Created by Max Simon on 27.04.16. | ||
// Copyright © 2016 Universität Heidelberg. All rights reserved. | ||
// | ||
|
||
/* | ||
Important: please add a default case to your switch-Statements when asking for the Message-type (this will not be executed :)) | ||
|
||
How to Work with Topics? | ||
If you want to create a topic go to Chatter.swift and add the Topic in the enum (with Description!) | ||
In the initializer of your chatter give possibleTopics a list of toppings your chatter want to talk about. (by default none) | ||
If you want to give individual answers for a ask to change the topic you can write them to sayNoToTopicChangeWith and sayYesToTopicChangeWith | ||
You can create your own Question to ask someone to change the topic. The Last word is computed and is the name of the topic. | ||
Now in your functions nextMessage() and responseForMessage you can ask the variable theCurrentTopic which Toping is now. With this you can adjust your answers to the topic. | ||
*/ | ||
|
||
|
||
|
||
import UIKit | ||
|
||
class Einstein: Chatter { | ||
|
||
required init() { | ||
super.init(image: UIImage(named: "einstein")) | ||
|
||
// accepted Topics | ||
possibleTopics = [.none, .Science, .Relativity, .Physics] | ||
//sayYesToTopicChangeWith = "Yes, I want to talk about this 😊" | ||
sayNoToTopicChangeWith = ["No, thankyou.", "No, that is not what I want to talk with you about 😡"] | ||
askForATopicChange = ["Lets talk about", "Do you want to talk about", "I want to tell you something about"] | ||
} | ||
|
||
|
||
override func nextMessage() -> Message { | ||
if(theCurrentTopic == Topic.Science) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Du brauchst keine Klammern um eine |
||
return [ | ||
Message(content: "This is science.", type: .Statement), | ||
Message(content: "Relativity is complex, but this is relative", type: .Joke), | ||
Message(content: "Yes, but never forget: E = m*c^2", type: .Joke), | ||
Message(content: "Relativity", type: .changeTopic), | ||
Message(content: "Physics", type: .changeTopic), | ||
|
||
].randomElement() | ||
} | ||
else { | ||
return [ | ||
|
||
Message(content: "You could be right, I have to think about this.", type: .Statement), | ||
|
||
Message(content: "Yes, I know.", type: .Statement), | ||
Message(content: "Maybe, maybe not. But who cares.", type: .Joke), | ||
Message(content: "Are you sure?", type: .QuestionBool), | ||
Message(content: "Do you calculated that?", type: .QuestionBool), | ||
Message(content: "Is this what you are really want to talk about?", type: .QuestionBool), | ||
Message(content: "What do you want to talk about?", type: .QuestionWhy), | ||
Message(content: "Why should that be?", type: .QuestionWhy), | ||
|
||
Message(content: "Science", type: .changeTopic), | ||
Message(content: "Physics", type: .changeTopic), | ||
].randomElement() | ||
} | ||
} | ||
|
||
override func responseForMessage(message: Message) -> Message { | ||
if(theCurrentTopic == Topic.Science) { | ||
return Message(content: "The topping is science, I love it :)", type: .Statement) | ||
} | ||
else { | ||
return Message(content: "Hmm...", type: .Statement) | ||
} | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x", | ||
"filename" : "einstein.png" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x", | ||
"filename" : "newton.png" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Newton.swift | ||
// chatter | ||
// | ||
// Created by Max Simon on 27.04.16. | ||
// Copyright © 2016 Universität Heidelberg. All rights reserved. | ||
// | ||
|
||
// | ||
// Einstein.swift | ||
// chatter | ||
// | ||
// Created by Max Simon on 27.04.16. | ||
// Copyright © 2016 Universität Heidelberg. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class Newton: Chatter { | ||
|
||
required init() { | ||
super.init(image: UIImage(named: "newton")) | ||
|
||
// accepted Topics | ||
possibleTopics = [.none, .Science, .Apples, .Physics] | ||
sayYesToTopicChangeWith = ["Oh Yes ❤️", "I thought you would never ask :D"] | ||
//sayNoToTopicChangeWith = ["Oh no, please not."] | ||
} | ||
|
||
|
||
override func nextMessage() -> Message { | ||
return [ | ||
|
||
Message(content: "You could be right, I have to think about this.", type: .Statement), | ||
Message(content: "This is science.", type: .Statement), | ||
Message(content: "Yes, I know.", type: .Statement), | ||
Message(content: "I like apples.", type: .Joke), | ||
Message(content: "Yes, but never forget: F = m*a", type: .Joke), | ||
Message(content: "Maybe, maybe not. But who cares.", type: .Joke), | ||
Message(content: "Are you sure?", type: .QuestionBool), | ||
Message(content: "Do you calculated that?", type: .QuestionBool), | ||
Message(content: "Is this what you are really want to talk about?", type: .QuestionBool), | ||
Message(content: "Do you want an apple?", type: .QuestionBool), | ||
Message(content: "What do you want to talk about?", type: .QuestionWhy), | ||
Message(content: "Why should that be?", type: .QuestionWhy), | ||
|
||
Message(content: "Science", type: .changeTopic), | ||
Message(content: "Apples", type: .changeTopic), | ||
Message(content: "Physics", type: .changeTopic), | ||
].randomElement() | ||
} | ||
|
||
override func responseForMessage(message: Message) -> Message { | ||
return Message(content: "Hmm...", type: .Statement) | ||
} | ||
|
||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Die
rawValue
s brauchst du nicht,Topic
muss nicht vonString
ableiten denke ich.