This content originally appeared on DEV Community and was authored by Kyle Homen
This week, I found a project called 100LinesOfPythonCode. While browsing issues, I found one that was asking someone to write a mini RPG game in python. I like that kind of stuff, so I took a look. It was already assigned to someone, but when I looked more into the project, I found that they welcomed multiple solutions and that we didn’t have to ask for permission to make a contribution, so I decided to do it.
The Issue
I know that this isn’t a traditional project where I’m solving a bug or an issue, but I was having a hard time finding anything gaming related, and this still felt like contributing something fun that someone could build off of in the future.
The constraint for this project is that every file needs to be under 100 lines of code. That made it into a fun little challenge, and I had to keep things simple yet try to do the most I could with it (only later did I read that we could use modularization to have multiple 100-line files..).
I had to utilize loops where I could to save on line real estate, so the entire game loop involves progressing through an Arena which gets incrementally harder based on the level number.
Stats are randomized, and each successful win gives the player a level up which gives a 50/50 chance of increasing each stat.
For 100 lines of code, there is a lot of randomness and replay ability due to the randomized enemy stats and the randomized growth of the player character, as well as the randomness of the battle system with the ability to miss attacks.
And of course, the goal is to make it as far in the Arena as possible, and when you lose it will display how far you made it in the Arena.
To wrap things up, last week I was able to make a request to contribute, have some correspondence with the maintainer, but ultimately all I did was change a line or two of code. This week, while I did not speak to a maintainer or have to learn anything more than surface level about the project, I was able to create something and have it merged for others to see and contribute themselves to. Next week I want to combine a bit of both.
This content originally appeared on DEV Community and was authored by Kyle Homen