Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import random
- import pickle
- import asyncio
- from random import shuffle
- from discord.ext import commands
- bot = commands.Bot(command_prefix='$$', description='RPG bot')
- bot.remove_command('help')
- @bot.event
- async def on_ready():
- global plyChars
- global helper
- print('Logged in as')
- print(bot.user.name)
- plyChars = {}
- helper = False
- @bot.command(pass_context=True)
- async def INFO(ctx):
- global plyChars
- usrName = str(ctx.message.author)
- if plyChars[usrName] is None:
- await bot.say('Load a :person_with_blond_hair::skin-tone-5: with $$PLAY')
- return
- fileN = plyChars[usrName] + '.' + usrName
- charSh = pickle.load(open(fileN, "rb"))
- plClass = charSh['Class']
- plName = charSh['Name']
- plAtk = charSh['Atk']
- plDef = charSh['Def']
- plLuk = charSh['Luk']
- plHp = charSh['Hp']
- plExp = charSh['Exp']
- await bot.say('{} the {}\n{} :sparkling_heart:\n{} :crossed_swords:\n{} :shield:\n{} :moneybag:\n{} EXP'.format(plName, plClass, plHp, plAtk, plDef, plLuk, plExp))
- @bot.group(pass_context=True)
- async def help(ctx):
- if ctx.invoked_subcommand is None:
- await bot.say('use $$help <command> \n create \n PLAY \n FGT \n LVL')
- @help.command()
- async def create():
- helpC = open('help1.help', "r")
- helpB = helpC.readlines()
- for line in helpB:
- await bot.say(line)
- @help.command()
- async def PLAY():
- helpC = open('help3.help', "r")
- helpB = helpC.readlines()
- for line in helpB:
- await bot.say(line)
- @help.command()
- async def FGT():
- helpC = open('help2.help', "r")
- helpB = helpC.readlines()
- for line in helpB:
- await bot.say(line)
- @help.command()
- async def LVL():
- helpC = open('help4.help', "r")
- helpB = helpC.readlines()
- for line in helpB:
- await bot.say(line)
- @bot.command(pass_context=True)
- async def players(ctx):
- global plyChars
- plyCharsS = str(plyChars)
- await bot.say('{}'.format(plyCharsS))
- @bot.command(pass_context=True)
- async def hello(ctx, userName: discord.Member = None):
- if userName is None:
- userName = ctx.message.author
- await bot.say('Hello, {0}!'.format(userName))
- @bot.group(pass_context=True)
- async def create(ctx):
- global usrName
- if ctx.invoked_subcommand is None:
- await bot.say('I KNOW ITS STUPID TO HAVE TO TYPE PC BUT THATS HOW IT IS! Type $$help for more info')
- usrName = ctx.message.author
- @bot.group(pass_context=True)
- async def LVL(ctx):
- global plyChars
- global usrName
- global charSh
- usrName = str(ctx.message.author)
- if ctx.invoked_subcommand is None:
- await bot.say('Pick a stat! use $$help LVL')
- return
- fileN = plyChars[usrName] + '.' + usrName
- charSh = pickle.load(open(fileN, "rb"))
- @LVL.command()
- async def ATK():
- global usrName
- global plyChars
- global charSh
- fileN = plyChars[usrName] + '.' + usrName
- if charSh['Exp'] < (charSh['Lvl']*1000):
- await bot.say("you don't have enough EXP to level up, fight some shit")
- pickle.dump(charSh, open(fileN, "wb"))
- return
- else:
- charSh['Lvl'] = charSh['Lvl'] + 1
- charSh['Atk'] = charSh['Atk'] + 2
- charSh['Hp'] = charSh['Hp'] + 4
- await bot.say("{}'s :crossed_swords: increased by 2! {} total :crossed_swords: \n Level is now {}".format(charSh['Name'], charSh['Atk'], charSh['Lvl']))
- pickle.dump(charSh, open(fileN, "wb"))
- @LVL.command()
- async def DEF():
- global usrName
- global plyChars
- global charSh
- fileN = plyChars[usrName] + '.' + usrName
- if charSh['Exp'] < (charSh['Lvl']*1000):
- await bot.say("you don't have enough EXP to level up, fight some shit")
- pickle.dump(charSh, open(fileN, "wb"))
- return
- else:
- charSh['Lvl'] = charSh['Lvl'] + 1
- charSh['Def'] = charSh['Def'] + 2
- charSh['Hp'] = charSh['Hp'] + 4
- await bot.say("{}'s :shield: increased by 2! {} total :shield: \n Level is now {}".format(charSh['Name'], charSh['Def'], charSh['Lvl']))
- pickle.dump(charSh, open(fileN, "wb"))
- @LVL.command()
- async def LUK():
- global usrName
- global plyChars
- global charSh
- fileN = plyChars[usrName] + '.' + usrName
- if charSh['Exp'] < (charSh['Lvl']*1000):
- await bot.say("you don't have enough EXP to level up, fight some shit")
- pickle.dump(charSh, open(fileN, "wb"))
- return
- else:
- charSh['Lvl'] = charSh['Lvl'] + 1
- charSh['Luk'] = charSh['Luk'] + 2
- charSh['Hp'] = charSh['Hp'] + 4
- await bot.say("{}'s :moneybag: increased by 2! {} total :moneybag: \n Level is now {}".format(charSh['Name'], charSh['Luk'], charSh['Lvl']))
- pickle.dump(charSh, open(fileN, "wb"))
- @LVL.command()
- async def HP():
- global usrName
- global plyChars
- global charSh
- fileN = plyChars[usrName] + '.' + usrName
- if charSh['Exp'] < (charSh['Lvl']*1000):
- await bot.say("you don't have enough EXP to level up, fight some shit")
- pickle.dump(charSh, open(fileN, "wb"))
- return
- else:
- charSh['Lvl'] = charSh['Lvl'] + 1
- charSh['Hp'] = charSh['Hp'] + 10
- await bot.say("{}'s :sparkling_heart: increased by 10! {} total :sparkling_heart: \n Level is now {}".format(charSh['Name'], charSh['Hp'], charSh['Lvl']))
- pickle.dump(charSh, open(fileN, "wb"))
- @bot.command(pass_context=True)
- async def PLAY(ctx, charName):
- global usrName
- global usrCharN
- global pcChL
- global plyChars
- global npcE
- global charSh
- usrName = str(ctx.message.author)
- if charName is None:
- await bot.say('use $$PLAY <:person_with_blond_hair::skin-tone-5: name> or $$help')
- usrCharN = charName + '.' + usrName
- try:
- pcChL = pickle.load(open(usrCharN, "rb"))
- except FileNotFoundError:
- await bot.say('Not a valid :person_with_blond_hair::skin-tone-5: name')
- return
- await bot.say(':person_with_blond_hair::skin-tone-5: loading...')
- if pcChL['ID'] == usrName:
- await bot.say('ID verified, this is your :person_with_blond_hair::skin-tone-5: \n :person_with_blond_hair::skin-tone-5: loaded')
- else:
- await bot.say('This :person_with_blond_hair::skin-tone-5: was not made by you, make your own')
- return
- pickle.dump(pcChL, open(usrCharN, "wb"))
- plyChars[usrName] = charName
- @bot.command(pass_context=True)
- async def FGT(ctx):
- global usrName
- global plyChars
- global charSh
- usrName = str(ctx.message.author)
- try:
- if plyChars[usrName] is None:
- await bot.say('you have not loaded a :person_with_blond_hair::skin-tone-5:, use $$PLAY or $$help')
- return
- else:
- await bot.say('{} is going on an adventure'.format(plyChars[usrName]))
- fileN = plyChars[usrName] + '.' + usrName
- charSh = pickle.load(open(fileN, "rb"))
- if charSh['Hp'] <= 0:
- await bot.say('The :person_with_blond_hair::skin-tone-5: you have loaded is dead. Not sure they can fight well')
- pickle.dump(charSh, open(fileN, "wb"))
- return
- print(int(charSh['Lvl']/3))
- difMod = int(charSh['Lvl']/2)
- if difMod < 1:
- difMod = 1
- await encountr(difMod)
- fileE = plyChars[usrName] + '.enc'
- npcE = pickle.load(open(fileE, "rb"))
- await bot.say('You are facing a {} it looks {}'.format(npcE['Name'], npcE['DIF']))
- if npcE['DIF'] == 'STRONG':
- xpMod = 3
- if npcE['DIF'] == 'AVERAGE':
- xpMod = 2
- if npcE['DIF'] == 'WEAK':
- xpMod = 1
- print(npcE)
- plrAtk = int(charSh['Atk'] / 2)
- plrDef = int(charSh['Def'] / 2)
- encAtk = int(npcE['ATK'] / 3)
- encDef = int(npcE['DEF'] / 3)
- while npcE['HP'] > 0:
- await bot.say('{} has {} :sparkling_heart:'.format(npcE['Name'], npcE['HP']))
- await bot.say('{} has {} :sparkling_heart:'.format(charSh['Name'], charSh['Hp']))
- if charSh['Hp'] <= 0:
- await bot.say('{} has died fighting a {}'.format(charSh['Name'], npcE['Name']))
- pickle.dump(charSh, open(fileN, "wb"))
- return
- pAt = (dicer(2, 8) + plrAtk) - encDef
- npcE['HP'] = npcE['HP'] - pAt
- await bot.say('{} hit the {} for {} damage. It has {} :sparkling_heart: left'.format(charSh['Name'], npcE['Name'], pAt, npcE['HP']))
- if npcE['HP'] > 0:
- eAt = (dicer(2, 8) + encAtk + 2) - plrDef
- charSh['Hp'] = charSh['Hp'] - eAt
- await bot.say('The {} hit {} for {} damage. You have {} :sparkling_heart: remaining!'.format(npcE['Name'], charSh['Name'], eAt, charSh['Hp']))
- await bot.say('WINNER! gained {} EXP'.format(str(int(difMod*100*xpMod))))
- charSh['Exp'] = charSh['Exp'] + (int(difMod * 100 * xpMod))
- print(charSh['Exp'])
- if charSh['Exp'] >= 1000 * charSh['Lvl']:
- await bot.say('Level up available!! Type $$LVL <stat> to level up! $$help LVL for details')
- if charSh['Hp'] <= 0:
- await bot.say('{} has died fighting a {}'.format(charSh['Name'], npcE['Name']))
- pickle.dump(charSh, open(fileN, "wb"))
- pickle.dump(charSh, open(fileN, "wb"))
- pickle.dump(npcE, open(fileE, "wb"))
- except KeyError:
- await bot.say('you have not loaded a :person_with_blond_hair::skin-tone-5:, use $$PLAY or $$help')
- return
- @create.command()
- async def PC(pcClass: int, pcNamer: str):
- global cmdLock
- global pcChS
- global pcCSt
- global pcCi
- global pcName
- global usrName
- pcCi = pcClass
- pcName = pcNamer
- pcChS = {}
- cmdLock = False
- print(pcName)
- if pcClass == 1:
- pcCSt = '::fist::skin-tone-5:'
- print('good')
- print('creating a character named:', pcName, 'the', pcCSt)
- await bot.say('{} the {}'.format(pcName, pcCSt))
- cmdLock = True
- elif pcClass == 2:
- pcCSt = ':dagger:'
- print('good')
- print('creating a character named:', pcName, 'the', pcCSt)
- await bot.say('Creating :person_with_blond_hair::skin-tone-5: ... \n{} the {}'.format(pcName, pcCSt))
- cmdLock = True
- elif pcClass == 3:
- pcCSt = ':fire:'
- print('good')
- print('creating a character named:', pcName, 'the', pcCSt)
- await bot.say('{} the {}'.format(pcName, pcCSt))
- cmdLock = True
- else:
- await bot.say('do it better that didnt work')
- return
- print('character accepted generating stats')
- await bot.say('Rolling stats...')
- await statser()
- await bot.say(':sparkling_heart: = {}'.format(pcChS['Hp']))
- await bot.say(':crossed_swords: = {}'.format(pcChS['Atk']))
- await bot.say(':shield: = {}'.format(pcChS['Def']))
- await bot.say(':moneybag: = {}'.format(pcChS['Luk']))
- await bot.say('Rerolls are unavailable at this time!')
- await packer()
- @asyncio.coroutine
- async def encountr(lvlMod):
- global plyChars
- global usrName
- global npcDif
- npcSh = {}
- npcSh['HP'] = 5 + dicer(lvlMod, 8)
- npcSh['ATK'] = 10 + dicer(lvlMod, 8)
- npcSh['DEF'] = 6 + dicer(lvlMod, 8)
- mNamer = open('monsterlist.RPG', "r")
- mName = mNamer.readlines()
- maxM = 0
- for line in mName:
- maxM = maxM + 1
- print('number of monsters:', maxM)
- npcSh['Name'] = str(mName[(dicer(1,maxM)-1)]).replace('\n','')
- mNamer.close()
- npcDif = npcSh['HP']+npcSh['ATK']+npcSh['DEF']
- if npcDif >= 38:
- npcSh['DIF'] = 'STRONG'
- elif npcDif >= 28:
- npcSh['DIF'] = 'AVERAGE'
- else:
- npcSh['DIF'] = 'WEAK'
- fileN = plyChars[usrName] + '.enc'
- pickle.dump(npcSh, open(fileN, "wb"))
- @asyncio.coroutine
- async def statser():
- global pcChS
- global pcHp
- global pcAtk
- global pcDef
- global pcLuk
- global pcCi
- global pcCSt
- if pcCi == 1:
- clHp = 5
- clAtk = 2
- clDef = 5
- clLuk = 0
- if pcCi == 2:
- clHp = 3
- clAtk = 6
- clDef = 2
- clLuk = 1
- if pcCi == 3:
- clHp = 2
- clAtk = 2
- clDef = 2
- clLuk = 6
- print('hp+{} atk+{} def+{} luk+{}'.format(clHp,clAtk,clDef,clLuk))
- pcHp = 10 + int(dicer(2,4)+clHp)
- pcAtk = 10 + int(dicer(2,4)+clAtk)
- pcDef = 10 + int(dicer(2,4)+clDef)
- pcLuk = 10 + int(dicer(2,4)+clLuk)
- pcLvl = 1
- pcExp = 0
- pcChS['Hp'] = pcHp
- pcChS['Atk'] = pcAtk
- pcChS['Def'] = pcDef
- pcChS['Luk'] = pcLuk
- pcChS['Lvl'] = pcLvl
- pcChS['Exp'] = pcExp
- pcChS['Class'] = pcCSt
- print(pcChS)
- @asyncio.coroutine
- async def packer():
- global pcChS
- global pcName
- global usrName
- usrName = str(usrName)
- pcNamez = pcName + '.' + usrName
- pcChS['Name'] = pcName
- pcChS['ID'] = usrName
- print(pcChS)
- pickle.dump(pcChS, open(pcNamez, "wb"))
- def dicer(diNum,diTy):
- global roResult
- global roTal
- global rAc
- rAc = 0
- roResult = []
- while(diNum > 0):
- rAc = random.randint(1,diTy)
- print(rAc)
- roResult.append(rAc)
- print(roResult)
- diNum = diNum - 1
- roTal = sum(roResult)
- print(roTal)
- return roTal
- def itemz(difMod):
- global npcE
- global charSh
- bot.run('NDE0MzMzNDM1MzEwNzY4MTM4.DYeQdA.RF_uemJdVhR7eP4dlgTPnNhY5Tk')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement