Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !/usr/bin/env python
- # -*- coding: utf-8 -*-
- from discord.ext import commands
- import logging
- import random
- import discord
- import dataclasses
- import typing
- bot = commands.Bot(command_prefix='rpg.')
- logging.basicConfig(level='INFO')
- @bot.command()
- async def ping(ctx):
- await ctx.send('pong')
- @bot.command()
- async def start(ctx):
- def predicate(message):
- return (
- message.author == ctx.author
- and message.channel == ctx.channel
- and message.content.isdigit()
- )
- you=Player(ctx.author)
- allTotalNumbers = []
- allBaseNumbers = []
- for x in range(7):
- tempNum1 = random.randint(1, 6)
- tempNum2 = random.randint(1, 6)
- tempNum3 = random.randint(1, 6)
- tempNum4 = random.randint(1, 6)
- tempNum5 = random.randint(1, 6)
- allBaseNumbers.clear()
- allBaseNumbers.append(tempNum1)
- allBaseNumbers.append(tempNum2)
- allBaseNumbers.append(tempNum3)
- allBaseNumbers.append(tempNum4)
- allBaseNumbers.append(tempNum5)
- smallest=9
- for x in allBaseNumbers:
- await ctx.send(x)
- if allBaseNumbers[x]<smallest:
- smallest=allBaseNumbers[x]
- totalNum = tempNum1 + tempNum2 + tempNum3 + tempNum4 + tempNum5-smallest
- allTotalNumbers.append(totalNum)
- await ctx.send(str(tempNum1) + " + " + str(tempNum2) + " + " + str(tempNum3) + " + " + str(tempNum4) + " + " + str(tempNum5) + " - smallest value " + str(smallest) + ", Total = " + str(totalNum))
- you.strength=allTotalNumbers[0]
- you.agility=allTotalNumbers[1]
- you.toughness = allTotalNumbers[2]
- you.intellect = allTotalNumbers[3]
- you.wisdom = allTotalNumbers[4]
- you.willpower = allTotalNumbers[5]
- you.luck= allTotalNumbers[6]
- await ctx.send("Strength : " + str(you.strength) + "\nAgility : " + str(you.agility) + "\nToughness : " + str(you.toughness) + "\nIntellect : " +
- str(you.intellect)+ "\nWisdom : " + str(you.wisdom)+ "\nWillpower : " + str(you.willpower)+ "\nLuck : " + str(you.luck))
- while you.modifPoints > 0:
- await ctx.send("you have " + str(you.modifPoints) + " modifier points, select what you want to use them on using the numbers\n1.Strength\n2.Agility\n3.Toughness\n4.Intellect\n5.Wisdom\n6.Willpower\n7.Luck\n")
- message=await bot.wait_for('message', timeout=30,check=predicate)
- tempAnswer=str(message.content)
- ctx.send(tempAnswer)
- if tempAnswer == "1":
- you.extstrength += 1
- elif tempAnswer == "2":
- you.extagility += 1
- elif tempAnswer == "3":
- you.exttoughness += 1
- elif tempAnswer == "4":
- you.extintellect += 1
- elif tempAnswer == "5":
- you.extwisdom += 1
- elif tempAnswer == "6":
- you.extwillpower += 1
- elif tempAnswer == "7":
- you.extluck += 1
- else:
- await ctx.send("that was an incorrect answer, please select the stat you want by using the numbers 1 to 7")
- you.modifPoints += 1
- you.modifPoints -= 1
- await ctx.send("that is all your modifiers used up, character creation has finished")
- await you.seeMe(ctx)
- @dataclasses.dataclass()
- class Player:
- user: discord.User
- money= 0
- treasures= 0
- level= 1
- exp= 0
- expNeeded= 5
- modifPoints= 5
- strength = 0
- agility = 0
- toughness = 0
- intellect = 0
- wisdom = 0
- willpower = 0
- luck = 0
- move1 = 0
- move2 = 0
- move3 = 0
- move4 = 0
- weapon = 0
- armour = 0
- medalion = 0
- ring = 0
- head = 0
- extstrength = 0
- extagility = 0
- exttoughness = 0
- extintellect = 0
- extwisdom = 0
- extwillpower = 0
- extluck = 0
- async def seeMe(self,ctx):
- await ctx.send("Money: " + str(self.money) + "\nTreasures: " + str(self.treasures) + "\nLevel: " + str(self.level) + "\nExp :" + str(self.exp) + "/" +
- str(self.expNeeded) + "\n\nSTATS\n Base Bonus"
- "\nStrength: " + str(self.strength) + " ("+ str(self.extstrength) + ")"
- "\nAgility: " + str(self.agility) + " ("+ str(self.extagility) + ")"
- "\nToughness: " + str(self.toughness) + " (" + str(self.exttoughness) + ")"
- "\nIntellect: " + str(self.intellect) + " (" + str(self.extintellect) + ")"
- "\nWisdom: " + str(self.wisdom) + " (" + str(self.extwisdom) + ")"
- "\nWillpower: " + str(self.willpower) + " (" + str(self.extwillpower) + ")"
- "\nLuck: " + str(self.luck) + " (" + str(self.extluck) + ")"
- )
- class PlayerCollection(typing.Dict[discord.User, Player]):
- def get_player(self, user: discord.User) -> Player:
- if user not in self:
- self[user] = Player(user)
- return self[user]
- @bot.command()
- async def seeme(ctx):
- you = player_collection.get_player(ctx.author)
- print(you.user)
- await you.seeMe(ctx)
- player_collection = PlayerCollection()
- class Monster:
- def __init__(self):
- self.area=0
- self.rarity=0
- self.moneyGive = 0
- self.treasuresGive = 0
- self.level = 1
- self.expGive = 0
- self.strength = 0
- self.agility = 0
- self.toughness = 0
- self.intellect = 0
- self.wisdom = 0
- self.willpower = 0
- self.luck = 0
- self.move1 = 0
- self.move2 = 0
- self.move3 = 0
- self.move4 = 0
- self.weapon = 0
- self.armour = 0
- self.medalion = 0
- self.ring = 0
- self.head = 0
- class Item:
- def __init__(self):
- self.rarity=0
- self.strength = 0
- self.agility = 0
- self.toughness = 0
- self.intellect = 0
- self.wisdom = 0
- self.willpower = 0
- self.luck = 0
- self.place=0
- # event
- @bot.listen()
- async def on_guild_join(guild):
- print('I just joined', guild)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement