def make_player_message(text): player_text = '\x05\x42\x0F\x05\x40' pronoun_mapping = { "You have ": player_text + " ", "You are ": player_text + " is ", "You've ": player_text + " ", "Your ": player_text + "'s ", "You ": player_text + " ", "you have ": player_text + " ", "you are ": player_text + " is ", "you've ": player_text + " ", "your ": player_text + "'s ", "you ": player_text + " ", } verb_mapping = { 'obtained ': 'got ', 'received ': 'got ', 'learned ': 'got ', 'borrowed ': 'got ', 'found ': 'got ', } new_text = text # Replace the first instance of a 'You' with the player name lower_text = text.lower() you_index = lower_text.find('you') if you_index != -1: for find_text, replace_text in pronoun_mapping.items(): # if the index do not match, then it is not the first 'You' if text.find(find_text) == you_index: new_text = new_text.replace(find_text, replace_text, 1) break # because names are longer, we shorten the verbs to they fit in the textboxes better for find_text, replace_text in verb_mapping.items(): new_text = new_text.replace(find_text, replace_text) wrapped_text = line_wrap(new_text, False, False, False) if wrapped_text != new_text: new_text = line_wrap(new_text, True, True, False) return new_text
def __str__(self): return get_raw_text(line_wrap(colorText(self)))