-
-
Notifications
You must be signed in to change notification settings - Fork 16
Team 4 #5
base: master
Are you sure you want to change the base?
Team 4 #5
Conversation
Fix Pipfile dependencies
Exclude virtualenv from Flake8 linting. Again.
bot/cogs/snakes.py
Outdated
@@ -4,6 +4,8 @@ | |||
|
|||
from discord.ext.commands import AutoShardedBot, Context, command | |||
|
|||
from .snakegame import SnakeGame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relative imports are discouraged
bot/cogs/snakes.py
Outdated
|
||
|
||
def setup(bot): | ||
bot.add_cog(Snakes(bot)) | ||
bot.add_cog(Snakes(bot, SnakeGame((5, 5)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite weird - maybe you should instantiate it in the __init__
instead?
bot/cogs/snakes.py
Outdated
@@ -4,6 +4,8 @@ | |||
|
|||
from discord.ext.commands import AutoShardedBot, Context, command | |||
|
|||
from .snakegame import SnakeGame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also seem to be missing this file
First commit by Refisio to the PR. Wew lad. Alright. Let's go. - Set up the basis for pulling information from the MediaWiki API - Set up the basis for the list that will be checked for command caching - Took down some notes for continuing with the project in the morning. All of these are findable in the comments within the functions. - Pretty much have the 'get_snek' function done. Just have a few things I would like to flesh out. - Cleared the Wikipedia module from 'Pipfile' and 'Pipfile.lock'. Let's hope I didn't screw anything up with that one.
[UPDATE] Ignored a silly rule from flake8.
Adding W503 and E226 to flake8 ignore list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work so far!
# account for snakes without a page somewhere. >(PC) | ||
async with ClientSession() as session: | ||
async with session.get(url) as response: | ||
resp = json.loads(str(await response.read(), 'utf-8')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just return await response.json()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep getting a TypeError when trying that, so I decided to build it using "json.load()". I still works exactly as I would like it to, without all the TypeError stuff.
"usable_data = web_data['query']['pages'][0]['extract']
TypeError: 'generator' object is not subscriptable"
I also completely rewrote it, so while this is still there, it's not returning anything until it's actually done doing what it's supposed to do. You'll see it in the next commit in a little while, or below if you're invested enough.
if name.split(' '): | ||
name = '%20'.join(name.split(' ')) | ||
|
||
# leaving off here for the evening. Building the embed is easy. Pulling the information is hard. /s >(PC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, build the embed. :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You code is failing to lint. Please see Travis for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, and some great ideas! Might want to look into becoming more pythonic (read pep8!). However clearly you guys know how to use python, evident from your code. Check out how to use the @property
decorator. Other then that, great project! See you next code jam!
|
||
async with ClientSession() as session: | ||
async with session.get(possible_names) as all_sneks: | ||
resp = str(await all_sneks.read(), 'utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for specifying the encoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem with encoding when trying to change the read response to a string. Specification solved that.
|
||
# accounting for the spaces in the names of some snakes. Allows for parsing of spaced names. >(PC) | ||
if name.split(' '): | ||
name = '%20'.join(name.split(' ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the urllib module for this operation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you specify which function of URLLib I should be using for this?
|
||
# Maybe one game at a given time, and maybe editing the original message instead of constantly posting | ||
# new ones? Maybe we could also ask nicely for DMs to be allowed for this if they aren't. >(PC) | ||
if order in self.movement_command.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be wrong, but it would appear that only 1 person can play at once, you should save the message author ID to a dict with their last time? I havn't played this game, so I may be misinterpreting it.
snekembed.add_field(name="Winner movement", | ||
value="{dir}: {per:.2f}%".format(dir=direction, per=percentage)) | ||
|
||
snek_head = next(emoji for emoji in ctx.guild.emojis if emoji.name == 'python') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clever usage of next, I like that. However this creates issues if the name is changed. Might want to make this optional.
""" | ||
|
||
self.snake = Snake(positions=[[2, 2], [2, 1]]) | ||
self.putFood() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies to all functions and variables, use
self.put_food()
Instead!
|
||
return move_status | ||
|
||
def isLost(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use python property decorator! So it would look like
@property
def lost(self):
Applies to other is
functions too!
self.head[1] + velocity[1]] | ||
self.positions.insert(0, self.head) | ||
|
||
return "ok" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be much nicer, if it returned a bool, or enum instead, this leads to less mistakes when developing.
This will be updated as production starts and continues.