def Battle_mob_phase(self, color_yellow) : # Monster battle phase while self.Hero_base_health > 0 : self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) # Monster & Player battle phase properties # Hero's min - max damage | max dmg = base_str self.player_dmg = randrange(self.Hero_min_dmg, self.Hero_base_str) self.mob_dmg = randrange(1,5) self.mob_hp = self.mob_hp - self.player_dmg print "%s You did %i of damage to the monster! \n" %(self.Battle_MSG, self.player_dmg) self.continue_mob_battle_phase(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) print "%s mob hits you for %i damage! \n" %(self.Battle_MSG, self.mob_dmg) self.Hero_base_health = self.Hero_base_health - self.mob_dmg # Certain battle phase conditions. These will execute if the conditions are met! if self.mob_hp < 0 : self.mob_hp += 15 self.total_experience = self.mob_exp + self.total_experience print "%s You defeated the mob! With %i life remaining!" %(self.Battle_MSG, self.Hero_base_health) # Return to the menu after monster has been defeated self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) elif self.Hero_base_health < 10 : print "%s NO!! You're near death! With only %i hp left! Use a potion!" %(self.Help_MSG, self.Hero_base_health) # Level up system elif self.total_experience >= self.total_exp_for_next_level : self.Level_System_Function(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) self.Next_LVL() self.Next_LVL_PHASE() return # If player dies self.PlayerDieMSG() return
def debugGreen(msg) : global default_bg global default_colors cons.set_text_attr(default_colors) print(" >" + msg) cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY)
def parseTagLine(self): self.isTagOpen = True self.openTag, self.closeTag, globalOpenTag, globalCloseTag, self.output = "", "", "", "", "" while (True): self.index += 1 if (self.line[self.index] != "]"): if (self.line[self.index] == "/"): self.isTagOpen = False self.index += 1 if (self.isTagOpen): self.openTag += self.line[self.index] globalOpenTag = self.openTag else: self.closeTag += self.line[self.index] globalCloseTag = self.closeTag else: break if (self.isTagOpen): self.tagDict[globalOpenTag] = cons.get_text_attr() try: cons.set_text_attr(colors[eval('self.' + vars()['globalOpenTag'])[2]] | default_bg | cons.FOREGROUND_INTENSITY) except AttributeError: self.fault(1); return else: try: cons.set_text_attr(self.tagDict[globalCloseTag]) except KeyError: self.fault(3); return self.index += 1 while (True): try: self.output += self.line[self.index] self.index += 1 if (self.line[self.index] == "["): print self.output, self.parseTagLine() except IndexError: break
def Check(expected, actual, message): if actual != expected: default_colors = cons.get_text_attr() default_bg = default_colors & 0x0070 cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print('ERROR:', ) cons.set_text_attr(default_colors) print(message % (expected, actual))
def __init__(self, w_title) : """ Base Framework initial constructor """ # Prepare the framework class contructor self.Game_title_Intro(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) Interface_Game_Intro() Interface_Menu() # Call Game class self.call_game = Game() self.call_game.Game_Start(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY))
def Hero_Battle_Menu(self, color_grey) : self.Menu_options(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) battle_menu = raw_input("%s Select the option you wish to choose : " %(self.Battle_MSG)) # Add a newline in the console... print "\n" if battle_menu == "1" : # Attack choice self.continue_player_battle_phase(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) elif battle_menu == "2" : # Spell book choice self.hero_spell_check() return self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) elif battle_menu == "3" : # Access Fairy Elf skill list choice self.hero_skill_check() return self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) elif battle_menu == "4" : # Inventory choice print "Your current inventory is %s " %(self.HERO_INVENTORY) self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) elif battle_menu == "5" : # View hero stats choice self.Stats_title(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) self.Stats(color_green = cons.set_text_attr(cons.FOREGROUND_GREEN)) return self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) else : # if invalid number range entered print "%s You didn't enter a valid number range!" %(self.Battle_MSG) self.Hero_Battle_Menu(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY))
def Type_Menu(self, color_yellow) : type_menu = \ """ Before you start your quest in Text RPG! You first need to choose a class type that you wish to play. Each class has its own bonuses and weaknesses. So choose wisely! Below, there is 3 class types to choose from. \n """ print type_menu self.Dark_Knight(color_red = cons.set_text_attr(cons.FOREGROUND_RED)) self.Dark_Wizard(color_blue = cons.set_text_attr(cons.FOREGROUND_BLUE)) self.Fairy_Elf(color_purple = cons.set_text_attr(cons.FOREGROUND_MAGENTA)) self.Classhelp(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW))
def Menu_System(self, color_cyan) : menu_OP = \ """ 0 - Acess Inventory 1 - Location Select 2 - Hero stats 3 - Enter Battle location 4 - Enter Town """ print menu_OP MS = raw_input("Select the option from the menu : ") if MS == "0" : print "Your current inventory is : %s" %(self.HERO_INVENTORY[0:10]) return self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) if MS == "1" : print "Location Module not available yet!" return self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) elif MS == "2" : self.Stats_title(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) self.Stats(color_green = cons.set_text_attr(cons.FOREGROUND_GREEN)) return self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) elif MS == "3" : print "You have chosen to enter a battle!" self.Encounter_Phase(color_red = cons.set_text_attr(cons.FOREGROUND_RED)) elif MS == "4" : print "Town Module not available yet!" return self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN)) else : print "You didn't enter a vaild number range!" self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN))
def Game_Start(self, color_grey) : menu_choice = raw_input("(Enter a number to start the game. To start the game press 1, to quit press 3) ") if menu_choice == "1" : system('cls') self.Game_title_Story(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) Interface_Story_Intro() self.Class_Select() self.Hero() Battle_Phase() elif menu_choice == "2" : Credits() return self.Game_Start(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) elif menu_choice == "3" : exit() else : print "You need to enter a valid number range!" self.Game_Start(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY))
def color(self, text, color=None, background=None): if background is None and color is not None: cons.set_text_attr( self._COLORS_FOREGROUND[color] | self.default_bg | cons.FOREGROUND_INTENSITY) print(text, end='') cons.set_text_attr(self.default_colors) elif background is not None and color is not None: cons.set_text_attr(self._COLORS_FOREGROUND[color] | self._COLORS_BACKGROUND[background] | cons.FOREGROUND_INTENSITY | cons.BACKGROUND_INTENSITY) print(text, end='') cons.set_text_attr(self.default_colors)
def parse(self): self.tagDict = {} self.tagIndex = 0 self.inFile = open(self.text, 'r') for line in self.inFile: self.openTag = "" self.tagDef = "" self.index = 0 self.line = list(line) if (self.line[self.index] == "#"): pass elif (self.line[self.index] == "."): self.index += 1 while (self.index < len(self.line)): self.tagDef += self.line[self.index] self.index += 1 exec("self." + self.tagDef) elif (self.line[self.index] == "["): self.parseTagLine() print cons.set_text_attr(cons.FOREGROUND_GREY | default_bg)
def check_once(lines, proc_handle) : debug_it = True readingOnce = False once_starts = 0 line_num = 0 for line in lines : line = line.strip() if (readingOnce == True) : if (line.startswith("debug=")) : boolean = line.split("=")[1] if (boolean == "0" or boolean == "false") : print(" >debug has been set to false") debug_it = False elif (boolean == "1" or boolean == "true") : print(" >debug has been set to true") debug_it = True else : cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print(line + " <- bad command") cons.set_text_attr(default_colors) elif (line == "}") : readingOnce = False lines = lines[:once_starts] + lines[line_num +1:] break else : parse_line(proc_handle, line, line_num, debug_it) elif (line.startswith("once={")) : readingOnce = True once_starts = line_num line_num += 1 return (lines, debug_it)
def parse(self): tag = "" ctag = "" tagd = "" index = 0 inf = open(self.text, 'r') print "File: " + self.text for line in inf: index = 0 line = list(line) if (line[index] == "#"): pass elif (line[index] == "."): index = index + 1 while (index < len(line)): tagd = tagd + line[index] index = index + 1 exec(tagd) elif (line[index] == "["): while (True): index = index + 1 if (line[index] != "]"): tag = tag + line[index] else: break try: eval(vars()['tag']) except NameError: cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print "Tag not defined!" cons.set_text_attr(cons.FOREGROUND_GREY | default_bg | cons.FOREGROUND_INTENSITY) output = "" cons.set_text_attr(colors[eval(vars()['tag'])[2]] | default_bg | cons.FOREGROUND_INTENSITY) index = index + 1 while (line[index] != "["): output = output + line[index] index = index + 1 index = index + 1 if (line[index] == "/"): while (True): index = index + 1 if (line[index] != "]"): ctag = ctag + line[index] else: break if (tag == ctag): print output tag = "" ctag = "" output = "" cons.set_text_attr(cons.FOREGROUND_GREY | default_bg)# | cons.FOREGROUND_INTENSITY)
def parse_line(proc_handle, line, line_num, debug_it) : bad_line = False global default_bg global default_colors if (debug_it == True) : cons.set_text_attr(default_colors) if (line.startswith("int:")) : set_variable(line, proc_handle, debug_it, "int") elif (line.startswith("float:")) : set_variable(line, proc_handle, debug_it, "float") elif (line.startswith("write:") or line.startswith("write.")) : set_write(line, proc_handle, debug_it) elif (line.startswith("sleep:")) : timeToSleep = int(line.split(":")[1]) time.sleep(timeToSleep / 1000.0) elif (line.startswith("print:")) : print(line[6:]) elif (line.startswith("print.var:")) : print(get_sum(line[10:], proc_handle, integers, floating_points, debug_it)) elif (line != "") : bad_line = True if (debug_it == True) : cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) if (bad_line == False) : if (debug_it == True) : cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) if (debug_it == True) : print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) if (bad_line == True) : return False else : return True
def setGray(): cons.set_text_attr(cons.FOREGROUND_INTENSITY | default_bg | cons.FOREGROUND_INTENSITY)
def Encounter_Phase(self, color_red) : # This function is just for looping back and forth between phases. raw_input("You have encountered a hostile monster! %s Press the ENTER Key!" %(self.Help_MSG)) self.Battle_mob_phase(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW))
def test(): """Simple Pyton 3.0 test for color_console.""" default_colors = cons.get_text_attr() default_bg = default_colors & 0x0070 default_fg = default_colors & 0x0007 cons.set_text_attr(cons.FOREGROUND_BLUE | default_bg | cons.FOREGROUND_INTENSITY) print('===========================================') cons.set_text_attr(cons.FOREGROUND_BLUE | cons.BACKGROUND_GREY | cons.FOREGROUND_INTENSITY | cons.BACKGROUND_INTENSITY) print('And Now for Something', end=' ') sys.stdout.flush() # Force writing first part of the line in blue cons.set_text_attr(cons.FOREGROUND_RED | cons.BACKGROUND_GREY | cons.FOREGROUND_INTENSITY | cons.BACKGROUND_INTENSITY) print('Completely Different!') cons.set_text_attr(default_colors) cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print('===========================================') cons.set_text_attr(default_colors)
def test(): """Simple test for color_console.""" default_colors = cons.get_text_attr() default_bg = default_colors & 0x0070 cons.set_text_attr(cons.FOREGROUND_BLUE | 0x0025 | cons.FOREGROUND_INTENSITY) print ' blue text... expected' print '===========================================' cons.set_text_attr(cons.FOREGROUND_BLUE | cons.BACKGROUND_GREY | cons.FOREGROUND_INTENSITY | cons.BACKGROUND_INTENSITY) print 'And Now for Something', cons.set_text_attr(cons.FOREGROUND_RED | cons.BACKGROUND_GREY | cons.FOREGROUND_INTENSITY | cons.BACKGROUND_INTENSITY) print 'Completely Different!', cons.set_text_attr(default_colors) print cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print ' green text... expected' print '===========================================' cons.set_text_attr(default_colors)
def choice_conf(filename) : print("clicked: %s" % filename) window.destroy() newwin = tk.Tk() newwin.title("pylaf (flyff tools coded in python) by lava") newwin.resizable(width="false", height="false") newwin.minsize(380, 200); newwin.protocol("WM_DELETE_WINDOW", on_closing) readingRange = False readingRagneON = False readingRagneOFF = False readingSpamSkill = False readingSpamSkillOptions = False readingSpamSkillOptionsIndex = 0; readingAutoSelectTarget = False readingAutoSelectTargetON = False readingAutoSelectTargetOFF = False waigin_for_end = False readingMouseClickTeleport = False readingMouseClickTeleportON = False readingCustomOption = False readingCustomOptionON = False readingCustomOptionOFF = False customFunctionName = "" global integers module = 0 proc_handle = 0 global proc_id bad_lines_count = 0 global default_bg global default_colors line_num = 1 with open(filename) as f : for line in f : line = line.strip() bad_line = False dont_color = False used_parse = False inquotes = False index = 0 for char in line : if (inquotes == True) : if (char == '"') : inquotes = False line = line[:index] + line[index +1:] else : index += 1 elif (char == '"') : inquotes = True line = line[:index] + line[index +1:] elif (char == ' ') : line = line[:index] + line[index +1:] elif (char == ' ') : line = line[:index] + line[index +1:] else : index += 1 if (char == ';') : exploded = line.split(";") print(" >not reading comment:\n" + line[index:]) line = exploded[0] if (len(line) > 1) : if (line[len(line) -1] == "\"") : line = line[:len(line) -1] if len(line) != 0 : cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) if (readingRange == True) : if (readingRagneON == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False add_to_range_lines(line, True) elif "{" in line : waigin_for_end = True add_to_range_lines(line, True) elif (line != "}") : add_to_range_lines(line, True) else : cons.set_text_attr(default_colors) print(" >end of when range is set to ON") readingRagneON = False dont_color = False elif (readingRagneOFF == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False add_to_range_lines(line, False) elif "{" in line : waigin_for_end = True add_to_range_lines(line, False) elif (line != "}") : add_to_range_lines(line, False) else : cons.set_text_attr(default_colors) print(" >end of when range is set to ON") cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) readingRagneOFF = False dont_color = False elif (line.startswith("ON={")) : debugGreen("going to read when range is set to ON") readingRagneON = True # if range ON has defined then drawing its button tk.Button(frame, text="range ON", command=lambda :set_range(proc_handle, True)).pack(side="left") elif (line.startswith("OFF={")) : debugGreen("going to read when range is set to OFF") readingRagneOFF = True # if range OFF has defined then drawing its button tk.Button(frame, text="Range OFF", command=lambda :set_range(proc_handle, False)).pack(side="left") elif (line == "}") : debugGreen("end of range function") readingRange = False # packing range frame frame.pack(fill="x") elif (line != "") : bad_line = True bad_lines_count += 1 cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) elif (readingSpamSkill == True) : if (readingSpamSkillOptions == True) : if (line == "}") : debugGreen("end of options") readingSpamSkillOptions = False # when options reading ended then packing list + scroll bar list1.config(width=5, height=3) scrollbar.config(command=list1.yview) list1.pack(side="left") scrollbar.pack(side=tk.LEFT, fill=tk.Y) tk.Button(frame1, text="ON", command=lambda :set_thread(True)).pack(side="left") tk.Button(frame1, text="OFF", command=lambda :set_thread(False)).pack(side="left") else : if "," in line : tpb = line.split(',') list1.insert(readingSpamSkillOptionsIndex, tpb[0]) readingSpamSkillOptionsIndex += 1 spam_bytes_arr.append(tpb[1]) elif (line.startswith("options=")) : debugGreen("going to read options") readingSpamSkillOptions = True tk.Label(frame1, text="spamm skill").pack(side="left") # making listbox + scroll bar scrollbar = tk.Scrollbar(frame1, orient=tk.VERTICAL) list1 = tk.Listbox(frame1, selectmode=tk.MULTIPLE, yscrollcommand=scrollbar.set) list1.bind('<<ListboxSelect>>', onselect) elif (line.startswith("sleep:")) : debugGreen("reading thread sleep time") global sleeptime sleeptime = int(line.split(":")[1]) + 0.0 elif (line == "}") : debugGreen("end of spamSkill function") readingSpamSkill = False # packing spamSkill frame frame1.pack(fill="x") elif (line != "") : bad_line = True bad_lines_count += 1 cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) elif (readingAutoSelectTarget == True) : if (readingAutoSelectTargetON == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False add_to_select_lines(line, True) elif "{" in line : waigin_for_end = True add_to_select_lines(line, True) elif (line != "}") : add_to_select_lines(line, True) else : debugGreen("end of autoSelectTarget when on ON function") readingAutoSelectTargetON = False dont_color = False elif (readingAutoSelectTargetOFF== True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False add_to_select_lines(line, False) elif "{" in line : waigin_for_end = True add_to_select_lines(line, False) elif (line != "}") : add_to_select_lines(line, False) else : debugGreen("end of autoSelectTarget when on OFF function") readingAutoSelectTargetOFF = False dont_color = False elif (line.startswith("sleep:")) : debugGreen("reading thread sleep time") global select_thread_sleep_time select_thread_sleep_time = int(line.split(":")[1]) + 0.0 elif (line.startswith("ON={")) : debugGreen("reading autoSelectTarget when on ON function") readingAutoSelectTargetON = True # adding on button tk.Button(frame2, text="ON", command=lambda :set_select_thread(True)).pack(side="left") tk.Button(frame2, text="OFF", command=lambda :set_select_thread(False)).pack(side="left") # making thread thread.start_new_thread(_select_thread, (proc_handle,)) elif (line.startswith("OFF={")) : debugGreen("reading autoSelectTarget when on OFF function") readingAutoSelectTargetOFF = True # thead has been crated when ON exists, so no more ^^ elif (line == "}") : debugGreen("end of autoSelectTarget function") readingAutoSelectTarget = False # packing autoSelectTarget frame frame2.pack(fill="x") elif (line != "") : bad_line = True bad_lines_count += 1 cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) elif (readingMouseClickTeleport == True) : if (readingMouseClickTeleportON == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False add_to_teleport_lines(line) elif "{" in line : waigin_for_end = True add_to_teleport_lines(line) elif (line != "}") : add_to_teleport_lines(line) else : debugGreen("end of mouseClickTeleport function when its on") readingMouseClickTeleportON = False dont_color = False elif (line.startswith("sleep:")) : debugGreen("reading thread sleep time") global teleport_thread_sleep_time teleport_thread_sleep_time = int(line.split(":")[1]) + 0.0 elif (line.startswith("ON={")) : debugGreen("going to read when mouseClickTeleport is ON") readingMouseClickTeleportON = True # adding on button tk.Button(frame3, text="ON", command=lambda :set_telport_thread(True)).pack(side="left") tk.Button(frame3, text="OFF", command=lambda :set_telport_thread(False)).pack(side="left") # making thread thread.start_new_thread(_teleport_thread, (proc_handle,)) elif (line == "}") : debugGreen("end of mouseClickTeleport function") readingMouseClickTeleport = False # packing mouseClickTeleport frame frame3.pack(fill="x") elif (readingCustomOption == True) : if (readingCustomOptionON == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False fillCustomFunctionProp(customFunctionName, "ON", line) elif "{" in line : waigin_for_end = True fillCustomFunctionProp(customFunctionName, "ON", line) elif (line != "}") : fillCustomFunctionProp(customFunctionName, "ON", line) else : debugGreen("end of when its ON") readingCustomOptionON = False dont_color = False elif (readingCustomOptionOFF == True) : cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) dont_color = True if (waigin_for_end == True) : if (line == "}") : waigin_for_end = False fillCustomFunctionProp(customFunctionName, "OFF", line) elif "{" in line : waigin_for_end = True fillCustomFunctionProp(customFunctionName, "OFF", line) elif (line != "}") : fillCustomFunctionProp(customFunctionName, "OFF", line) else : debugGreen("end of when its ON") readingCustomOptionOFF = False dont_color = False elif (line.startswith("gui.")): parse_gui(frame, line, line_num, True) elif (line.startswith("ON={")) : debugGreen("going to read when its ON") readingCustomOptionON = True # adding on button tk.Button(frame, text="ON", command=lambda :runCustomFunction(customFunctionName, "ON", proc_handle)).pack(side="left") elif (line.startswith("OFF={")) : debugGreen("going to read when its OFF") readingCustomOptionOFF = True # adding on button tk.Button(frame, text="OFF", command=lambda :runCustomFunction(customFunctionName, "OFF", proc_handle)).pack(side="left") elif (line == "}") : debugGreen("end of custom function") readingCustomOption = False # packing custion function frame frame.pack(fill="x") elif (line.startswith("window=")) : cons.set_text_attr(default_colors) # getting window name, it has to be set before write command windowName = line.split('=') print(" >got window name [%s]" % windowName[1]) hwnd = ctypes.windll.user32.FindWindowA(None, windowName[1]) print (hwnd) if (hwnd == 0) : print(" >no window found") ctypes.windll.user32.MessageBoxA(0, "window not found\ngoing to exit program", "cancer 404", 0) exit_me() else : ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(proc_id)) proc_handle = ctypes.windll.kernel32.OpenProcess(0x38, False, proc_id) if proc_handle : print(" >process opened successfully") # making key spamming thread thread.start_new_thread(_spam_thread, (hwnd,)) else : print(" >there was error while opening process\n try run it as admin") ctypes.windll.user32.MessageBoxA(0, "there was error while opening process\ntry run it as admin", "cancer 404", 0) exit_me() elif (line.startswith("range={")) : debugGreen("going to read range function") readingRange = True # creating range frame frame = tk.Frame() elif (line.startswith("spamSkill={")) : debugGreen("going to read spamSkill function") readingSpamSkill = True # creating spamSkill frame frame1 = tk.Frame() elif (line.startswith("autoSelectTarget={")) : debugGreen("going to read autoSelectTarget function") readingAutoSelectTarget = True # creating autoSelectTarget frame frame2 = tk.Frame() tk.Label(frame2, text="auto select target").pack(side="left") elif (line.startswith("mouseClickTeleport={")) : debugGreen("going to read mouseClickTeleport function") readingMouseClickTeleport = True # creating mouseClickTeleport frame frame3 = tk.Frame() tk.Label(frame3, text="mouse click teleport").pack(side="left") elif (line.endswith("={")) : debugGreen("going to read " + line[:len(line) -2] + " function") readingCustomOption = True addCustomFunctionProp(line[:len(line) -2]) customFunctionName = line[:len(line) -2] # creting custion function frame frame = tk.Frame() elif (line.startswith("version=")) : needs_version = line.split("=")[1] if (float(needs_version) > 1.3) : print(" >this is not right version for this script") ctypes.windll.user32.MessageBoxA(0, "this pylaf is not right version for this scrypt\ngoto youtube.com/c/lavaphox or pylafblue.gdk.mx and check for updates\ngoing to exit program", "cancer 404", 0) exit_me() elif (dont_color == False) : if (parse_line(proc_handle, line, line_num, True) == False) : bad_lines_count += 1 used_parse = True if (used_parse == False) : print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) line_num += 1 # enf of reading line by line # end of opening file if (bad_lines_count != 0) : cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print("bad lines count: " + str(bad_lines_count) + ", scroll up to see red line(s)") cons.set_text_attr(default_colors) else : cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print("thre is no errors") cons.set_text_attr(default_colors)
def print_debug(prt): if debug_flag_environ: cons.set_text_attr(cons.FOREGROUND_MAGENTA | default_bg | cons.FOREGROUND_INTENSITY) print("{}".format(prt)) cons.set_text_attr(default_colors)
def print_fail(prt): cons.set_text_attr(cons.FOREGROUND_RED | default_bg | cons.FOREGROUND_INTENSITY) print("{}".format(prt)) cons.set_text_attr(default_colors)
def __init__(self) : # Call Menu_System function and color it cyan using andre's color wrapper self.HP_Restore_Onlevelup() self.Mana_Restore_Onlevelup() self.Menu_System(color_cyan = cons.set_text_attr(cons.FOREGROUND_CYAN))
""" - Project : Text RPG! - Class description : Text RPG! interface module - Language : Python - Coded by : A.Taylor - Coder Name : S3pHiRoTh """ # Import andre's CLI color wrapper import color_console as cons # Global properties # Properties for CLI font color default_colors = cons.get_text_attr() default_bg = default_colors & 0x0070 cons.set_text_attr(cons.FOREGROUND_GREY | default_bg | cons.FOREGROUND_INTENSITY) class Interface_Menu(object) : """ Text RPG! interface class, all interface related stuff goes into this module """ def __init__(self) : """ Class constructor """ self.TextRPG_MENU(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY)) def TextRPG_MENU(self, color_grey) : menu_opts = \ """ \t\t\t 1 - New Game \t\t\t 2 - Credits \t\t\t 3 - Quit Game \n """
def check_if(line, line_num, proc_handle, is_if_true_arr, if_clauses, debug_it) : global integers global floating_points global default_bg global default_colors if (is_if_true_arr[if_clauses] == True) : if (line.startswith("if:")) : new_line = line[3:] if (is_if_true(new_line, proc_handle, integers, floating_points, debug_it) == True) : is_if_true_arr.append(True) if (debug_it == True) : print(" >if sentence is true") else : is_if_true_arr.append(False) if (debug_it == True) : print(" >if sentence is false") if_clauses += 1 if (debug_it == True) : cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) elif (line == "else") : is_if_true_arr[if_clauses] = False if (debug_it == True) : print (" >if sentence was true so need for else") cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) elif (line == "endif") : is_if_true_arr = is_if_true_arr[:if_clauses] if_clauses -= 1 if (debug_it == True) : print (" >true if sentence end") cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) else : parse_line(proc_handle, line, line_num, debug_it) else : if (line == "else") : if (is_if_true_arr[if_clauses -1] == True) : is_if_true_arr[if_clauses] = True if (debug_it == True) : print (" >if sentence was false so going to check else") cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) elif (line == "endif") : is_if_true_arr = is_if_true_arr[:if_clauses] if_clauses -= 1 if (debug_it == True) : print (" >false if sentence end") cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print(str(line_num) + ": " + line) cons.set_text_attr(default_colors) elif (line.startswith("if:")) : is_if_true_arr.append(False) if_clauses += 1 return (if_clauses, is_if_true_arr)
def setGreen(): cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg)
def setRed(): cons.set_text_attr(cons.FOREGROUND_RED | default_bg)
def __init__(self) : """ Class constructor """ self.Type_Menu(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW))
def __init__(self) : """ Class constructor """ self.DK_Class_Help(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) self.DW_Class_Help(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW)) self.FE_Class_Help(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW))
except KeyboardInterrupt: break match = re_tag.match(line) if not match is None: tagtype, tag, owner, message = match.groups() if filter_tags.__len__() > 0: if not tag.strip() in filter_tags: continue # linebuf = StringIO.StringIO() # center process info if PROCESS_WIDTH > 0: owner = owner.strip().center(PROCESS_WIDTH) cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_BLACK | cons.BACKGROUND_INTENSITY) print owner, cons.set_text_attr(default_colors) #linebuf.write("%s%s%s " % (format(fg=BLACK, bg=BLACK, bright=True), owner, format(reset=True))) # right-align tag title and allocate color if needed tag = tag.strip() color = allocate_color(tag) tag = tag[-TAG_WIDTH:].rjust(TAG_WIDTH) cons.set_text_attr(color) print tag, cons.set_text_attr(default_colors) print " ", #linebuf.write("%s%s %s" % (format(fg=color, dim=False), tag, format(reset=True)))
def print_warn(prt): cons.set_text_attr(cons.FOREGROUND_YELLOW | default_bg | cons.FOREGROUND_INTENSITY) print("{}".format(prt)) cons.set_text_attr(default_colors)
def __init__(self) : """ Class Constructor """ self.Creds(color_yellow = cons.set_text_attr(cons.FOREGROUND_YELLOW))
def print_pass(prt): cons.set_text_attr(cons.FOREGROUND_GREEN | default_bg | cons.FOREGROUND_INTENSITY) print("{}".format(prt)) cons.set_text_attr(default_colors)
def __init__(self) : """ Class constructor """ self.TextRPG_MENU(color_grey = cons.set_text_attr(cons.FOREGROUND_GREY))
color=cmd[5] canvas.create_line(int(x1*r), int(y1*r), int(x2*r), int(y2*r), fill=color) expected = getExpectedOutput() inputCache= getInputCache() actual=[] for i in range(len(expected)): inputStr=sys.stdin.readline() if len(inputStr)==0 : break actual.append(inputStr) default_colors = cons.get_text_attr() cons.set_text_attr(cons.FOREGROUND_GREEN | cons.BACKGROUND_GREY) resultArr=["green"]*len(expected) if len(expected)<=len(actual): l=len(expected) else: l=len(actual) print("Input Received is of shorter size than expected.Did you miss some test case?") print("Expected ",len(expected)," responses") print("Got ",len(actual)," responses") for i in range(l): if expected[i][0]=="$": print("Showing graphical test") root = Tk() root.title("Graphical Testing tool"); canvas = Canvas(width=500, height=500, bg='white') canvas.pack(expand=YES, fill=BOTH)
def __init__(self) : """ Class constructor """ self.Game_Intro(color_red = cons.set_text_attr(cons.FOREGROUND_RED))
except UnicodeError: continue except KeyboardInterrupt: break if not line: break match = retag.match(line.expandtabs()) if match: tagtype, tag, owner, message = match.groups() print(" " + tag.rjust(tag_width)[-tag_width:], end=' ', flush=True) if tagtype == "V": cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_GREY) elif tagtype == "D": cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_BLUE | cons.BACKGROUND_INTENSITY) elif tagtype == "I": cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_GREEN) elif tagtype == "W": cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_YELLOW) else: cons.set_text_attr(cons.FOREGROUND_BLACK | cons.BACKGROUND_RED) print(" " + tagtype, end=' ', flush=True) cons.set_text_attr(default_colors) for i in range(0,len(message),message_width): if i == 0: print (" " + message[i:i + message_width])
def __init__(self) : """ Class constructor """ self.Beg_Story(color_red = cons.set_text_attr(cons.FOREGROUND_RED))