Beispiel #1
0
def roll_exec(irc, message):
    '''
        A !roll comand has the following structure:
            !roll diceAmount+d+diceSize+"+"+modifier

        * Dice amount is an integer up to 20000
        * Dice Size is an integer
        * Modifier is an integer that is added onto the roll after

        The !Roll command can also have this structure:
            !!roll d+diceAmount+d+diceSize+"+"+modifier

        * Dice amount is the result of a roll of said size and then proceeds
            to roll that many of the following dice
        * Dice Size is an integer
        * Modifier is an integer that is added onto the roll after
    '''

    diceNumbers = roller.getRolledNumbers(message.text)
    messageToSend = ''

    # -------------------------------------------------------------------
    #   Hard limits on the dice sizes
    # -------------------------------------------------------------------

    if diceNumbers[0] > 10:
        diceNumbers[0] = 10

    if diceNumbers[0] < 1:
        diceNumbers[0] = 1

    if diceNumbers[1] > 2000:
        diceNumbers[1] = 2000

    if diceNumbers[1] < 1:
        diceNumbers[1] = 1

    if diceNumbers[2] < 1:
        diceNumbers[2] = 1
    rolledArray = roller.roll(diceNumbers[0], diceNumbers[1], diceNumbers[2])

    for rollNum in rolledArray:
        # REMINDER: make a message maker function cause this is ugly!
        if (diceNumbers[3] == 0):
            messageToSend = (messageToSend + "\x0312,15(" +
                             str(diceNumbers[1]) + "d" + str(diceNumbers[2]) +
                             ") \x032,15[" + str(rollNum) +
                             "]\x031,15 : \x034,15{" +
                             str(rollNum + diceNumbers[3]) + "} ")
        else:
            messageToSend = (messageToSend + "\x0312,15(" +
                             str(diceNumbers[1]) + "d" + str(diceNumbers[2]) +
                             "+" + str(diceNumbers[3]) + ") \x032,15[" +
                             str(rollNum) + "+" + str(diceNumbers[3]) +
                             "]\x031,15 : \x034,15{" +
                             str(rollNum + diceNumbers[3]) + "} ")

    irc.send(message.reply(messageToSend))
Beispiel #2
0
async def roll(text : str):
  messageToSend = ""
  diceNumbers = roller.getRolledNumbers(text.upper(), False)
  results = roller.roll(diceNumbers[0], diceNumbers[1], diceNumbers[2])
  for res in results:
    res += diceNumbers[3]

  for rollNum in results:
    if(diceNumbers[3] == 0):
        messageToSend = (messageToSend + 
                        "("+str(diceNumbers[1])+
                        "d"+str(diceNumbers[2])+") ["+
                        str(rollNum)+"] : {"+
                        str(rollNum+diceNumbers[3])+"} \n")
    else:
        messageToSend = (messageToSend + "("+
                         str(diceNumbers[1])+"d"+
                         str(diceNumbers[2])+"+"+
                         str(diceNumbers[3])+") ["+
                         str(rollNum)+"+"+
                         str(diceNumbers[3])+
                         "] : {"+
                         str(rollNum+diceNumbers[3])+"} \n")
  await client.say(messageToSend)
Beispiel #3
0
            * Dice Size is an integer
            * Modifier is an integer that is added onto the roll after

            The !Roll command can also have this structure:
                !!roll d+diceAmount+d+diceSize+"+"+modifier

            * Dice amount is the result of a roll of said size and then proceeds
                to roll that many of the following dice
            * Dice Size is an integer
            * Modifier is an integer that is added onto the roll after            
        '''

        command = rawhandle.getCommand(text)
        if command[0] == "!":
            chann = rawhandle.getChannel(text, botnick)
            diceNumbers = roller.getRolledNumbers(command)
            messageToSend = ''

            #-------------------------------------------------------------------
            #   Hard limits on the dice sizes
            #-------------------------------------------------------------------

            if diceNumbers[0] > 10:
                diceNumbers[0] = 10
            
            if diceNumbers[1] > 2000:
                diceNumbers[1] = 2000

            rolledArray = roller.roll(diceNumbers[0],
                                      diceNumbers[1],
                                      diceNumbers[2])