def on_message(self, ws, message): if message.find(self.loginStatus) != -1: goCount = color.red("{} {}登陆".format(self.invoker, self.uuid)) self.pb.gameLogAddToFile(goCount, self.logFile) self.pb.gameLogAddToFile(message, self.logFile) ws.send(self.coinMatch) elif message.find(self.roomJoin) != -1: self.pb.gameLogAddToFile(message, self.logFile) ws.send(self.ready) elif message.find(self.gameStart) != -1: self.pb.gameLogAddToFile(message, self.logFile) ws.send(self.enableRobot) elif message.find(self.roomRemove) != -1: self.pb.gameLogAddToFile(message, self.logFile) ws.send(self.coinMatch) elif message.find(self.gameOver) != -1: goCount = color.red("{} {} 第{}局游戏结束".format( self.invoker, self.uuid, self.gameCount)) self.pb.gameLogAddToFile(goCount, self.logFile) self.pb.gameLogAddToFile(message, self.logFile) self.gameCount = self.gameCount + 1 ws.send(self.ready) elif self.gameCount == 3: ws.close() self.releaseThread() else: self.pb.gameLogAddToFile(message, self.logFile)
def help_info(): color.two_types(color.GREEN,color.UNDERLINE,'Saving') s_help = '\tAll entried are saved upon changing to a differ-\n' \ '\tent note or upon exit. Notes can also be saved\n' \ '\tusing the S command from the title page.' color.cyan(s_help) color.two_types(color.GREEN,color.UNDERLINE,'Listing') l_help = '\tThis command lists the notes that are currently\n' \ '\tpresent in the ~/.notes/ directory. All notes\n' \ '\twill be saved to this directory as plain text\n' \ '\tfiles' color.cyan(l_help) color.two_types(color.GREEN,color.UNDERLINE,'Note Choice') n_help = '\tAllows the user to choose one of the notes alrea-\n' \ '\tdy present as shown with the L command, or to cr-\n' \ '\teate a new note.' color.cyan(n_help) color.two_types(color.GREEN,color.UNDERLINE,'Print') p_help = '\tPrints an ordered list of entries within the note\n' \ '\tchosen with the L command. The numbers prior to\n' \ '\teach entry are used for reordering the note with\n' \ '\tthe R command.' color.cyan(p_help) color.two_types(color.GREEN,color.UNDERLINE,'Add') a_help = '\tAdds an entry to the end of the note selected wi-\n' \ '\tth the L command.' color.cyan(a_help) color.two_types(color.GREEN,color.UNDERLINE,'Delete') d_help = '\tDeletes an entry of the selected note. The number\n' \ '\tcorresponds to the number shown prior to the entry\n' \ '\twith the L command.' color.cyan(d_help) color.two_types(color.GREEN,color.UNDERLINE,'Reorder') r_help = '\tReorders entries within the note selected. Numbe-\n' \ '\trs correspond to those shown with the L command.\n' \ '\tThe first number input is the note to be moved and\n' \ '\tthe second is the location to put it.' color.cyan(r_help) color.two_types(color.GREEN,color.UNDERLINE,'Exit') e_help = '\tExits the program after saving the current note.' color.cyan(e_help) color.two_types(color.GREEN,color.UNDERLINE,'Help') h_help = '\tDisplays this screen.' color.cyan(h_help) print('\n') color.red('Press enter to return to the main menu') main_menu = input() if main_menu: return
def delete_entry(n_list): # Delete an entry from the note del_num = input('\nWhich entry would you like to delete? (All or number)\n') try: int(del_num) del n_list[int(del_num)-1] return n_list except: pass if del_num.lower() in ['all','a']: del n_list[:] else: color.red('That is an invalid entry.') return n_list
def no_note(): color.red('\nPlease choose a note to work with')
def test_red(self): got = color.red('hi') expected = '\x1b[;31mhi\x1b[0m' self.assertEqual(got, expected)