Personal Projects

Summer Game Jam 1 - Slime Crime

Enemies from my first summer Game Jam, Tower of Diseased Digestion

Test Area Selection/Hub Screen

Summer Python Discord Bot, creating a text based adventure RPG with a modular class system and player profile system

Early code from my testing and development discord for the bot

import discord

import json

import os

import random

from discord.ext import commands


TOKEN = 'TokenName'

client = commands.Bot(command_prefix='.')

prefix = '.'

os.chdir('Path')


@client.event

async def on_ready():

print('Bot is ready.')


@client.event

async def on_message_delete(message):

author = message.author

content = message.content

channel = message.channel

await channel.send('Deleted: ' + content)


@client.event

async def on_member_join(member):

with open('users.json', 'r') as f:

users = json.load(f)


await update_data(users, member)


with open('users.json', 'w') as f:

json.dump(users, f)


@client.event

async def on_message(message):

author = message.author

content = message.content

channel = message.channel

print('{}: {}'.format(author, content))

with open('users.json', 'r') as f:

temp_users = json.load(f)

users = {}

for key, value in temp_users.items():

users[ int( key ) ] = value

exp = 5

await update_data(users, message.author)

await add_experience(users, message.author, exp)

await stats(users, message, message.author, message.channel)

await hunt(users, message, message.author, message.channel)

await study(users, message, message.author, message.channel)

await run(users, message, message.author, message.channel)

await fight(users, message, message.author, message.channel)

await level_up(users, message.author, message.channel)

with open('users.json', 'w') as f:

json.dump(users, f)


async def update_data(users, user):

if user.id in users.keys():

pass

else:

users[user.id] = {}

users[user.id]['experience'] = 0

users[user.id]['level'] = 1

users[user.id]['health'] = 1

users[user.id]['strength'] = 1

users[user.id]['defense'] = 1

users[user.id]['wisdom'] = 1

users[user.id]['speed'] = 1

users[user.id]['luck'] = 1


async def add_experience(users, user, exp):

users[user.id]['experience'] += exp


async def level_up(users, user, channel):

experience = users[user.id]['experience']

lvl_start = users[user.id]['level']

lvl_end = int(experience ** (1 / 4))

if lvl_start < lvl_end:

await channel.send('{} has level up to level {}'.format(user.mention, lvl_end))

users[user.id]['level'] = lvl_end


async def stats(users, message, user, channel):

health = users[user.id]['health']

strength = users[user.id]['strength']

defense = users[user.id]['defense']

wisdom = users[user.id]['wisdom']

speed = users[user.id]['speed']

luck = users[user.id]['luck']

if message.content.startswith(prefix + 'stats'):

await channel.send('Your Stats: ')

await channel.send('Health: {}, Strength: {}, Defense: {}, Wisdom: {}, Speed: {}, Luck: {}'.format(health, strength, defense, wisdom, speed, luck))


async def hunt(users, message, user, channel):

if message.content.startswith(prefix + 'hunt'):

users[user.id]['strength'] += 1

users[user.id]['defense'] += 1

users[user.id]['experience'] += 5

strength = users[user.id]['strength']

await channel.send('Strength: {}'.format(strength))

async def study(users, message, user, channel):

if message.content.startswith(prefix + 'study'):

users[user.id]['wisdom'] += 1

users[user.id]['luck'] += 1

users[user.id]['experience'] += 5

wisdom = users[user.id]['wisdom']

await channel.send('Wisdom: {}'.format(wisdom))


async def run(users, message, user, channel):

if message.content.startswith(prefix + 'run'):

users[user.id]['health'] += 1

users[user.id]['speed'] += 1

users[user.id]['experience'] += 5

speed = users[user.id]['speed']

await channel.send('Speed: {}'.format(speed))


async def fight(users, message, user, channel):

if message.content.startswith(prefix + 'fight'):

await channel.send('Enemy Fight Commands:')

await channel.send('1 .fight Human (weakest)')

await channel.send('2 .fight Monster')

await channel.send('3 .fight Beast')

await channel.send('4 .fight Demon')

await channel.send('5 .fight God (strongest)')


client.run(TOKEN)