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
- from motor.motor_asyncio import AsyncIOMotorClient
- client = AsyncIOMotorClient(
- "mongodb+srv://DrakeNorr:<password>@rpgbot-atziq.mongodb.net/test?retryWrites=true&w=majority")
- 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_collection.get_player(ctx.author)
- if you.created:
- await ctx.send("you have already made a character")
- return
- await statsRoll(you, ctx)
- 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))
- await ctx.send(
- "Please select a race using the numbers beside the races\n1.Human\n+Strength +Agility +Toughness +willpower\n2.Elf\n++Agility ++intellect\n3.Dwarf \n++Toughness ++Strength\n4.Lizardman\n++Wisdom +willpower +luck")
- message = await bot.wait_for('message', timeout=60, check=predicate)
- tempAnswer = str(message.content)
- if tempAnswer == "1":
- you.race = "Human"
- you.strength += 5
- you.agility += 5
- you.toughness += 5
- you.willpower += 5
- elif tempAnswer == "2":
- you.race = "Elf"
- you.agility += 10
- you.intellect += 10
- elif tempAnswer == "3":
- you.race = "Dwarf"
- you.strength += 10
- you.toughness += 10
- elif tempAnswer == "4":
- you.race = "Lizardmen"
- you.wisdom += 10
- you.willpower += 5
- you.luck += 5
- await you.seeMe(ctx)
- while you.modifPoints > 0:
- await ctx.send("you have " + str(
- you.modifPoints) + " modifier points, one modifier point gives you a +3 to your chosen stat, 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 += 3
- elif tempAnswer == "2":
- you.extagility += 3
- elif tempAnswer == "3":
- you.exttoughness += 3
- elif tempAnswer == "4":
- you.extintellect += 3
- elif tempAnswer == "5":
- you.extwisdom += 3
- elif tempAnswer == "6":
- you.extwillpower += 3
- elif tempAnswer == "7":
- you.extluck += 3
- 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")
- you.created = True
- await you.seeMe(ctx)
- @dataclasses.dataclass()
- class Player:
- user: discord.User
- created = False
- race = ""
- rerolls = 4
- 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("User: " + str(self.user) + "\nRace: " + str(self.race) + "\nMoney: " + str(
- self.money) + "\nTreasures: " + str(self.treasures) + "\nLevel: " + str(self.level) + "\nExp :" + str(
- self.exp) + "/" +
- str(self.expNeeded) + "\n\nSTATS\n Base Bonus Total"
- "\nStrength: " + str(self.strength) + " (" + str(
- self.extstrength) + ") = " + str(self.strength + self.extstrength) +
- "\nAgility: " + str(self.agility) + " (" + str(self.extagility) + ") = " + str(
- self.agility + self.extagility) +
- "\nToughness: " + str(self.toughness) + " (" + str(self.exttoughness) + ") = " + str(
- self.toughness + self.exttoughness) +
- "\nIntellect: " + str(self.intellect) + " (" + str(self.extintellect) + ") = " + str(
- self.intellect + self.extintellect) +
- "\nWisdom: " + str(self.wisdom) + " (" + str(self.extwisdom) + ") = " + str(
- self.wisdom + self.extwisdom) +
- "\nWillpower: " + str(self.willpower) + " (" + str(self.extwillpower) + ") = " + str(
- self.willpower + self.extwillpower) +
- "\nLuck: " + str(self.luck) + " (" + str(self.extluck) + ") = " + str(
- self.luck + 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)
- async def statsRoll(you, ctx):
- def predicate(message):
- return (
- message.author == ctx.author
- and message.channel == ctx.channel
- and message.content.isdigit()
- )
- tempAnswer = "1"
- while tempAnswer != "2":
- if (you.rerolls > 0):
- you.rerolls -= 1
- 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:
- if x < smallest:
- smallest = 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("\nStrength: " + 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))
- await ctx.send(
- "Would you like to reroll these stats? you have " + str(
- you.rerolls) + " rerolls left\n1.Reroll\n2.Continue")
- message = await bot.wait_for('message', timeout=60, check=predicate)
- tempAnswer = str(message.content)
- if you.rerolls > 0 and tempAnswer == "1":
- await ctx.send("Rerolling...")
- elif tempAnswer == "1":
- await ctx.send("you cannot reroll anymore")
- elif tempAnswer == "2":
- await ctx.send("lets move on")
- else:
- await ctx.send("invalid entry, please try again")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement