예제 #1
0
 def __init__(self, makeAToon, doneEvent, avList, index):
     StateData.StateData.__init__(self, doneEvent)
     self.makeAToon = makeAToon
     self.avList = avList
     self.index = index
     self.shopsVisited = []
     self.avId = -1
     self.avExists = 0
     self.names = ['',
      '',
      '',
      '']
     self.toon = None
     self.boy = 0
     self.girl = 0
     self.allTitles = []
     self.allFirsts = []
     self.allPrefixes = []
     self.allSuffixes = []
     self.titleIndex = 0
     self.firstIndex = 0
     self.prefixIndex = 0
     self.suffixIndex = 0
     self.titleActive = 0
     self.firstActive = 0
     self.lastActive = 0
     self.quickFind = 0
     self.listsLoaded = 0
     self.addedGenderSpecific = 0
     self.chastise = 0
     self.nameIndices = [-1,
      -1,
      -1,
      -1]
     self.nameFlags = [1,
      1,
      1,
      0]
     self.dummyReturn = 2
     self.nameAction = 0
     self.pickANameGUIElements = []
     self.typeANameGUIElements = []
     self.textRolloverColor = Vec4(1, 1, 0, 1)
     self.textDownColor = Vec4(0.5, 0.9, 1, 1)
     self.textDisabledColor = Vec4(0.4, 0.8, 0.4, 1)
     self.fsm = ClassicFSM.ClassicFSM('NameShop', [State.State('Init', self.enterInit, self.exitInit, ['PickAName']),
      State.State('PickAName', self.enterPickANameState, self.exitPickANameState, ['TypeAName', 'Done']),
      State.State('TypeAName', self.enterTypeANameState, self.exitTypeANameState, ['PickAName',
       'Approval',
       'Rejected']),
      State.State('Approval', self.enterApprovalState, self.exitApprovalState, ['PickAName', 'ApprovalAccepted']),
      State.State('ApprovalAccepted', self.enterApprovalAcceptedState, self.exitApprovalAcceptedState, ['Done']),
      State.State('Rejected', self.enterRejectedState, self.exitRejectedState, ['TypeAName']),
      State.State('Done', self.enterDone, self.exitDone, ['Init'])], 'Init', 'Done')
     self.parentFSM = makeAToon.fsm
     self.parentFSM.getStateNamed('NameShop').addChild(self.fsm)
     self.nameGen = NameGenerator.NameGenerator()
     self.fsm.enterInitialState()
     self.requestingSkipTutorial = False
     return
def generateFighterNPC():
    NPCrace = generateRACE()
    NPCclass = generateCLASS()
    NPCgender = generateGENDER()
    NPCcharachteristics = generateCHAR()
    npc = NameGenerator.generate(GENDERFlag, RACEflag)
    npc = npc + ' ' + '(' + NPCgender + ') ' + NPCrace + ' ' + NPCclass + ' '
    npc = npc + NPCcharachteristics
    return npc
예제 #3
0
 def create(self):
     self.gendervar = self.gender.get()
     if(self.gendervar == 0 or self.gendervar == 1):
         racevar = self.race.get()
         if(racevar):
             string = ng.generate(self.gendervar,racevar)
             self.text.config(state=NORMAL)
             self.text.delete(1.0, END)
             self.text.insert(INSERT,string)
             self.text.config(state=DISABLED)
         else:
             showerror('Error', 'Please select a race')
     else:
         showerror('Error', 'Please select a gender')
예제 #4
0
def create():
    gendervar = gender.get()
    if(gendervar == 0 or gendervar == 1):
        racevar = race.get()
        if(racevar):
            string = NameGenerator.generate(gendervar,racevar)
            text.config(state=NORMAL)
            text.delete(1.0, END)
            text.insert(INSERT,string)
            text.config(state=DISABLED)
        else:
            showerror('Error', 'Please select a race')
    else:
        showerror('Error', 'Please select a gender')
def generateNPC(n):
    if (n == 0):
        #0 is a warrior NPC
        NPCclass = generateCLASS()
    elif (n == 1):
        npc = generateCITIZEN()
    NPCrace = generateRACE()
    NPCgender = generateGENDER()
    NPCcharachteristics = generateCHAR()
    if (n == 0):
        npc = NameGenerator.generate(GENDERFlag, RACEflag)
        npc = npc + ' ' + '(' + NPCgender + ') ' + NPCrace + ' ' + NPCclass + ' '
        npc = npc + NPCcharachteristics
        return npc
    else:
        return npc
def generateNPC(n):
    if n == 0:
        # 0 is a warrior NPC
        NPCclass = generateCLASS()
    elif n == 1:
        npc = generateCITIZEN()
    NPCrace = generateRACE()
    NPCgender = generateGENDER()
    NPCcharachteristics = generateCHAR()
    if n == 0:
        npc = NameGenerator.generate(GENDERFlag, RACEflag)
        npc = npc + " " + "(" + NPCgender + ") " + NPCrace + " " + NPCclass + " "
        npc = npc + NPCcharachteristics
        return npc
    else:
        return npc
예제 #7
0
# Validating the entered gender in order to only accept 'g' or 'b'
while iv.validateGender(gender):
    gender = raw_input("Wrong input! Please either enter b or g")

minL = input('Enter minimum Length for the names: ')
while iv.validateMinimumLength(minL):
    minL = input(
        'Min length should be at least 1. Enter minimum Length for the names: '
    )

maxL = input('Enter maximum Length for the names: ')
while iv.validateMaximumLength(maxL):
    maxL = input(
        'Too big! Enter smaller length! less than 20! Enter maximum Length for the names: '
    )

order = input('Enter the markove model order: ')
while iv.validateOrder(order):
    order = input(
        'Please set the order higher than zero. Enter the markove model order: '
    )

count = input('how many names you want? ')
while iv.validateCount(count):
    count = input(
        'Are you kidding me?!I am too tired to generate all of these names! select a smaller number. how many names you want? '
    )

