def encounter_roll(self, current_space): i_e_list = (8, 23, 25, 29, 30) poison_list = (20, 21, 26, 27, 28, 35, 35, 36) x = random.randint(1, 5) y = 4 if current_space in i_e_list: self.interactive_encounter(current_space) elif current_space == 15: print merchant_func('self') self.user_input(current_space) elif current_space == 5: print sorrow_lake('stuff') self.user_input(current_space) #elif current_space == 5 or current_space == 11: # a, b, c = the_sorrow('self', current_space) # print a # print b # print c # self.user_input(current_space) elif current_space == 22 or current_space == 24: self.user_input(current_space) elif x == y: if current_space in poison_list: self.poison_encounter(current_space) elif 3 == current_space or 14 == current_space: print format_text('self', Tile_Change_Scene[0]) current_space = random.randint(1, 36) self.scene(current_space) elif current_space == 23: self.memory_nymph(current_space) else: self.attack_engine(current_space) elif x != y: self.user_input(current_space)
def merchant_func(self): #Print intro, take input, parse input, take input until goodbye key triggered. val = 0 key = 0 scenes = encounter[15] print format_text('self', Merchant_Scenes[0][0]) while key != 2: u_i = raw_input("> ") for keys in Merchant_Inp: if keys in u_i: key = Merchant_Inp[keys] if key == 0: print sell('self') key = 2 elif key != 0: print format_text('self', Merchant_Scenes[0][key]) elif u_i not in keys: val += 1 if val == len(Merchant_Inp): print " I don't understand what you're looking for." else: continue else: return " Goodbye"
def passive_encounter(self, current_space): current_scenes = encounter[current_space] current_dict = encounter_directory[current_space] intro_scene = current_scenes[0] print format_text('self', intro_scene) val = 0 a, b = 0, 0 text = 0 action = 0 #Check dictionary for request to exit encounter. while val != 1: u_i = raw_input("> ") key_list = pull_action_keys('self', current_space, u_i) sub_key_list = pull_sub_keys('self', current_space, u_i) text = check_for_dialogue('self', current_space, u_i) ###Need to print if len(text) != 0: print text #if current_dict[text] == 1: # val = 1 #else: # print "hello" elif len(key_list) != 0: for action in key_list: a = action if len(sub_key_list) == 0: print "What would you like to %r ?" % a elif len(sub_key_list) != 0: b = sub_key_list buy_sell_trade('self', a, b) elif len(sub_key_list) != 0: print "What would you like to do with your %r ?" % sub_key_list b = sub_key_list.pop() print format_text('self', current_scenes[1])
def the_sorrow(self, current_space): scene_group = encounter[current_space] scene = random.randrange(1, len(scene_group)) Hit_Points["Hero"] = (Hit_Points["Hero"] + scene_group[scene][0]) return format_text('self', scene_group[0][0]), format_text( 'self', scene_group[scene] [1]), " Your health is now %r." % Hit_Points["Hero"]
def help(self): print " Tell me what you need help with. When you are done, type \"done\"." val = 0 u_i = 0 while u_i != "done": u_i = raw_input("> ") for key in help_d: if key in u_i: print format_text('self', help_d[key]) elif key not in u_i: val += 1 if val != len(help_d): continue elif val == len(help_d): print " Please try to explain your problem again." else: print " I hope we've solved your issue."
def interactive_encounter(self, current_space): ###print intro scene, take input until exit scene triggered then pass to self.scene(current_space). #Merchant_Inp current_dict = encounter_directory[current_space] current_scenes = encounter[current_space] intro_scene = current_scenes[0] print format_text('self', intro_scene) value = 0 counter = 0 while value != 2: u_i = raw_input("> ") for key in current_dict: if key in u_i: value = current_dict[key] current_scene = current_scenes[value] print format_text('self', current_scene) elif key not in u_i: counter += 1 if counter == len(current_dict): print "I don't understand." else: continue print format_text('self', scene[current_space]) self.user_input(current_space)
def attack_engine(self, current_space): val = 0 s_group = encounter[current_space] scene_group = s_group[1:len(s_group)] scene = random.choice(scene_group) #current_scene = scene[1] foe = foe_map[current_space] lucky = " Luck favors you and the %s attack misses completely." % foe ###While hero is alive, while foe is alive, if first time in, if subsequent times in. while Hit_Points["Hero"] > 0: while Hit_Points[foe] > 0: roll = random.randint(0, 4) scene = random.choice(scene_group) current_scene = scene[1] if val == 0: incoming = s_group[0][0] print format_text('stuff', incoming) if roll != 1: print self.defense_input(current_space, foe) val = 1 elif roll == 1: print format_text('stuff', lucky), self.defense_input( current_space, foe) val = 1 elif val == 1: if roll == 1: print lucky, self.defense_input(current_space, foe) val = 1 elif roll != 1: h_change = scene[0] print format_text( 'stuff', current_scene ), "Your health is now %s." % self.hero_health_change( h_change), self.defense_input(current_space, foe) val = 1 print " Your foe perishes at your feet. At surviving, you are victorious." self.scene(current_space) break print " With your last breath you scream \"Arturia!\" then you breath no more." exit(1)
def memory_nymph(self, current_space): format_text('self', Memory_Nymphs_Scenes[0][0]) scenes = Memory_Nymphs_Scenes[1], Memory_Nymphs_Scenes[2] scene = random.choice(scenes) item = scene[1] u_i = raw_input("> ") if "sit" in u_i or "yes" in u_i or "talk" in u_i: print format_text("self", scene[2]) print del_from_bag("stuff", item) self.user_input(current_space) elif "run" in u_i or "no" in u_i or "walk away" in u_i: print " You put some distance between yourself and the mysterious creature. " #Move player one space to the left. current_space = 22 self.scene(current_space) else: print " You can tell that the creature doesn't understand you but it continues anyway." print format_text("self", scene[2]) print del_from_bag("stuff", item) self.user_input(current_space)
def scene(self, current_space): incoming = scene[int(current_space)] print format_text('stuff', incoming) self.encounter_roll(current_space)
def poison_encounter(self, current_space): scene_set = encounter[current_space] intro, scene = scene_set[0][0], scene_set[random.randint( 1, (len(scene_set) - 1))][1] print format_text('self', intro) print format_text('self', scene)
def passive_encounter(self, current_space): current_scenes = encounter[current_space] intro_scene = current_scenes[0][0] print format_text('self', intro_scene)