r/madeinpython • • May 12 '20

Clash of Clans API framework

I still have a lot to work on, but I made a framework for the Clash of Clans API. I run a discord bot that I also designed for our clan and realized I was doing way too much work keeping up with the mess of code. I made the framework using OOP principles and trying to focus on using clean code (as much as I could lol). Again I still have a lot to work on and it may not be much, but I designed it from scratch and I love it! I would love lots of feedback if possible.

Link to github page for Clash-Frame

22 Upvotes

12 comments sorted by

View all comments

2

u/nandahkrishna May 12 '20

Looks nice for a WIP! You seem to have adhered to PEP8 at first glance, neat code is always a plus :)

2

u/YoelkiToelki May 12 '20

Except for the 80 characters per line limit ... who cares though that guideline is ridiculous anyway!

1

u/westo48 May 12 '20

If I’m being honest I haven’t gone through the ACTUAL guidelines. I just focused on the OOP portion of it. A lot of the code uses a ton of characters because of the api access (json iteration and what not), so it gets a little hairy in the get methods. I’m hoping to update it as time goes on, and make sure that I use good version control, start using PEP8 guidelines, and try not to clutter everything lol. It’s my first larger project, so I’ve been excited/obsessed. Whichever you want to call it haha

3

u/YoelkiToelki May 12 '20

You could cut down on some space using the unpacking operator * on the jsons, for example, when u make a new clan instance. Just make sure the json values and clan parameters are in order

1

u/westo48 May 12 '20

I haven’t seen that, I’ll have to look into it!! My only concern (without reading anything about it mind you) is if the API return values vary at all then it could prove challenging. Sometimes values are there and sometimes they just don’t exist (if the player doesn’t have the troop, bldg, etc then it just won’t be included in the json response, which IMO it should return 0 or something like that for uniformity, but I’m inexperienced, so idk)