def surviveRYes(): log.add_event("Debo seguir y encontrar una forma de recuperar mi sanidad, algo de calor deberia servir") self.addEvent("fuego") self.addEvent("palmera") removeItem(world, "radio") Story.addItem(self.world, "fuego") Story.addItem(self.world, "palmera")
def Answer2(): if Questions.answer == "1": Story.Story7() elif Questions.answer == "2": Story.Story8() else: Questions.Decision(2)
def ropeYes(): log.add_event("Es una cuerda! Que suerte tengo") c = Item.create("cuerda") inv.addItem(c) removeItem(world, "cuerda") if not (inv.getItem(Item.getItemId("madera")) is None): Story.addItem(self.world, "balsa")
def woodYes(): log.add_event("Esto me servira para muchas cosas...") c = Item.create("madera") inv.addItem(c) removeItem(world, "madera") if not (inv.getItem(Item.getItemId("cuerda")) is None): Story.addItem(self.world, "balsa")
def Answer1(): if Questions.answer == "1": Story.Story2() elif Questions.answer == "2": Story.Story3() elif Questions.answer == "3": Story.Story4() else: Questions.Decision(1)
class StoryParser(): def __init__(self, fileLocation): self.initParse(fileLocation) def initParse(self, fileLocation): self.story = Story() self.f = open(fileLocation) self.lines = self.f.readlines() self.f.close() print(self.lines) for x in range(len(self.lines)): if self.lines[x].strip() == "Dialogue": print("String (Dialogue) found on line: " + str(x)) try: if self.lines[x + 1] != "Dialogue": for y in range(len(self.lines)): if self.lines[y].strip() != "Dialogue": print("String (Not Dialogue) found on line: " + str(y)) self.story.getStoryDialogue(self.lines[y], y) except: print("Out of Dialogue!") self.story.compareLists() self.story.createFinalDialogueList() self.story.printDialogue()
def readStoryFiles(): for storyId in storyIds: storyFile = open( directoryName.replace("\\", "/") + "/" + storyId + ".story", 'r') story = Story() # Headline of the story headline = storyFile.readline() colonIndex = headline.index(":") story.headline = headline[colonIndex + 2:] # Date of the story date = storyFile.readline() colonIndex = date.index(":") story.date = date[colonIndex + 2:] # Story ID of the story id = storyFile.readline() story.storyId = storyId # Sentences of the story storyFile.readline() storyFile.readline() fileContent = storyFile.read() fileContent = fileContent.replace("\\", "") fileContent = fileContent.replace("\'s", "") fileContent = fileContent.replace("\'", "") sent_detector = load('tokenizers/punkt/english.pickle') story.sentences = sent_detector.tokenize(fileContent.strip()) # Questions of the story story.questions = readQuestionsFile(storyId) sentenceProcessing(story) storyObjects.append(story)
def connect(data): #stories.append(data) print data if session.get('user') not in users: return storyList[data["name"]] = (Story.Story(data["storyText"], data["name"], data["name"], data["storyImage"])) newStories = [x.__dict__ for x in list(storyList.values())] socketio.emit('updateStories', list(reversed(newStories)))
def connect(data): #stories.append(data) print("New story", data) if data["ownerID"] not in users: return stories[data["ownerID"]] = (Story.Story(data["storyName"], data["ownerID"], data["storyText"], data["storyImage"])) newStories = [x.__dict__ for x in list(stories.values())] socketio.emit('updateStories', list(reversed(newStories)))
def readStoryFiles(): for storyId in storyIds: storyFile = open(directoryName.replace("\\", "/") + "/" + storyId + ".story", 'r') story = Story() # Headline of the story headline = storyFile.readline() colonIndex = headline.index(":") story.headline = headline[colonIndex + 2:] # Date of the story date = storyFile.readline() colonIndex = date.index(":") story.date = date[colonIndex + 2:] # Story ID of the story id = storyFile.readline() story.storyId = storyId # Sentences of the story storyFile.readline() storyFile.readline() fileContent = storyFile.read() fileContent = fileContent.replace("\\", "") fileContent = fileContent.replace("\'s", "") fileContent = fileContent.replace("\'", "") sent_detector = load('tokenizers/punkt/english.pickle') story.sentences = sent_detector.tokenize(fileContent.strip()) # Questions of the story story.questions = readQuestionsFile(storyId) sentenceProcessing(story) storyObjects.append(story)
def readStories(): f = open("stories.csv") strs = f.readlines() global poolMoney global numUsers for i, stry in enumerate(strs[1:]): temp = stry.split(",") if temp[0] == "": break poolMoney += 100 numUsers += 1 storyList[temp[0]] = (Story.Story(temp[2], temp[0], temp[0], temp[3])) print storyList #print temp return
def connect(): print("CONNECTEDD") global poolMoney global stories newStories = [x.__dict__ for x in list(stories.values())] emit("updatedMoney", poolMoney) global timer emit("timerUpdate", timer) emit('updateStories', list(reversed(newStories))) allUsers = [x.getName() for x in users.values()] socketio.emit("newUser", allUsers) global thread with thread_lock: if thread is None: thread = socketio.start_background_task(target=timerHelper) if stories == {}: temp = User.User(name="Zeeshan", balance=500) users[temp.getID()] = temp tempS = Story.Story( "College books", temp.getID(), "I need to buy books for college", "https://cdn.eso.org/images/thumb700x/eso1238a.jpg") stories[temp.getID()] = tempS
def surviveYes(): log.add_event("Creo haber visto algo que puede servirme cerca de la orilla...") self.addEvent("palmera") Story.addItem(self.world, "palmera")
def test_get_a_story(self): story = Story.get_a_story(self.repo_path) self.assertIsNotNone(story) print(story)
import Library, Game_Mechanics, Story, Encounters.pathEncounters import random Story.start_Up_Menu() user_Selection = input("|> ") if user_Selection.lower() == "start": # New Player Set-Up player = Library.new_Player() playerName = player.Name playerLevel = player.Level playerHealth = player.Health playerMana = player.Mana Story.intro() Library.randomPath() if user_Selection.lower() == "options": pass if user_Selection.lower() == "exit": quit()
def main(): ''' Make a new Brain given a list of JSON files.''' myBrain = load_brain([ 'assertions/story_demo/littlemermaid_people.json', 'assertions/story_demo/littlemermaid_scene1.json', 'assertions/story_demo/littlemermaid_scene2.json' ]) ''' Make a Story from this Brain. ''' littleMermaid = Story(myBrain) ''' Retrieve or remove scenes. ''' # Retrieve all scenes (as a list of Scene objects) in littleMermaid. # print littleMermaid.get_scenes() # Retrieve a scene object by its number. # Example: retrieve scene 2. # print littleMermaid.get_scene(2) # Retrieve certain scenes by their scene number. # Example: retrieve scene objects 1 and 2. # print littleMermaid.get_scenes_by_nums([1,2]) # Remove a scene by its number. # Example: Remove scene 2. # littleMermaid.remove_scene(2) # Remove all scenes. # littleMermaid.remove_scenes() # Remove certain scenes by their scene number. # Example: remove scenes 1 and 3, if they exist. # littleMermaid.remove_scenes([1,3]) ''' Add, remove, or retrieve assertions or StoryPoints (objects that store the assertions at distinct story time points) in a scene. ''' # Retrieve a scene's StoryPoints. # Example: retrieve StoryPoint objects from scene 1. # print littleMermaid.get_storypoints(1) # Retrieve assertion objects from a given scene and StoryPoint. # Example: retrieve assertions from scene 1, storypoint 2. # print littleMermaid.get_storypoint_assertions(1,2) # Add a StoryPoint to a scene. # Example: add a storypoint to scene 1. # - You can also use this command to add any assertion to the Story. # newAssertion = { # "l": ["Eric","sailors"], # "relation": "action", # "r": ["pat"], # "action_object": ["Grimsby"], # "location":["on"], # "location_object":["the back"], # "location_object_owner":["Grimsby"], # "with_property": ["sympathetic"], # "storypoints": [ # {"at": 5} # ], # "scene":"1", # "tense":"past" # } # littleMermaid.add_assertion(newAssertion) ''' Access, add, edit, or remove a scene setting. ''' # Access a scene's setting. # Example: retrieve the setting for scene 2, if any. # - This will return "" if there is no setting. # littleMermaid.get_setting(2) # Add/edit a full setting to a scene. # Example: add a setting to scene 3. # - Parameters are sceneNum, time, place, and general_place. # - Use the empty string if you don't want to list part of a setting. # - You can also use this command to replace a prior setting instead of using edit_setting. # littleMermaid.add_setting(3, "evening", "lighthouse", "INT.") # Edit one part of a setting. # Example: change the time for scene 2. # littleMermaid.edit_setting(2, "time", "morning") # Remove a setting. # Example: remove scene 2's setting. # littleMermaid.remove_setting(2) ''' Find, add, edit, or remove an actor. ''' # Retrieve all actors (as a list of Actor objects) in the story. # print littleMermaid.get_actors() # Retrieve the names of all actors in the story. # print littleMermaid.get_actor_names() # Retrieve an actor object given the actor's name or keyword. # print littleMermaid.get_actor("Seahorse Herald") # Remove a single actor from the story by their keyword or name. # littleMermaid.remove_actor("Grimsby") ''' Realize the story, or parts of the story. ''' # Realize the entire story. # (Only assertions with specified scenes/storypoints will be realized.) print "\n* * *" littleMermaid.realize() print "* * *\n" # Realize a story assertion, given the story brain. # Example: realize the 0th assertion in Scene 1, StoryPoint 2. # assertion = littleMermaid.get_storypoint_assertions(1,2)[0] # assertion.realize(littleMermaid.brain, False) # Example 2: realize a custom assertion. # assertion2 = Assertion.Assertion({ # "l": ["porpoises"], # "relation": "action", # "r": ["swim"], # "with_property":["happy"], # "storypoints": [{"begin": 0, "end": 1}] # }) # assertion2.realize(littleMermaid.brain, False) print "Process completed."
# player_health += 1 # elif x == 4: # print() # print("An angry squirrel bites you on the ankle!") # print("\tYour health is decreased by 1!") # player_health -= 1 # time.sleep(2) else: return # if __name__ == '__main__': # >> GAMEPLAY START << name, method = Story.the_story_begins() # << This TOTALLY works! player = Entities.PlayerCharacter(name) time.sleep(0) # Increase this later... if method == 'p': starting_weapon = Items.Weapon(*Items.starting_weapons[0]) player.equip_primary_weapon(starting_weapon) elif method == 's': starting_weapon = Items.Weapon(*Items.starting_weapons[1]) player.equip_primary_weapon(starting_weapon) spawn_enemy(7) spawn_area_of_interest(5) # >> MOVEMENT <<
def get_action_ps1(): return '{}o{}={}[{}====>{} : '.format(Fore.RED, Fore.YELLOW, Fore.LIGHTYELLOW_EX, Fore.WHITE, Style.RESET_ALL) def get_story_ps1(): return '{0}~\'({1}@{0}),~{2} : '.format(Fore.GREEN, Fore.RED, Style.RESET_ALL) def clear_screen(): unix = ['linux1', 'linux2', 'darwin'] windows = ['win32'] if platform in unix: system('clear') elif platform in windows: system('cls') if __name__ == '__main__': world = mp.Map() player = p.Player() messages = s.Story() # Initiate the player into the start position of the map x, y, z = world.init_player() player.set_position(x=x, y=y, z=z) main()