# Calling the generateNewNames of NameGenerator
ng.generateNewNames(minL, maxL, order, count, str(gender))
def generateCITIZEN():
    NPCrace = generateRACE()
    NPCgender = generateGENDER()
    citizen = NameGenerator.generate(GENDERFlag, RACEflag)
    #Decide what is the profession of the citizen.
    dice = randint(1, 10)
    #dice = 3 #this one is just for debugging
    #ALCHEMIST
    if (dice == 1):
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = 'an Alchemist, more specifically an apothecary'
        elif (dice == 2):
            NPCprofession = 'an alchemist, more specifically a hedge wizard'
        elif (dice == 3):
            NPCprofession = 'an alchemist, more specifically an herbalist'
        elif (dice == 4):
            NPCprofession = 'an alchemist, more specifically a poisonmaker'
        elif (dice == 5):
            NPCprofession = 'an alchemist, more specifically a potioneer'
        elif (dice == 6):
            NPCprofession = 'an alchemist, more specifically a pyromancer'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for delivery help '
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for new recipes '
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for purchasers '
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for rare ingredients '
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + 'and carries several vials of acids.'
        elif (dice == 2):
            NPCprofession = NPCprofession + 'and carries several curatives.'
        elif (dice == 3):
            NPCprofession = NPCprofession + 'and carries an unusual potion.'
        elif (dice == 4):
            NPCprofession = NPCprofession + 'and carries a pyrophoric substance.'
        else:
            NPCprofession = 'error with the carries'

    #BANDIT
    elif (dice == 2):
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = 'a bandit, more specifically an assassin'
        elif (dice == 2):
            NPCprofession = 'a bandit, more specifically a confidence artist'
        elif (dice == 3):
            NPCprofession = 'a bandit, more specifically a gambler'
        elif (dice == 4):
            NPCprofession = 'a bandit, more specifically a poacher'
        elif (dice == 5):
            NPCprofession = 'a bandit, more specifically a smuggler'
        elif (dice == 6):
            NPCprofession = 'a bandit, more specifically a thief'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for accomplices for a specific task'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for revenge against a rival criminal'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for an easy mark'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for extra muscle for some work'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is looking for rumors that may lead to a big score'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is looking for a owdy evening of carousing'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries a crossbow with poisoned darts.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries several daggers.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a short sword.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries a lucky charm.'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' and carries the token of a love.'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' and carries letters for blackmail.'
        else:
            NPCprofession = 'error with the carries'

    #LAW OFFICIAL
    elif (dice == 3):
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = 'a law official, more specifically a constable'
        elif (dice == 2):
            NPCprofession = 'a law official, more specifically a sheriff'
        elif (dice == 3):
            NPCprofession = 'a law official, more specifically a guard captain'
        elif (dice == 4):
            NPCprofession = 'a law official, more specifically a magistrate'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is seeking someone to capture a fugitive'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is seeking someone to catch a thief'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is seeking someone to guard a specific location or person'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is seeking someone to investigate a disappearance'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is seeking someone to solve a murder mystery'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is seeking someone to have an ale with'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries an arrest warrant for an outlaw.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a proclamation for a reward.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a knife or sword of the office.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries a pocketbook of local laws.'
        else:
            NPCprofession = 'error with the carries'

    #NOBLE
    elif (dice == 4):
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = 'a noble, more specifically a kinght'
        elif (dice == 2):
            NPCprofession = 'a noble, more specifically an old lord'
        elif (dice == 3):
            NPCprofession = 'a noble, more specifically a young lord'
        elif (dice == 4):
            NPCprofession = 'a noble, more specifically an old lady'
        elif (dice == 5):
            NPCprofession = 'a noble, more specifically a young lady'
        elif (dice == 6):
            NPCprofession = 'a noble, more specifically a wealthy merchant'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for someone to dispose of an enemy'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for someone to negotiate a trade contract'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for someone to prepare an army for war'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for someone to sabotage a rival'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is looking for someone to secure marriage'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is looking for someone to have a good time with'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries several deeds and titles.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a family heirloom.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries several inventories and invoices.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries a some very valuable jewels.'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' and carries a compromising love letter.'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' and carries a letter from a powerful lord or lady.'
        else:
            NPCprofession = 'error with the carries'

    #PRIEST
    elif (dice == 5):
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = 'a priest, more specifically an acolyte'
        elif (dice == 2):
            NPCprofession = 'a priest, more specifically a healer'
        elif (dice == 3):
            NPCprofession = 'a priest, more specifically a monk'
        elif (dice == 4):
            NPCprofession = 'a priest, more specifically a preacher'
        elif (dice == 5):
            NPCprofession = 'a priest, more specifically a scholar'
        elif (dice == 6):
            NPCprofession = 'a priest, more specifically a witch-hunter'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for new coverts'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for heretics'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for an relics and rare lore'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for the bottom of a goblet'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries a well-used cudgel.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a prominently displayed holy symbol.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a pocketbook of sacred texts.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries a wineskin.'
        else:
            NPCprofession = 'error with the carries'

    #SEER
    elif (dice == 6):
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = 'a seer, more specifically an astrologer'
        elif (dice == 2):
            NPCprofession = 'a seer, more specifically a fortune teller'
        elif (dice == 3):
            NPCprofession = 'a seer, more specifically a mystic'
        elif (dice == 4):
            NPCprofession = 'a seer, more specifically a lorekeeper'
        elif (dice == 5):
            NPCprofession = 'a seer, more specifically a prophet'
        elif (dice == 6):
            NPCprofession = 'a seer, more specifically a psychic'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for new clients for reading'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for the answer to a riddle or prophecy'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for an relics and news regarding a missing person'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for some juicy gossip'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries a crystall ball.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a dowsing rod.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a large, sharp-pointed knife.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries several star charts.'
        else:
            NPCprofession = 'error with the carries'

    #SMITH
    elif (dice == 7):
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = 'a smith, more specifically an armorer'
        elif (dice == 2):
            NPCprofession = 'a smith, more specifically a blacksmith'
        elif (dice == 3):
            NPCprofession = 'a smith, more specifically a farrier'
        elif (dice == 4):
            NPCprofession = 'a smith, more specifically a weaponsmith'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for a new apprentice'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for a journeyman craftsman'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for rare metals'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for a mug of strong ale'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries a hammer.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a metal trinket made by the smith.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a contract commisioning a weapon.'  #might insert the weapon randomizer... but maybe not because too much coding
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries little more than a few coins.'
        else:
            NPCprofession = 'error with the carries'

    #TRAVELER
    elif (dice == 8):
        dice = randint(1, 8)
        if (dice == 1):
            NPCprofession = 'a traveler, more specifically an exile'
        elif (dice == 2):
            NPCprofession = 'a traveler, more specifically a ministrel'
        elif (dice == 3):
            NPCprofession = 'a traveler, more specifically a peddler'
        elif (dice == 4):
            NPCprofession = 'a traveler, more specifically a pilgrim'
        elif (dice == 5):
            NPCprofession = 'a traveler, more specifically a refugee'
        elif (dice == 6):
            NPCprofession = 'a traveler, more specifically a sellsword'
        elif (dice == 7):
            NPCprofession = 'a traveler, more specifically a storyteller'
        elif (dice == 8):
            NPCprofession = 'a traveler, more specifically a treasure hunter'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 10)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for accomplices on a quest.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for the answer to a riddle.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for an audience to entertain.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for a long lost friend'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is looking for the return of something stolen.'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is looking for revenge against a bitter rival.'
        elif (dice == 7):
            NPCprofession = NPCprofession + ' is looking for a permanent home.'
        elif (dice == 8):
            NPCprofession = NPCprofession + ' is looking for steady work.'
        elif (dice == 9):
            NPCprofession = NPCprofession + ' is looking for traveling companions.'
        elif (dice == 10):
            NPCprofession = NPCprofession + ' is looking for drinking companions.'
        else:
            NPCprofession = 'error with the lookings'

    #BARMAN
    elif (dice == 9):
        if (NPCgender == 'Male'):
            NPCprofession = 'a Barman, and he'
        elif (NPCgender == 'Female'):
            NPCprofession = ' Barmaid, and she'
        else:
            NPCprofession = 'error with gender at stage 1'
        dice = randint(1, 8)
        if (dice == 1):
            NPCprofession = NPCprofession + ' greets you with a mug of ale'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' greets you with a goblet of wine'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' greets you with a glass of water'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' greets you with an offer to move to a better table'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' greets you with a look of exasperation'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' greets you with a warm handshake'
        elif (dice == 7):
            NPCprofession = NPCprofession + ' greets you with a pat on the back'
        elif (dice == 8):
            NPCprofession = NPCprofession + ' greets you with a pretty smile'
        else:
            NPCprofession = 'error with the greetings'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 6)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is looking for an excuse to kick you out'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is looking for somoeone more important to talk to'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is looking for someone to do some pest removal'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is looking for a big tip'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is looking for a good joke or story'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is looking for the bottom of a bottle'
        else:
            NPCprofession = 'error with the lookings'
        dice = randint(1, 4)
        if (dice == 1):
            NPCprofession = NPCprofession + ' and carries a filthy rag.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' and carries a pristine silk handkerchief.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' and carries a piece of cospicuous jewelry.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' and carries an unusual belt purse.'
        else:
            NPCprofession = 'error with the carries'

    #PAESANT
    elif (dice == 10):
        dice = randint(1, 8)
        if (dice == 1):
            NPCprofession = 'an old farmer'
        elif (dice == 2):
            NPCprofession = 'a middle-aged farmer'
        elif (dice == 3):
            NPCprofession = 'a young farmer'
        elif (dice == 4):
            NPCprofession = 'a farm kid'
        elif (dice == 5):
            if NPCgender == 'Female':
                NPCprofession = 'an old farmwife'
            elif NPCgender == 'Male':
                NPCprofession = 'an old farm-man'
        elif (dice == 6):
            if NPCgender == 'Female':
                NPCprofession = 'a tough farmwife'
            elif NPCgender == 'Male':
                NPCprofession = 'a tough farm-man'
        elif (dice == 7):
            if NPCgender == 'Female':
                NPCprofession = 'a young maid'
            elif NPCgender == 'Male':
                NPCprofession = 'a young maidman'
        elif (dice == 8):
            if NPCgender == 'Female':
                NPCprofession = 'a country girl'
            elif NPCgender == 'Male':
                NPCprofession = 'a country boy'
        else:
            NPCprofession = 'error in single prof'
        if NPCgender == 'Male':
            NPCprofession = NPCprofession + ', and he'
        elif NPCgender == 'Female':
            NPCprofession = NPCprofession + ', and she'
        else:
            NPCprofession = 'error with the gender'
        dice = randint(1, 8)
        if (dice == 1):
            NPCprofession = NPCprofession + ' is seeking someone to lend a hand on a laborious task.'
        elif (dice == 2):
            NPCprofession = NPCprofession + ' is seeking someone to repair a tool or farming implements.'
        elif (dice == 3):
            NPCprofession = NPCprofession + ' is seeking someone to help locate a missing beast.'
        elif (dice == 4):
            NPCprofession = NPCprofession + ' is seeking someone to help locate a missing person.'
        elif (dice == 5):
            NPCprofession = NPCprofession + ' is seeking someone to hHelp secure an audience with the lord/lady.'
        elif (dice == 6):
            NPCprofession = NPCprofession + ' is seeking someone to purchase or distribute crops.'
        elif (dice == 7):
            NPCprofession = NPCprofession + ' is seeking someone to purchase some livestock.'
        elif (dice == 8):
            NPCprofession = NPCprofession + ' is seeking someone to listen to a tale of woe.'
        else:
            NPCprofession = 'error with the lookings'
    else:
        NPCprofession = 'Error with the profession'
    citizen = NameGenerator.generate(GENDERFlag, RACEflag)
    citizen = citizen + ', ' + NPCrace + ' (' + NPCgender + ') ' + NPCprofession
    return citizen
예제 #9
0
#!/usr/bin/env python

import os
import json

import tornado.ioloop
import tornado.web
from tornroutes import route
from jinja2 import Environment, FileSystemLoader

from NameGenerator import *

templates = Environment(loader=FileSystemLoader('templates'))
redis_url = os.getenv('REDISTOGO_URL', 'redis://*****:*****@route(r"/")
class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        self.write(templates.get_template('index.html').render())


@route(r"/shorten_url")
class ShortenUrlHandler(tornado.web.RequestHandler):
    def post(self):
        """
        ip = self.request.remote_ip)
        tries = r.get(ip)
	"""
예제 #10
0
def returner(msg):
    dt = strftime("%Y{0}%m{1}%d{2}", localtime()).format('年','月','日')#当前时间
    pu = msg.member.puid
    if not os.path.exists('groups/'+WordStr.GroupName+'/'+pu):#第一次在群中出现的人的初始化
        init = 'wname\n'+msg.member.name+'\nname\n'+msg.member.name+'\nrp\n'+str(randint(1,100))+'\n'
        pers = open('groups/'+WordStr.GroupName+'/'+pu,mode = 'x')
        pers.write(init)
        pers.close()
        changemisc('pu',readmisc('pu')+[pu+'\n'])
        sleep(2)
    tn = getvl(pu,'name')
    if msg.member.name != getvl(pu,'wname'):#更新群昵称
        st(pu,'wname',msg.member.name)
    if (dt+'\n' != readmisc('dt')[0]):#jrrp更新
        changemisc('dt',dt+'\n')
        for i in range(0,len(readmisc('pu'))):
            st(readmisc('pu')[i][:-1],'rp',randint(1,100))
    if msg.text[0]+'\n' in readmisc('cmd'):
        if (msg.text[1:4] == 'bot'):
            if msg.member == group.owner:
                if (msg.text[5:] == 'on'):
                    changerule('mute','off')
                    group.send(WordStr.Unmuted)
                elif (msg.text[5:] == 'off'):
                    changerule('mute','on')
                    group.send(WordStr.Muted)
            else:
                group.send(WordStr.NotOwner)
    if readrule('mute') == 'on':
        return
    if msg.text[0]+'\n' in readmisc('cmd'):
        if (msg.text[1:4] == 'rpt'):#复读开关
            if msg.member == group.owner:
                x = cmd(msg.text[4:])
                try:
                    if x.lower() == 'off':
                        changerule('rpt','off')
                        group.send(WordStr.FunctionChange.format('随机复读',x))
                    elif x.lower() == 'on':
                        changerule('rpt','on')
                        group.send(WordStr.FunctionChange.format('随机复读',x))
                    else:
                        raise
                except:
                    group.send(WordStr.Err)
            else:
                group.send(WordStr.NotOwner)
        elif (msg.text[1:8] == 'welcome'):#复读开关
            if msg.member == group.owner:
                x = cmd(msg.text[8:])
                try:
                    if x.lower() == 'off':
                        changerule('welcome','off')
                        group.send(WordStr.FunctionChange.format('进/退群提示',x))
                    elif x.lower() == 'on':
                        changerule('welcome','on')
                        group.send(WordStr.FunctionChange.format('进/退群提示',x))
                    else:
                        raise
                except:
                    group.send(WordStr.Err)
            else:
                group.send(WordStr.NotOwner)
        elif (msg.text[1:5] == 'help'):#显示帮助
            if len(msg.text) == 5:
                x = readmisc('cmd')
                x1 = ''
                for i in range(0,len(x)):
                    j = '(空格)' if x[i][:-1] == ' ' else x[i][:-1]
                    x1 = x1 + j + ' '
                y = readmisc('sep')
                y1 = ''
                for i in range(0,len(y)):
                    j = '(空格)' if y[i][:-1] == ' ' else y[i][:-1]
                    y1 = y1 + j + ' '
                group.send(WordStr.help['default'].format(readrule('rpt'),x1,y1))
            else:
                try:
                    x = cmd(msg.text[5:])
                    group.send(WordStr.help[x])
                except:
                    group.send(WordStr.NoHelp)
        elif (msg.text[1:6] == 'rules'):#显示房规
            s = readmisc('rule')
            a = 'COC房规:'+WordStr.cocrule.split('######')[int(readrule('cocrule'))]+'其他规则:\n'
            for i in range(1,len(s)):
                a += s[i]
            group.send(WordStr.showrule.format(a))
        elif (msg.text[1:7] == 'setcoc'):#coc房规
            x = cmd(msg.text[7:])
            try:
                x = int(x)
                if x in range(0,6):
                    changerule('cocrule',str(x))
                    group.send(WordStr.setcoc.format(x,WordStr.cocrule.split('######\n')[x]))
                else:
                    raise IndexError
            except IndexError:
                group.send(WordStr.InvalidRule.format('COC'))
            except:
                group.send(WordStr.Err)
        elif (msg.text[1:4] == 'set'):
            try:
                x = cmd(msg.text[4:])
                x = str(int(x))
                changerule('defaultdice',x)
                group.send(WordStr.setdice.format(x))
            except:
                group.send(WordStr.NotInteger.format('默认骰子面数'))
        elif (msg.text[1:3] == 'st'):#记录数据
            try:
                a = cmd(msg.text[3:])
                if '|' in a:
                    group.send(WordStr.RegSuc)
                    a = a.split('|')
                    for i in range(0,len(a)):
                        nam,val = a[i].split(' ')
                        nam = syn(nam)
                        st(pu,nam,val)
                elif ' ' in a:
                    nam,val = a.split(' ')
                    if nam == 'show':
                        group.send(WordStr.CRDStatus.format(tn,val,getvl(pu,val)))
                    elif nam == 'del':
                        a = readpl(pu)
                        if val == 'all':
                            a = a[0:6]+['\n']
                            group.send(WordStr.DelReg.format(tn,'全部'))
                        else:
                            for i in range(0,len(a)):
                                if a[i] == val+'\n':
                                    a.pop(i)
                                    a.pop(i)
                                    group.send(WordStr.DelReg.format(tn,val))
                                    break
                                if i == len(a)-1:
                                    group.send(NoData.format(val))
                        writepl(pu,a)
                    else:
                        nam = syn(nam)
                        if nam == 'rp':
                            group.send(WordStr.RegDeny)
                        else:
                            val = calc(val)
                            st(pu,nam,val)
                            group.send(WordStr.CRDUpd.format(tn,nam,val))
                else:
                    nam = a
                    opr = ''
                    for i in range(0,len(a)):
                        if a[i] in ['+','-','*','/']:
                            opr = a[i:]
                            nam = a[:i]
                            break
                    nam = syn(nam)
                    if nam == 'rp':
                        group.send(WordStr.RegDeny)
                    else:
                        val = floor(eval(calc(str(getvl(pu,nam))+opr)))
                        if opr == '':
                            group.send(WordStr.CRDStatus.format(tn,nam,val))
                        else:
                            st(pu,nam,val)
                            group.send(WordStr.CRDUpd.format(tn,nam,val))
            except IndexError:
                group.send(WordStr.Err)
            except NameError:
                group.send(WordStr.NoData.format(nam))
        elif (msg.text[1:3] == 'en'):#成长检定
            x = cmd(msg.text[3:])
            try:
                x = x.split(' ')
                nam = syn(x[0])
                if nam == 'rp':
                    group.send(WordStr.RegDeny)
                else:
                    if len(x) == 1:
                        try:
                            val = int(getvl(pu,nam))
                        except:
                            val = int(nam)
                    if len(x) == 2:
                        try:
                            val = int(getvl(pu,nam))
                        except:
                            val = int(nam)
                    elif len(x) == 3:
                        val = int(x[1])
                        st(pu,nam,val)
                    else:
                        raise IndexError
                    r = randint(1,100)
                    if len(x) == 1:
                        suc,fail = '1d10','0'
                    elif '/' in x[-1]:
                        suc,fail = x[-1].split('/')
                    else:
                        suc,fail = x[-1],'0'
                    if r > val:
                        a = int(calc(suc))
                        a1 = suc
                        n = '成功'
                    else:
                        a = int(calc(fail))
                        a1 = fail
                        n = '失败'
                    st(pu,nam,val+a)
                    if a1 != str(a):
                        a1 = str(val) + '+' + a1 + '=' + str(val) + '+' + str(a) + '=' + str(val+a)
                    else:
                        a1 = str(val) + '+' + a1 + '=' + str(val+a)
                    group.send(WordStr.EN.format(tn,nam,r,val,n,a1))
            except NameError:
                group.send(WordStr.NoData.format(nam))
            except IndexError:
                group.send(WordStr.Err)
            except ValueError:
                group.send(WordStr.NotInteger.format(nam))
        elif (msg.text[1:7] == 'choose'):#选择
            x = cmd(msg.text[7:])
            try:
                n = 1
                a = []
                x = sep(x)
                if ' ' in x[-1]:
                    n = int(x[-1].split(' ')[1])
                    x[-1] = x[-1].split(' ')[0]
                if (n >= len(x)) | (n > 50):
                    raise ValueError
                while len(a) < n:
                    a.append(x.pop(randint(0,len(x)-1)))
                s = ''
                for i in range(0,len(a)):
                    s += a[i]
                    if i != len(a)-1:
                        s += '+'
                group.send(WordStr.choice.format(s))
            except ValueError:
                group.send(WordStr.nochoice)
        elif (msg.text[2] == 'i'):#疯狂症状
            r1 = randint(1,10)
            r2 = '1D10 = ' + str(randint(1,10))
            if msg.text[1] == 't':
                a = DiceConstant.ti[r1-1]
                s = '临时'
            elif msg.text[1] == 'l':
                a = DiceConstant.li[r1-1]
                s = '长期'
            if r1 == 9:
                r3 = randint(1,100)
                group.send(WordStr.insanity.format(tn,'临时',r1,a.format(r2,'1D100 = '+str(r3),DiceConstant.fear[r3-1])))
            elif r1 == 10:
                r3 = randint(1,100)
                group.send(WordStr.insanity.format(tn,'临时',r1,a.format(r2,'1D100 = '+str(r3),DiceConstant.panic[r3-1])))
            else:
                group.send(WordStr.insanity.format(tn,'临时',r1,a.format(r2)))
        elif (msg.text[1:5] == 'jrrp'):#显示今日人品
            if msg.text[1:] == 'jrrp':
                if readrule('jrrp') == 'on':
                    group.send(WordStr.Jrrp.format(tn,dt,getvl(pu,'rp')))
                else:
                    group.send(WordStr.JrrpUnavailable)
            else:
                x = cmd(msg.text[5:])
                if x.lower() == 'on' or x.lower() == 'off':
                    if msg.member == group.owner:
                        changerule('jrrp',x.lower())
                        group.send(WordStr.FunctionChange.format('jrrp',x.lower()))
                    else:
                        group.send(WordStr.NotOwner)
        elif (msg.text[1:5] == 'send'):#向骰子拥有者发送消息
            x = cmd(msg.text[5:])
            if x.lower() == 'on' or x.lower() == 'off':
                if msg.member == group.owner:
                    changerule('send',x.lower())
                    group.send(WordStr.FunctionChange.format('send',x.lower()))
                else:
                    group.send(WordStr.NotOwner)
            else:
                if readrule('send') == 'on':
                    group.send(WordStr.Send)
                    bot.file_helper.send(WordStr.Send_msg.format(getvl(pu,'wname'),WordStr.GroupName,x))
                else:
                    group.send(WordStr.SendUnavailable)
        elif (msg.text[1:3] == 'ob'):#旁观
            a = readmisc('ob')
            if pu + '\n' in a:
                a.pop(a.index(pu+'\n'))
                group.send(WordStr.unOB.format(tn))
            else:
                a.append(pu+'\n')
                group.send(WordStr.OB.format(tn))
            changemisc('ob',a)
        elif (msg.text[1:3] == 'nn'):#更改昵称
            if msg.text[3:] == '':
                st(pu,'name',msg.member.name)
                group.send(WordStr.NNForget.format(tn))
            elif msg.text[3] == 'n':
                if msg.text[3:] == 'n':
                    n = NameGenerator.getRandomName('')
                    st(pu,'name',n)
                    group.send(WordStr.NN.format(n))
                else:
                    try:
                        n = NameGenerator.getRandomName(msg.text[-2:].upper())
                        st(pu,'name',n)
                        group.send(WordStr.NN.format(n))
                    except:
                        group.send(WordStr.Err)
            else:
                x = cmd(msg.text[3:])
                if len(x) > 30:
                    group.send('@'+tn+' '+WordStr.RCG[randint(0,len(WordStr.RCG)-1)])
                else:
                    st(pu,'name',x)
                    group.send(WordStr.NN.format(x))
        elif (msg.text[1:3] == '复读'):#手动复读
            if len(msg.text) > 3:
                x = cmd(msg.text[3:])
                if len(x) > 100:
                    group.send('@'+tn+' '+WordStr.RCG[randint(0,len(WordStr.RCG)-1)])
                else:
                    group.send(WordStr.Repeat.format(msg.text[4:],tn))
            else:
                group.send(WordStr.EmptyRpt[randint(0,len(WordStr.EmptyRpt)-1)])
        elif (msg.text[1:9] == 'transfer'):#数据转移
            x = cmd(msg.text[9:])
            if x == '':
                x = 'all'
            if x == 'all':
                group.send(WordStr.Transfering.format('所有用户'))
                a = readmisc('pu')
                b = deepcopy(a)
                ob = readmisc('ob')
                c = []
                for i in range(0,len(a)-1):
                    puSource = a[i][:-1]
                    s = readpl(puSource)
                    ttn = getvl(puSource,'wname')
                    for j in range(i+1,len(a)):
                        puTarget = a[j][:-1]
                        if (getvl(puTarget,'wname') == ttn) & (puSource != puTarget):
                            writepl(puTarget,s)
                            b[i] = ''
                            if a[i] in ob:
                                if a[j] not in ob:
                                    ob[ob.index(a[i])] = a[j]
                                else:
                                    ob[ob.index(a[i])] = ''
                            c.append(getvl(puTarget,'wname'))
                            os.remove('groups/'+WordStr.GroupName+'/'+puSource)
                            break
                changemisc('pu',b)
                changemisc('ob',ob)
                s = ''
                if len(c) > 0:
                    for i in range(0,len(c)):
                        s += c[i] + '\n'
                group.send(WordStr.TransferResult.format(len(c),s))
            else:
                group.send(WordStr.Transfering.format(getvl(pu,'wname')))
                a = readmisc('pu')
                b = deepcopy(a)
                ob = readmisc('ob')
                for i in range(0,len(a)):
                    puSource = a[i][:-1]
                    s = readpl(puSource)
                    ttn = getvl(puSource,'wname')
                    if getvl(pu,'wname') == ttn:
                        if puSource == pu:
                            group.send(WordStr.TransferFailed.format(WordStr.NoUsr))
                            break
                        else:
                            writepl(puTarget,s)
                            b[i] = ''
                            if a[i] in ob:
                                if pu+'\n' not in ob:
                                    ob[ob.index(a[i])] = pu + '\n'
                                else:
                                    ob[ob.index(a[i])] = ''
                            os.remove('groups/'+WordStr.GroupName+'/'+puSource)
                            changemisc('pu',b)
                            changemisc('ob',ob)
                            group.send(WordStr.TransferResult.format(1,getvl(pu,'wname')))
                            break
                    if i == len(a)-1:
                        group.send(WordStr.TransferFailed.format(WordStr.NoUsr))
        elif (msg.text[1:3] == 'sc'):#san check
            x = cmd(msg.text[3:])
            x,y = sep(x)
            x,y = eval(calc(x)),eval(calc(y))
            try:
                r = randint(1,100)
                san = int(getvl(pu,'理智'))
                if r <= san:
                    st(pu,'理智',san-x)
                    group.send(WordStr.SC.format(tn,r,san,WordStr.SCsuc,x,san-x))
                if r > san:
                    st(pu,'理智',san-y)
                    group.send(WordStr.SC.format(tn,r,san,WordStr.SCfail,y,san-y))
            except:
                group.send(WordStr.NoData.format('理智'))
        elif (msg.text[1:4] == 'coc'):#人物卡生成
            try:
                x = 1
                s = WordStr.COC.format(tn)
                if len(msg.text) > 4:
                    x = int(cmd(msg.text[4:]))
                if x > 10:
                    raise IndexError
                for i in range(0,x):
                    ax = [((randint(1,6)+randint(1,6)+randint(1,6))*5) for i in range(0,6)]\
                         + [((randint(1,6)+randint(1,6)+6)*5) for i in range (0,3)] + [0,0]
                    ax[2],ax[5],ax[6],ax[8] = ax[6],ax[8],ax[2],ax[5]
                    for ii in range(0,9):
                        ax[9] += ax[ii]
                        if ii != 8:
                            ax[10] += ax[ii]
                    s += \
                    '力量STR:'+ str(ax[0]) + '\n'\
                    '体质CON:'+ str(ax[1]) + '\n'\
                    '体型SIZ:'+ str(ax[2]) + '\n'\
                    '敏捷DEX:'+ str(ax[3]) + '\n'\
                    '外貌APP:'+ str(ax[4]) + '\n'\
                    '智力INT:'+ str(ax[5]) + '\n'\
                    '意志POW:'+ str(ax[6]) + '\n'\
                    '教育EDU:'+ str(ax[7]) + '\n'\
                    '幸运LUK:'+ str(ax[8]) + '\n'\
                    '总和(不含幸运)SUM:'+ str(ax[9]) + '(' + str(ax[10]) + ')\n'\
                    '———————————\n'
                group.send(s)
            except ValueError:
                group.send(WordStr.NotInteger.format(''))
            except IndexError:
                group.send('@'+tn+' '+WordStr.RCG[randint(0,len(WordStr.RCG)-1)])
        elif (msg.text[1:4] == 'dnd'):#人物卡生成
            try:
                x = 1
                s = WordStr.DND.format(tn)
                if len(msg.text) > 4:
                    x = int(cmd(msg.text[4:]))
                if x > 10:
                    raise IndexError
                for i in range(0,x):
                    ax = [[randint(1,6),randint(1,6),randint(1,6),randint(1,6)] for i in range(0,6)] + [0]
                    for ii in range(0,6):
                        ax[ii].pop(ax[ii].index(min(ax[ii])))
                        ax[ii] = ax[ii][0]+ax[ii][1]+ax[ii][2]
                    ax[6] = ax[0]+ax[1]+ax[2]+ax[3]+ax[4]+ax[5]
                    s += \
                    '力量:'+ str(ax[0]) +\
                    '敏捷:'+ str(ax[1]) +\
                    '体质:'+ str(ax[2]) + '\n'\
                    '智力:'+ str(ax[3]) +\
                    '感知:'+ str(ax[4]) +\
                    '魅力:'+ str(ax[5]) + '\n'\
                    '总和:'+ str(ax[6]) + '\n'
                group.send(s)
            except ValueError:
                group.send(WordStr.NotInteger.format(''))
            except IndexError:
                group.send('@'+tn+' '+WordStr.RCG[randint(0,len(WordStr.RCG)-1)])
        elif (msg.text[1:4] == 'rhd'):#暗骰
            group.send(WordStr.RHDGroup)
            a = readmisc('ob')
            a = a if pu+'\n' in a else a+[pu+'\n']
            r = randint(1,100)
            flg = False
            for i in range(0,len(a)):
                try:
                    fr = bot.friends().search('',puid=a[i][:-1])[0]
                    fr.send(WordStr.RHD.format(WordStr.GroupName,tn,r))
                    fr.send(WordStr.RHDLine)
                except:
                    flg = True
            if flg == True:
                group.send(WordStr.NotFriend)
        elif (msg.text[1] == 'r'):#普通骰子
            x = cmd(msg.text[2:])
            try:
                if (x[0] == 'c') | (x[0] == 'a'):
                    x = syn(cmd(x[1:]))
                    try:
                        y = 0
                        if (x[0] == 'b') | (x[0] == 'p'):
                            i = 1
                            if x[1] not in '0123456789':
                                y = 1
                            else:
                                while x[i] in '0123456789':
                                    y = y * 10 + int(x[i])
                                    i += 1
                            while x[i] == ' ':
                                i += 1
                            d,s = rbp(y,x[0])
                            s += '='
                            x = x[i:]
                        else:
                            d,s = randint(1,100),''
                        if ' ' in x:
                            x,val = x.split(' ')
                            try:
                                for i in range(0,len(x)):
                                    if x[i] in '+-*/()%':
                                        for i in val:
                                            if i not in '1234567890+-*/()%d ':
                                                raise IndexError
                                        val = eval(val+x[i:])
                                        x = x[:i]
                                        break
                            except IndexError:
                                x,val = val,x
                                for i in range(0,len(x)):
                                    if x[i] in '+-*/()%':
                                        for i in val:
                                            if i not in '1234567890+-*/()%d ':
                                                raise IndexError
                                        val = eval(val+x[i:])
                                        x = x[:i]
                                        break
                            val = int(val)
                        else:
                            t = ''
                            for i in range(0,len(x)):
                                if x[i] in '+-*/()%':
                                    t = x[i:]
                                    x = x[:i]
                                    break
                            x = syn(x)
                            val = floor(eval(getvl(pu,x) + t))
                        t = jdg(d,val)
                        group.send(WordStr.RC.format(tn,x,s+str(d),val,t))
                    except NameError:
                        group.send(WordStr.NoData.format(x))
                        raise
                    except ValueError:
                        group.send(WordStr.NotInteger.format(x))
                        raise
                    except:
                        raise IndexError
                elif (x[0] == 'b') | (x[0] == 'p'):
                    if ' ' in msg.text[2:]:
                        z = x[x.index(' ')+1:]
                        x = x[:x.index(' ')]
                    else:
                        z = ''
                    for i in x[1:]:
                        if i not in '1234567890+-*/()%d ':
                            raise IndexError
                    if len(x) == 1:
                        y = 1
                        opr = ''
                    else:
                        if x[1] not in '0123456789':
                            y = 1
                            if x[1] not in '+-*/()%':
                                z = x[1:]
                            else:
                                i = 1
                        else:
                            i = 1
                            y = 0
                            while x[i] in '0123456789':
                                y = y * 10 + int(x[i])
                                i += 1
                        opr = x[i:]
                    d,s = rbp(y,x[0])
                    sum = floor(eval(str(d)+opr))
                    if (z == ''):
                        group.send(WordStr.RBP.format(tn,x[0].upper,s,opr,sum))
                    else:
                        group.send(WordStr.RBPn.format(z,tn,x[0].upper,s,opr,sum))
                else:
                    if ' ' in x:
                        x,z = x.split(' ')
                    else:
                        x,z = x,''
                    if x[0] == 'd':
                        s = readrule('defaultdice')
                        if x == 'd':
                            x = '1d' + s
                        elif x[1] in ['+','-','*','/','(',')']:
                            x = '1d' + s + x[1:]
                        else:
                            x = '1' + x
                    y = calc(x)
                    for i in y:
                        if i not in '1234567890+-*/()%d ':
                            raise IndexError
                    l = x if str(eval(y)) == y else x + '=' + y
                    if (z == ''):
                        group.send(WordStr.ROLL.format(tn,l,floor(eval(y))))
                    else:
                        group.send(WordStr.ROLLn.format(z,tn,l,floor(eval(y))))
            except TypeError:
                group.send(WordStr.TooManyFaces)
            except ValueError:
                group.send(WordStr.TooManyDices)
            except IndexError:
                group.send(WordStr.Err)
    elif (randint(1,15) == 1) & (len(msg.text) <= 50) & (readrule('rpt') == 'on'):#随机复读
        if randint(1,2) == 1:
            group.send(WordStr.Repeat.format(msg.text,tn))
        else:
            group.send(WordStr.DRM[randint(0,len(WordStr.DRM)-1)] + '#bot')
    sleep(0.2)
    if readrule('welcome') == 'on':#群聊人数变化提示
        if len(group.members) < int(readmisc('members')[0][:-1]):
            group.send(WordStr.MemberExit)
        elif len(group.members) > int(readmisc('members')[0][:-1]):
            group.send(WordStr.MemberWelcome)
    changemisc('members',[str(len(group.members))+'\n'])
def generateCITIZEN():
    NPCrace = generateRACE()
    NPCgender = generateGENDER()
    citizen = NameGenerator.generate(GENDERFlag, RACEflag)
    # Decide what is the profession of the citizen.
    dice = randint(1, 10)
    # dice = 3 #this one is just for debugging
    # ALCHEMIST
    if dice == 1:
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = "an Alchemist, more specifically an apothecary"
        elif dice == 2:
            NPCprofession = "an alchemist, more specifically a hedge wizard"
        elif dice == 3:
            NPCprofession = "an alchemist, more specifically an herbalist"
        elif dice == 4:
            NPCprofession = "an alchemist, more specifically a poisonmaker"
        elif dice == 5:
            NPCprofession = "an alchemist, more specifically a potioneer"
        elif dice == 6:
            NPCprofession = "an alchemist, more specifically a pyromancer"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for delivery help "
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for new recipes "
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for purchasers "
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for rare ingredients "
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + "and carries several vials of acids."
        elif dice == 2:
            NPCprofession = NPCprofession + "and carries several curatives."
        elif dice == 3:
            NPCprofession = NPCprofession + "and carries an unusual potion."
        elif dice == 4:
            NPCprofession = NPCprofession + "and carries a pyrophoric substance."
        else:
            NPCprofession = "error with the carries"

    # BANDIT
    elif dice == 2:
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = "a bandit, more specifically an assassin"
        elif dice == 2:
            NPCprofession = "a bandit, more specifically a confidence artist"
        elif dice == 3:
            NPCprofession = "a bandit, more specifically a gambler"
        elif dice == 4:
            NPCprofession = "a bandit, more specifically a poacher"
        elif dice == 5:
            NPCprofession = "a bandit, more specifically a smuggler"
        elif dice == 6:
            NPCprofession = "a bandit, more specifically a thief"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for accomplices for a specific task"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for revenge against a rival criminal"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for an easy mark"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for extra muscle for some work"
        elif dice == 5:
            NPCprofession = NPCprofession + " is looking for rumors that may lead to a big score"
        elif dice == 6:
            NPCprofession = NPCprofession + " is looking for a owdy evening of carousing"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries a crossbow with poisoned darts."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries several daggers."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries a short sword."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries a lucky charm."
        elif dice == 5:
            NPCprofession = NPCprofession + " and carries the token of a love."
        elif dice == 6:
            NPCprofession = NPCprofession + " and carries letters for blackmail."
        else:
            NPCprofession = "error with the carries"

    # LAW OFFICIAL
    elif dice == 3:
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = "a law official, more specifically a constable"
        elif dice == 2:
            NPCprofession = "a law official, more specifically a sheriff"
        elif dice == 3:
            NPCprofession = "a law official, more specifically a guard captain"
        elif dice == 4:
            NPCprofession = "a law official, more specifically a magistrate"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " is seeking someone to capture a fugitive"
        elif dice == 2:
            NPCprofession = NPCprofession + " is seeking someone to catch a thief"
        elif dice == 3:
            NPCprofession = NPCprofession + " is seeking someone to guard a specific location or person"
        elif dice == 4:
            NPCprofession = NPCprofession + " is seeking someone to investigate a disappearance"
        elif dice == 5:
            NPCprofession = NPCprofession + " is seeking someone to solve a murder mystery"
        elif dice == 6:
            NPCprofession = NPCprofession + " is seeking someone to have an ale with"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries an arrest warrant for an outlaw."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a proclamation for a reward."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries a knife or sword of the office."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries a pocketbook of local laws."
        else:
            NPCprofession = "error with the carries"

    # NOBLE
    elif dice == 4:
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = "a noble, more specifically a kinght"
        elif dice == 2:
            NPCprofession = "a noble, more specifically an old lord"
        elif dice == 3:
            NPCprofession = "a noble, more specifically a young lord"
        elif dice == 4:
            NPCprofession = "a noble, more specifically an old lady"
        elif dice == 5:
            NPCprofession = "a noble, more specifically a young lady"
        elif dice == 6:
            NPCprofession = "a noble, more specifically a wealthy merchant"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for someone to dispose of an enemy"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for someone to negotiate a trade contract"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for someone to prepare an army for war"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for someone to sabotage a rival"
        elif dice == 5:
            NPCprofession = NPCprofession + " is looking for someone to secure marriage"
        elif dice == 6:
            NPCprofession = NPCprofession + " is looking for someone to have a good time with"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries several deeds and titles."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a family heirloom."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries several inventories and invoices."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries a some very valuable jewels."
        elif dice == 5:
            NPCprofession = NPCprofession + " and carries a compromising love letter."
        elif dice == 6:
            NPCprofession = NPCprofession + " and carries a letter from a powerful lord or lady."
        else:
            NPCprofession = "error with the carries"

    # PRIEST
    elif dice == 5:
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = "a priest, more specifically an acolyte"
        elif dice == 2:
            NPCprofession = "a priest, more specifically a healer"
        elif dice == 3:
            NPCprofession = "a priest, more specifically a monk"
        elif dice == 4:
            NPCprofession = "a priest, more specifically a preacher"
        elif dice == 5:
            NPCprofession = "a priest, more specifically a scholar"
        elif dice == 6:
            NPCprofession = "a priest, more specifically a witch-hunter"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for new coverts"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for heretics"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for an relics and rare lore"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for the bottom of a goblet"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries a well-used cudgel."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a prominently displayed holy symbol."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries a pocketbook of sacred texts."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries a wineskin."
        else:
            NPCprofession = "error with the carries"

    # SEER
    elif dice == 6:
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = "a seer, more specifically an astrologer"
        elif dice == 2:
            NPCprofession = "a seer, more specifically a fortune teller"
        elif dice == 3:
            NPCprofession = "a seer, more specifically a mystic"
        elif dice == 4:
            NPCprofession = "a seer, more specifically a lorekeeper"
        elif dice == 5:
            NPCprofession = "a seer, more specifically a prophet"
        elif dice == 6:
            NPCprofession = "a seer, more specifically a psychic"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for new clients for reading"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for the answer to a riddle or prophecy"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for an relics and news regarding a missing person"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for some juicy gossip"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries a crystall ball."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a dowsing rod."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries a large, sharp-pointed knife."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries several star charts."
        else:
            NPCprofession = "error with the carries"

    # SMITH
    elif dice == 7:
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = "a smith, more specifically an armorer"
        elif dice == 2:
            NPCprofession = "a smith, more specifically a blacksmith"
        elif dice == 3:
            NPCprofession = "a smith, more specifically a farrier"
        elif dice == 4:
            NPCprofession = "a smith, more specifically a weaponsmith"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for a new apprentice"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for a journeyman craftsman"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for rare metals"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for a mug of strong ale"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries a hammer."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a metal trinket made by the smith."
        elif dice == 3:
            NPCprofession = (
                NPCprofession + " and carries a contract commisioning a weapon."
            )  # might insert the weapon randomizer... but maybe not because too much coding
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries little more than a few coins."
        else:
            NPCprofession = "error with the carries"

    # TRAVELER
    elif dice == 8:
        dice = randint(1, 8)
        if dice == 1:
            NPCprofession = "a traveler, more specifically an exile"
        elif dice == 2:
            NPCprofession = "a traveler, more specifically a ministrel"
        elif dice == 3:
            NPCprofession = "a traveler, more specifically a peddler"
        elif dice == 4:
            NPCprofession = "a traveler, more specifically a pilgrim"
        elif dice == 5:
            NPCprofession = "a traveler, more specifically a refugee"
        elif dice == 6:
            NPCprofession = "a traveler, more specifically a sellsword"
        elif dice == 7:
            NPCprofession = "a traveler, more specifically a storyteller"
        elif dice == 8:
            NPCprofession = "a traveler, more specifically a treasure hunter"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 10)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for accomplices on a quest."
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for the answer to a riddle."
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for an audience to entertain."
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for a long lost friend"
        elif dice == 5:
            NPCprofession = NPCprofession + " is looking for the return of something stolen."
        elif dice == 6:
            NPCprofession = NPCprofession + " is looking for revenge against a bitter rival."
        elif dice == 7:
            NPCprofession = NPCprofession + " is looking for a permanent home."
        elif dice == 8:
            NPCprofession = NPCprofession + " is looking for steady work."
        elif dice == 9:
            NPCprofession = NPCprofession + " is looking for traveling companions."
        elif dice == 10:
            NPCprofession = NPCprofession + " is looking for drinking companions."
        else:
            NPCprofession = "error with the lookings"

    # BARMAN
    elif dice == 9:
        if NPCgender == "Male":
            NPCprofession = "a Barman, and he"
        elif NPCgender == "Female":
            NPCprofession = " Barmaid, and she"
        else:
            NPCprofession = "error with gender at stage 1"
        dice = randint(1, 8)
        if dice == 1:
            NPCprofession = NPCprofession + " greets you with a mug of ale"
        elif dice == 2:
            NPCprofession = NPCprofession + " greets you with a goblet of wine"
        elif dice == 3:
            NPCprofession = NPCprofession + " greets you with a glass of water"
        elif dice == 4:
            NPCprofession = NPCprofession + " greets you with an offer to move to a better table"
        elif dice == 5:
            NPCprofession = NPCprofession + " greets you with a look of exasperation"
        elif dice == 6:
            NPCprofession = NPCprofession + " greets you with a warm handshake"
        elif dice == 7:
            NPCprofession = NPCprofession + " greets you with a pat on the back"
        elif dice == 8:
            NPCprofession = NPCprofession + " greets you with a pretty smile"
        else:
            NPCprofession = "error with the greetings"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 6)
        if dice == 1:
            NPCprofession = NPCprofession + " is looking for an excuse to kick you out"
        elif dice == 2:
            NPCprofession = NPCprofession + " is looking for somoeone more important to talk to"
        elif dice == 3:
            NPCprofession = NPCprofession + " is looking for someone to do some pest removal"
        elif dice == 4:
            NPCprofession = NPCprofession + " is looking for a big tip"
        elif dice == 5:
            NPCprofession = NPCprofession + " is looking for a good joke or story"
        elif dice == 6:
            NPCprofession = NPCprofession + " is looking for the bottom of a bottle"
        else:
            NPCprofession = "error with the lookings"
        dice = randint(1, 4)
        if dice == 1:
            NPCprofession = NPCprofession + " and carries a filthy rag."
        elif dice == 2:
            NPCprofession = NPCprofession + " and carries a pristine silk handkerchief."
        elif dice == 3:
            NPCprofession = NPCprofession + " and carries a piece of cospicuous jewelry."
        elif dice == 4:
            NPCprofession = NPCprofession + " and carries an unusual belt purse."
        else:
            NPCprofession = "error with the carries"

    # PAESANT
    elif dice == 10:
        dice = randint(1, 8)
        if dice == 1:
            NPCprofession = "an old farmer"
        elif dice == 2:
            NPCprofession = "a middle-aged farmer"
        elif dice == 3:
            NPCprofession = "a young farmer"
        elif dice == 4:
            NPCprofession = "a farm kid"
        elif dice == 5:
            if NPCgender == "Female":
                NPCprofession = "an old farmwife"
            elif NPCgender == "Male":
                NPCprofession = "an old farm-man"
        elif dice == 6:
            if NPCgender == "Female":
                NPCprofession = "a tough farmwife"
            elif NPCgender == "Male":
                NPCprofession = "a tough farm-man"
        elif dice == 7:
            if NPCgender == "Female":
                NPCprofession = "a young maid"
            elif NPCgender == "Male":
                NPCprofession = "a young maidman"
        elif dice == 8:
            if NPCgender == "Female":
                NPCprofession = "a country girl"
            elif NPCgender == "Male":
                NPCprofession = "a country boy"
        else:
            NPCprofession = "error in single prof"
        if NPCgender == "Male":
            NPCprofession = NPCprofession + ", and he"
        elif NPCgender == "Female":
            NPCprofession = NPCprofession + ", and she"
        else:
            NPCprofession = "error with the gender"
        dice = randint(1, 8)
        if dice == 1:
            NPCprofession = NPCprofession + " is seeking someone to lend a hand on a laborious task."
        elif dice == 2:
            NPCprofession = NPCprofession + " is seeking someone to repair a tool or farming implements."
        elif dice == 3:
            NPCprofession = NPCprofession + " is seeking someone to help locate a missing beast."
        elif dice == 4:
            NPCprofession = NPCprofession + " is seeking someone to help locate a missing person."
        elif dice == 5:
            NPCprofession = NPCprofession + " is seeking someone to hHelp secure an audience with the lord/lady."
        elif dice == 6:
            NPCprofession = NPCprofession + " is seeking someone to purchase or distribute crops."
        elif dice == 7:
            NPCprofession = NPCprofession + " is seeking someone to purchase some livestock."
        elif dice == 8:
            NPCprofession = NPCprofession + " is seeking someone to listen to a tale of woe."
        else:
            NPCprofession = "error with the lookings"
    else:
        NPCprofession = "Error with the profession"
    citizen = NameGenerator.generate(GENDERFlag, RACEflag)
    citizen = citizen + ", " + NPCrace + " (" + NPCgender + ") " + NPCprofession
    return citizen
