Coding Bootcamp: Project Two
Elizabeth Parnell
Software Developer | Specializing in React.js, JavaScript, PHP, SQL | Prevented $1.2M loss by fixing critical bug
Now that project 2 is done I can sit back and reflect on it. These projects are meant to test you so being stressed is a key point of this process. I am glad to say that this time around I was much more prepared for it. The second project for General Assembly is your choice. They require you to use certain technologies but it is your choice on what you do. The technologies we were required to use are Rails for the back-end and JavaScript for the front-end.
So the question was what was I going to make to make me stand out. I have always been a geek and love games of all kinds so I thought how about a simple Pokemon game. The requirements were a user needed to own a resource and be able to CRUD (create, read, update, and destroy) on it.
With that the light bulb went off. I could make a game where you could encounter a random Pokemon and catch it. So for a week before the start of this project I wanted to lay out how it was going to be coded and how things were going to connect.
I knew that I needed to have a table with all the Pokemon that you would be able to catch and you would need a table for the user. Knowing these two things meant that a joins table would have to be in the equation somewhere. The Pokemon table is a simple table that just has the first 150 Pokemon. You are not able to create, update, or destroy on this table because I wanted only the first generation of Pokemon to be in my game. The user table is a simple user table that contains your email and password.
For the joins table I wanted for a user to only have 6 Pokemon at a time. If a user wanted to catch another Pokemon they would have too 'release' a Pokemon first. To start the user would be given an empty 'bag' and you would have to click a button to encounter a Pokemon. After a successful encounter you are able to catch that Pokemon and by that I mean, you send a post request to the api with the Pokemon's id and the user's id to the bag table. So a user can have many Pokemon through bags and Pokemon can have many users through bags.
With all the planning that I had put into this project before hand I had an easy time with writing the back-end. Rails also has a lot of backed in features that makes it beginner friendly. I wrote some curl scripts and tested my api and was done with it by the middle of the first project day. Now for the front-end.
I know how to make ajax calls to an api but I have never written my own api then had to make calls to it. The first problem that I had ran into was I wasn't able to sign in/up. The error message was not helpful. All it had said was 'User already exists'. LIES! I knew the fake email that I was putting in was not one that I had used before. It was a lesson in patients this error. By breaking down the problem I knew that there was something in the model on the back-end that I had forgotten. It took me a good couple of hours to figure out that I needed to add a simple line 'Optional: true' to the users model.
The encounter system is a simple Math.floor(Math.random) that picks a number and sends that in a get request. This way you can encounter any Pokemon that you want. In later versions of this game I do want to make it where the rarer a Pokemon the harder it is to encounter. You are always able to catch a Pokemon that you encounter as long as you have room for it in you 'bag'. Again in later iterations I would like to make it to where it's more random on whether or not you are able to catch a Pokemon and depending on its rarity it's harder to catch.
Over all this project has been so much fun. I have taken away valuable planning skills and feel like I put everything into this project.
You can play it here: https://ejparnell.github.io/full-stack-front-end/
You can check out the front-end repo here: https://github.com/ejparnell/full-stack-front-end
You can check out the back-end repo here: https://github.com/ejparnell/back-end-full-stack
Front End Developer
5 年Just seeing this now. What a fantastic project that was,?Beth!