Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
__pycache__/
config.py
venv/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/cato.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/clove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district10female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district10male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district3female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district3male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district4female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district4male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district5male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district6female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district7female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district7male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district8female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district8male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district9female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/district9male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/foxface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/glimmer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/jason.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/katniss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pfp/hg/marvel.png
Binary file added assets/pfp/hg/peeta.png
Binary file added assets/pfp/hg/rue.png
Binary file added assets/pfp/hg/thresh.png
5 changes: 2 additions & 3 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(self, owner_name, owner_id, title: str):
self.owner_id = owner_id
self.title = title
self.has_started = False
self.is_autostepping = False

# Player data
self.players = {}
Expand All @@ -30,9 +31,7 @@ def __init__(self, owner_name, owner_id, title: str):

@property
def players_sorted(self):
l = list(self.players.values())
l.sort()
return l
return sorted(list(self.players.values()))

def add_player(self, new_player):
if new_player.name in self.players:
Expand Down
56 changes: 55 additions & 1 deletion hungrybot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import discord
import re
from discord.ext import commands
import pytimeparse
import datetime
import asyncio

from default_players import default_players
from hungergames import HungerGames
Expand Down Expand Up @@ -141,7 +144,7 @@ async def status(ctx):

@bot.command()
@commands.guild_only()
async def start(ctx):
async def start(ctx, auto=None):
"""
Starts the pending game in the channel.
"""
Expand Down Expand Up @@ -180,6 +183,57 @@ async def step(ctx):
await ctx.send(embed=embed)


@bot.command()
@commands.guild_only()
async def autostep(ctx, step_time):
# TODO: Fix this boilerplate spaghetti and fold it into the current error system
if step_time is None:
await ctx.reply("Time interval not specified.")
return
interval = pytimeparse.parse(step_time)
if interval is None:
await ctx.reply("Invalid time interval.")
return
if ctx.channel.id not in hg.active_games:
__check_errors(ctx, ErrorCode.NO_GAME)
if hg.active_games[ctx.channel.id].owner_id is not ctx.author.id:
__check_errors(ctx, ErrorCode.NOT_OWNER)
if not hg.active_games[ctx.channel.id].has_started:
__check_errors(ctx, ErrorCode.GAME_NOT_STARTED)
if hg.active_games[ctx.channel.id].is_autostepping:
await ctx.reply("This game is already autostepping.")
return
interval = max(min(interval, 86400), 5)
hg.active_games[ctx.channel.id].is_autostepping = True
await ctx.send("Starting auto-step at {0} per step...".format(datetime.timedelta(seconds=interval)))
while ctx.channel.id in hg.active_games and hg.active_games[ctx.channel.id].has_started:
ret = hg.step(ctx.channel.id, ctx.author.id)
if not await __check_errors(ctx, ret):
return
embed = discord.Embed(title=ret['title'], color=ret['color'], description=ret['description'])
if ret['footer'] is not None:
embed.set_footer(text=ret['footer'])
await ctx.send(embed=embed)
await asyncio.sleep(interval)


@bot.command
@commands.guild_only()
async def stopautostep(ctx):
# TODO: Fix this boilerplate spaghetti and fold it into the current error system
if ctx.channel.id not in hg.active_games:
__check_errors(ctx, ErrorCode.NO_GAME)
if hg.active_games[ctx.channel.id].owner_id is not ctx.author.id:
__check_errors(ctx, ErrorCode.NOT_OWNER)
if not hg.active_games[ctx.channel.id].has_started:
__check_errors(ctx, ErrorCode.GAME_NOT_STARTED)
if hg.active_games[ctx.channel.id].is_autostepping:
await ctx.reply("This game is not autostepping.")
return
hg.active_games[ctx.channel.id].is_autostepping = False
await ctx.send("Autostepping cancelled.")


async def __check_errors(ctx, error_code):
if type(error_code) is not ErrorCode:
return True
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py
git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py
pytimeparse==1.1.7