예제 #12
0
def returner(msg):
    dt = strftime("%Y{0}%m{1}%d{2}", localtime()).format('年', '月', '日')  #当前时间
    pu = msg.member.puid
    if not os.path.exists('groups/' + WordStr.GroupName + '/' +
                          pu):  #第一次在群中出现的人的初始化
        init = 'wname\n' + msg.member.name + '\nname\n' + msg.member.name + '\nrp\n' + str(
            randint(1, 100)) + '\n'
        pers = open('groups/' + WordStr.GroupName + '/' + pu, mode='x')
        pers.write(init)
        pers.close()
        changemisc('pu', readmisc('pu') + [pu + '\n'])
    tn = getvl(pu, 'name')
    if msg.member.name != getvl(pu, 'wname'):
        st(pu, 'wname', msg.member.name)
    if (dt + '\n' != readmisc('dt')[0]):  #jrrp更新
        changemisc('dt', dt + '\n')
        for i in range(0, len(readmisc('pu'))):
            st(readmisc('pu')[i][:-1], 'rp', randint(1, 100))
    if (randint(1, 15) == 1) & (len(msg.text) <= 50) & (
            readrule('rpt') == 'on') & (readrule('mute') == 'off'):  #随机复读
        if randint(1, 2) == 1:
            group.send(WordStr.Repeat.format(msg.text, tn))
        else:
            group.send(WordStr.DRM[randint(0, len(WordStr.DRM) - 1)] + '#梦话')
    if msg.text[0] + '\n' in readmisc('cmd'):
        if (msg.text[1:4] == 'bot'):
            if msg.member == group.owner:
                if (msg.text[5:] == 'on'):
                    changerule('mute', 'off')
                    group.send(WordStr.Unmuted)
                elif (msg.text[5:] == 'off'):
                    changerule('mute', 'on')
                    group.send(WordStr.Muted)
            else:
                group.send(WordStr.NotOwner)
        if readrule('mute') == 'on':
            return
        if (msg.text[1:4] == 'rpt'):
            if msg.member == group.owner:
                try:
                    if msg.text[5:].lower() == 'off':
                        changerule('rpt', 'off')
                        group.send(
                            WordStr.FunctionChange.format(
                                '随机复读', msg.text[5:]))
                    elif msg.text[5:].lower() == 'on':
                        changerule('rpt', 'on')
                        group.send(
                            WordStr.FunctionChange.format(
                                '随机复读', msg.text[5:]))
                    else:
                        raise
                except:
                    group.send(WordStr.Err)
            else:
                group.send(WordStr.NotOwner)
        if (msg.text[1:5] == 'help'):  #显示帮助
            if len(msg.text) == 5:
                group.send(WordStr.hlp.format(readrule('rpt')))
            else:
                group.send(eval('WordStr.' + msg.text[6:] + 'hlp'))
        if (msg.text[1:5] == 'rules'):  #显示帮助
            s = readmisc('rule')
            a = 'COC房规:' + WordStr.cocrule.split('######')[int(
                readrule('cocrule'))] + '其他规则:\n'
            for i in range(1, len(s)):
                a += s[i]
            group.send(WordStr.showrule.format(a))
        elif (msg.text[1:3] == 'st'):
            try:
                a = msg.text[4:] if msg.text[3] == ' ' else msg.text[3:]
                if '|' in a:
                    group.send(WordStr.RegSuc)
                    a = a.split('|')
                    for i in range(0, len(a)):
                        nam, val = a[i].split(' ')
                        nam = syn(nam)
                        st(pu, nam, val)
                elif ' ' in a:
                    nam, val = a.split(' ')
                    if nam == 'show':
                        group.send(
                            WordStr.CRDStatus.format(tn, val, getvl(pu, val)))
                    elif nam == 'del':
                        a = readpl(pu)
                        if val == 'all':
                            a = a[0:6] + ['\n']
                            group.send(WordStr.DelReg.format(tn, '全部'))
                        else:
                            for i in range(0, len(a)):
                                if a[i] == val + '\n':
                                    a.pop(i)
                                    a.pop(i)
                                    break
                            group.send(WordStr.DelReg.format(tn, val))
                        writepl(pu, a)
                    else:
                        nam = syn(nam)
                        if nam == 'rp':
                            group.send(WordStr.RegDeny)
                        else:
                            val = calc(val)
                            st(pu, nam, val)
                            group.send(WordStr.CRDUpd.format(tn, nam, val))
                else:
                    nam = a
                    opr = ''
                    for i in range(0, len(a)):
                        if a[i] in ['+', '-', '*', '/']:
                            opr = a[i:]
                            nam = a[:i]
                            break
                    nam = syn(nam)
                    if nam == 'rp':
                        group.send(WordStr.RegDeny)
                    else:
                        val = floor(eval(calc(str(getvl(pu, nam)) + opr)))
                        if opr == '':
                            group.send(WordStr.CRDStatus.format(tn, nam, val))
                        else:
                            st(pu, nam, val)
                            group.send(WordStr.CRDUpd.format(tn, nam, val))
            except IndexError:
                group.send(WordStr.Err)
            #except NameError:
        elif (msg.text[1:3] == 'en'):
            x = msg.text[4:] if msg.text[3] == ' ' else msg.text[3:]
            try:
                x = x.split(' ')
                nam = syn(x[0])
                if nam == 'rp':
                    group.send(WordStr.RegDeny)
                else:
                    if len(x) == 2:
                        val = int(getvl(pu, nam))
                    elif len(x) == 3:
                        val = int(x[1])
                        st(pu, nam, val)
                    else:
                        raise IndexError
                    r = randint(1, 100)
                    if '/' in x[-1]:
                        suc, fail = x[-1].split('/')
                    else:
                        suc, fail = x[-1], '0'
                    if r <= val:
                        a = int(calc(suc))
                        a1 = suc
                        n = '成功'
                    else:
                        a = int(calc(fail))
                        a1 = fail
                        n = '失败'
                    st(pu, nam, val + a)
                    if a1 != str(a):
                        a1 = str(val) + '+' + a1 + '=' + str(val) + '+' + str(
                            a) + '=' + str(val + a)
                    else:
                        a1 = str(val) + '+' + a1 + '=' + str(val + a)
                    group.send(WordStr.EN.format(tn, nam, r, val, n, a1))
            except NameError:
                group.send(WordStr.NoData.format(nam))
            except IndexError:
                group.send(WordStr.Err)
            except ValueError:
                group.send(WordStr.NotInteger.format(nam))
        elif (msg.text[1:8] == 'choose '):
            if ' ' in msg.text[8:]:
                x = msg.text[8:].split(' ')
            else:
                x = msg.text[8:].split('/')
            if len(x) >= 2:
                group.send(WordStr.choice.format(x[randint(0, len(x) - 1)]))
        elif (msg.text[1:4] == 'art'):  #获取潜力信息
            x = 1
            s = WordStr.ART.format(tn) + '\n——————————\n'
            if ' ' in msg.text:
                num = findall(msg.text[0:4] + ' (\d+)', msg.text)
                x = int(num[0][0])
            for j in range(0, x):
                zy = 0  #卓越个数
                a = [[0] * 2 for i in range(6)]
                for i in range(6):
                    a[i][0] = randint(1, 5)
                    if a[i][0] == 5:
                        zy += 1
                for i in range(5):
                    if a[i][0] == 1:
                        a[i][1] = '缺陷 -1D10 = ' + str(-randint(1, 10))
                    elif a[i][0] == 2:
                        a[i][1] = '普通 -1D6 = ' + str(-randint(1, 6))
                    elif a[i][0] == 3:
                        a[i][1] = '标准 0'
                    elif a[i][0] == 4:
                        a[i][1] = '优良 1D10 = ' + str(randint(1, 10))
                    elif a[i][0] == 5:
                        a[i][1] = '卓越 2D10 = ' + str(
                            randint(1, 10) + randint(1, 10))
                if a[5][0] == 1:
                    a[5][1] = '缺陷'
                elif a[5][0] == 2:
                    a[5][1] = '普通'
                elif a[5][0] == 3:
                    a[5][1] = '标准'
                elif a[5][0] == 4:
                    a[5][1] = '优良'
                elif a[5][0] == 5:
                    a[5][1] = '卓越'
                s += '物理强度:'+ a[0][1] +'\n'\
                     '生理耐受:'+ a[1][1] +'\n'\
                     '战场机动:'+ a[2][1] +'\n'\
                     '战术规划:'+ a[3][1] +'\n'\
                     '战斗技巧:'+ a[4][1] +'\n'\
                     '源石技术适应性:'+ a[5][1] +'\n'\
                     '“卓越”个数:'+str(zy)+'\n'\
                     '———————————\n'
            group.send(s)
        elif (msg.text[1:4] == 'ark'):  #人物卡生成
            x = 1
            s = WordStr.ARK.format(tn)
            if ' ' in msg.text:
                num = findall(msg.text[0:4] + ' (\d+)', msg.text)
                x = int(num[0][0])
            for i in range(0, x):
                ax = [((randint(1,6)+randint(1,6)+randint(1,6))*5) for i in range(0,8)]\
                     + [((randint(1,6)+randint(1,6)+6)*5) for i in range (0,3)] + [0]
                for ii in range(0, 11):
                    ax[11] += ax[ii]
                s += \
                '攻击AGG:'+ str(ax[0]) + '\n'\
                '体质CON:'+ str(ax[1]) + '\n'\
                '敏捷DEX:'+ str(ax[2]) + '\n'\
                '外貌APP:'+ str(ax[3]) + '\n'\
                '意志POW:'+ str(ax[4]) + '\n'\
                '经验EXP:'+ str(ax[5]) + '\n'\
                '感染ORG:'+ str(ax[6]) + '\n'\
                '幸运LUK:'+ str(ax[7]) + '\n'\
                '智力INT:'+ str(ax[8]) + '\n'\
                '教育EDU:'+ str(ax[9]) + '\n'\
                '体型SIZ:'+ str(ax[10]) + '\n'\
                '总和SUM:'+ str(ax[11]) + '\n'
                if ax[11] >= 700:
                    s += '★总和大于700!★\n'
                s += '———————————\n'
            group.send(s)
        elif (msg.text[1:7] == 'setcoc'):
            if msg.member == group.owner:
                x = msg.text[8:] if msg.text[7] == ' ' else msg.text[7:]
                try:
                    x = int(x)
                    if x in range(0, 6):
                        changerule('cocrule', str(x))
                        group.send(
                            WordStr.setcoc.format(
                                x,
                                WordStr.cocrule.split('######\n')[x]))
                    else:
                        raise IndexError
                except IndexError:
                    group.send(WordStr.InvalidRule.format('COC'))
                except:
                    group.send(WordStr.Err)
            else:
                group.send(WordStr.NotOwner)
        elif (msg.text[2] == 'i'):
            r1 = randint(1, 10)
            r2 = '1D10 = ' + str(randint(1, 10))
            if msg.text[1] == 't':
                a = DiceConstant.ti[r1 - 1]
                s = '临时'
            elif msg.text[1] == 'l':
                a = DiceConstant.li[r1 - 1]
                s = '长期'
            if r1 == 9:
                r3 = randint(1, 100)
                group.send(
                    WordStr.insanity.format(
                        tn, '临时', r1,
                        a.format(r2, '1D100 = ' + str(r3),
                                 DiceConstant.fear[r3 - 1])))
            elif r1 == 10:
                r3 = randint(1, 100)
                group.send(
                    WordStr.insanity.format(
                        tn, '临时', r1,
                        a.format(r2, '1D100 = ' + str(r3),
                                 DiceConstant.panic[r3 - 1])))
            else:
                group.send(WordStr.insanity.format(tn, '临时', r1, a.format(r2)))
        elif (msg.text[1:5] == 'jrrp'):  #显示今日人品
            if msg.text[1:] == 'jrrp':
                if readrule('jrrp') == 'on':
                    group.send(WordStr.Jrrp.format(tn, dt, getvl(pu, 'rp')))
                else:
                    group.send(WordStr.JrrpUnavailable)
            else:
                if msg.text[6:].lower() == 'on' or msg.text[6:].lower(
                ) == 'off':
                    if msg.member == group.owner:
                        changerule('jrrp', msg.text[6:])
                        group.send(
                            WordStr.FunctionChange.format(
                                'jrrp', msg.text[6:]))
                    else:
                        group.send(WordStr.NotOwner)
        elif (msg.text[1:5] == 'send'):  #显示今日人品
            if msg.text[6:].lower() == 'on' or msg.text[6:].lower() == 'off':
                if msg.member == group.owner:
                    changerule('send', msg.text[6:])
                    group.send(
                        WordStr.FunctionChange.format('send', msg.text[6:]))
                else:
                    group.send(WordStr.NotOwner)
            else:
                if readrule('send') == 'on':
                    group.send(WordStr.Send)
                    bot.file_helper.send(
                        WordStr.Send_msg.format(getvl(pu, 'wname'),
                                                WordStr.GroupName,
                                                msg.text[6:]))
                else:
                    group.send(WordStr.SendUnavailable)
        elif (msg.text[1:3] == 'ob'):
            a = readmisc('ob')
            if pu + '\n' in a:
                a.pop(a.index(pu + '\n'))
                group.send(WordStr.unOB.format(tn))
            else:
                a.append(pu + '\n')
                group.send(WordStr.OB.format(tn))
            changemisc('ob', a)
        elif (msg.text[1:3] == 'nn'):  #更改昵称
            if msg.text[3:] == '':
                st(pu, 'name', msg.member.name)
                group.send(WordStr.NNForget.format(tn))
            elif msg.text[3] == 'n':
                if msg.text[3:] == 'n':
                    n = NameGenerator.getRandomName('')
                    st(pu, 'name', n)
                    group.send(WordStr.NN.format(n))
                else:
                    try:
                        n = NameGenerator.getRandomName(msg.text[-2:].upper())
                        st(pu, 'name', n)
                        group.send(WordStr.NN.format(n))
                    except:
                        group.send(WordStr.Err)
            else:
                if len(msg.text[4:]) > 30:
                    group.send('@' + tn + ' ' +
                               WordStr.RCG[randint(0,
                                                   len(WordStr.RCG) - 1)])
                else:
                    st(pu, 'name', msg.text[4:])
                    group.send(WordStr.NN.format(msg.text[4:]))
        elif (msg.text[1:3] == '复读'):  #手动复读
            if ' ' in msg.text:
                if len(msg.text[4:]) > 100:
                    group.send('@' + tn + ' ' +
                               WordStr.RCG[randint(0,
                                                   len(WordStr.RCG) - 1)])
                else:
                    group.send(WordStr.Repeat.format(msg.text[4:], tn))
            else:
                group.send(WordStr.EmptyRpt[randint(0, 1)])
        elif (msg.text[1:8] == 'transfer'):
            x = msg.text[8:] if msg.text[8] != ' ' else msg.text[9:]
            if x == 'all':
                group.send(WordStr.Transfering.format('所有用户'))
                a = readmisc('pl')
                b = a
                ob = readmisc('ob')
                c = []
                for i in range(0, len(a) - 1):
                    puSource = a[i][-1]
                    s = readpl(puSource)
                    ttn = getvl(puSource, 'wname')
                    for j in range(i + 1, len(a)):
                        puTarget = a[j][-1]
                        if (getvl(puTarget, 'wname')
                                == ttn) & (puSource != puTarget):
                            writepl(puTarget, s)
                            b.pop(i)
                            if a[i] in ob:
                                if a[j] not in ob:
                                    ob[ob.index(a[i])] = a[j]
                                else:
                                    ob.pop(ob.index(a[i]))
                            c.append(getvl(puTarget, 'wname'))
                            os.remove('groups/' + WordStr.GroupName + '/' +
                                      puSource)
                            break
                writemisc('pl', b)
                writemisc('ob', ob)
                s = ''
                for i in range(0, len(c)):
                    s += c[i] + '\n'
                group.send(WordStr.TransferResult.format(len(c), s))
            else:
                group.send(WordStr.Transfering.format(getvl(pu, 'wname')))
                a = readmisc('pl')
                ob = readmisc('ob')
                c = ''
                for i in range(0, len(a)):
                    puSource = a[i][-1]
                    s = readpl(puSource)
                    ttn = getvl(puSource, 'wname')
                    if getvl(pu, 'wname') == ttn:
                        if puSource == pu:
                            group.send(
                                WordStr.TransferFailed.format(WordStr.NoUsr))
                            break
                        else:
                            writepl(puTarget, s)
                            b.pop(i)
                            if a[i] in ob:
                                if pu + '\n' not in ob:
                                    ob[ob.index(a[i])] = pu + '\n'
                                else:
                                    ob.pop(ob.index(a[i]))
                            c.append(getvl(puTarget, 'wname'))
                            os.remove('groups/' + WordStr.GroupName + '/' +
                                      puSource)
                            group.send(
                                WordStr.TransferResult.format(
                                    1, getvl(pu, 'wname')))
                            break
                    if i == len(a) - 1:
                        group.send(WordStr.TransferFailed.format(
                            WordStr.NoUsr))
        elif (msg.text[1:3] == 'rc') | (msg.text[1:3] == 'ra'):  #检定
            x = msg.text[3:] if msg.text[3] != ' ' else msg.text[4:]
            try:
                d = randint(1, 100)
                if ' ' in x:
                    x, val = x.split(' ')
                    for i in range(0, len(x)):
                        if x[i] in ['+', '-', '*', '/', '(', ')']:
                            val = eval(val + x[i:])
                            x = x[:i]
                            break
                    val = int(val)
                else:
                    t = ''
                    for i in range(0, len(x)):
                        if x[i] in ['+', '-', '*', '/', '(', ')']:
                            t = x[i:]
                            x = x[:i]
                            break
                    x = syn(x)
                    val = floor(eval(getvl(pu, x) + t))
                t = ''
                rule = int(readrule('cocrule'))
                if rule == 0:
                    if d == 1:
                        t = WordStr.GSuc
                    elif val < 50:
                        if d in range(96, 101):
                            t = WordStr.LFail
                    elif val >= 50:
                        if d == 100:
                            t = WordStr.LFail
                elif rule == 1:
                    if val < 50:
                        if d == 1:
                            t = WordStr.GSuc
                        elif d in range(96, 101):
                            t = WordStr.LFail
                    elif val >= 50:
                        if d in range(1, 6):
                            t = WordStr.GSuc
                        if d == 100:
                            t = WordStr.LFail
                elif rule == 2:
                    if d in range(1, 6):
                        if d <= val:
                            t = WordStr.GSuc
                    elif d > 95:
                        if d > val:
                            t = WordStr.LFail
                elif rule == 3:
                    if d in range(1, 6):
                        t = WordStr.GSuc
                    elif d > 95:
                        t = WordStr.LFail
                elif rule == 4:
                    if d in range(1, 6):
                        if d <= val // 10:
                            t = WordStr.GSuc
                    elif val < 50:
                        if d >= 96 + val // 10:
                            t = WordStr.LFail
                    elif val >= 50:
                        if d == 100:
                            t = WordStr.LFail
                elif rule == 5:
                    if d in range(1, 3):
                        t = WordStr.GSuc
                    elif val < 50:
                        if d in range(96, 101):
                            t = WordStr.LFail
                    elif val >= 50:
                        if d in range(99, 101):
                            t = WordStr.LFail
                if (t == ''):
                    if d > val:
                        t = WordStr.Fail
                    elif d > val // 2:
                        t = WordStr.Suc
                    elif d > val // 5:
                        t = WordStr.HardSuc
                    else:
                        t = WordStr.ExtremeSuc
                group.send(WordStr.RC.format(tn, x, d, val, t))
            except NameError:
                group.send(WordStr.NoData.format(x))
            except ValueError:
                group.send(WordStr.NotInteger.format(x))
        elif (msg.text[1:3] == 'sc'):
            x = msg.text[3:] if msg.text[3] != ' ' else msg.text[4:]
            x, y = x.split('/')
            x, y = eval(calc(x)), eval(calc(y))
            try:
                r = randint(1, 100)
                san = int(getvl(pu, '理智'))
                if r <= san:
                    st(pu, '理智', san - x)
                    group.send(
                        WordStr.SC.format(tn, r, san, WordStr.SCsuc, x,
                                          san - x))
                if r > san:
                    st(pu, '理智', san - y)
                    group.send(
                        WordStr.SC.format(tn, r, san, WordStr.SCfail, y,
                                          san - y))
            except:
                group.send(WordStr.NoData.format('理智'))
        elif (msg.text[1:4] == 'coc'):  #人物卡生成
            x = 1
            s = WordStr.COC.format(tn)
            if ' ' in msg.text:
                num = findall(msg.text[0:4] + ' (\d+)', msg.text)
                x = int(num[0][0])
            for i in range(0, x):
                ax = [((randint(1,6)+randint(1,6)+randint(1,6))*5) for i in range(0,6)]\
                     + [((randint(1,6)+randint(1,6)+6)*5) for i in range (0,3)] + [0,0]
                ax[2], ax[5] = ax[6], ax[8]
                for ii in range(0, 9):
                    ax[9] += ax[ii]
                    if ii != 8:
                        ax[10] += ax[ii]
                s += \
                '力量STR:'+ str(ax[0]) + '\n'\
                '体质CON:'+ str(ax[1]) + '\n'\
                '体型SIZ:'+ str(ax[2]) + '\n'\
                '敏捷DEX:'+ str(ax[3]) + '\n'\
                '外貌APP:'+ str(ax[4]) + '\n'\
                '智力INT:'+ str(ax[5]) + '\n'\
                '意志POW:'+ str(ax[6]) + '\n'\
                '教育EDU:'+ str(ax[7]) + '\n'\
                '幸运LUK:'+ str(ax[8]) + '\n'\
                '总和(不含幸运)SUM:'+ str(ax[9]) + '(' + str(ax[10]) + ')\n'\
                '———————————\n'
            group.send(s)
        elif (msg.text[1:3] == 'rb') | (msg.text[1:3] == 'rp'):  #奖励骰/惩罚骰
            x1 = randint(1, 100)
            x2 = []
            y = ''
            t = 1
            if len(msg.text) > 3:
                if ' ' in msg.text:
                    t = msg.text[3:].split(' ')[0]
                    t = 1 if t == '' else int(t)
                    if t > 100:
                        group.send('@' + tn + ' ' +
                                   WordStr.RCG[randint(0,
                                                       len(WordStr.RCG) - 1)])
                        t = -1
                    y = msg.text[3:].split(' ')[1]
                else:
                    t = int(msg.text[3:])
            for i in range(0, t):
                x2.append(randint(0, 10))
            x3 = deepcopy(x2)
            x3.append(x1 // 10)
            if msg.text[2] == 'b':
                if x1 % 10 == 0:
                    while min(x3) == 0:
                        for i in range(0, len(x3)):
                            x3[i] = 10 if x3[i] == 0 else x3[i]
                x = min(x3) * 10 + x1 % 10
                k = '奖励'
            elif msg.text[2] == 'p':
                if x1 % 10 != 0:
                    while max(x3) == 10:
                        for i in range(0, len(x3)):
                            x3[i] = -1 if x3[i] == 10 else x3[i]
                elif min(x3) == 0:
                    x3.append(10)
                x = max(x3) * 10 + x1 % 10
                k = '惩罚'
            if y == '':
                group.send(
                    WordStr.RBP.format(tn, msg.text[2].upper(), x1, k, x2, x))
            else:
                group.send(
                    WordStr.RBPn.format(y, tn, msg.text[2].upper(), x1, k, x2,
                                        x))
        elif (msg.text[1:4] == 'rhd'):  #暗骰
            group.send(WordStr.RHDGroup)
            a = readmisc('ob')
            a = a if pu + '\n' in a else a + [pu + '\n']
            r = randint(1, 100)
            for i in range(0, len(a)):
                fr = bot.friends().search('', puid=a[i][:-1])[0]
                fr.send(WordStr.RHD.format(WordStr.GroupName, tn, r))
                fr.send(WordStr.RHDLine)
        elif (msg.text[1] == 'r'):  #普通骰子
            if ' ' in msg.text[2:]:
                x, z = msg.text[2:].split(' ')
            else:
                x, z = msg.text[2:], ''
            if x[0] == 'd':
                if x == 'd':
                    x = '1d100'
                elif x[1] in ['+', '-', '*', '/', '(', ')']:
                    x = '1d100' + x[1:]
                else:
                    x = '1' + x
            y = calc(x)
            l = x if str(eval(y)) == y else x + '=' + y
            if (z == ''):
                group.send(WordStr.ROLL.format(tn, l, floor(eval(y))))
            else:
                group.send(WordStr.ROLLn.format(z, tn, l, floor(eval(y))))