So one of the first projects we created at DBC was called the Ruby Racer. It was a simple program that created a horse race powered by a random number generator. It had no user input and simply displayed text icons moving across the screen. It was simple and fun.
We later converted that into a Java Script racer. Using Sinatra we would prompt two players to enter names and then they would each press a key on the keyboard so as to move their “piece” along a track made of <tr> and <td> tags.
I enjoyed working with it so much that I added an Active Record backend and used the Stripe Api (test mode only, I want to obey the law) so that the players could bet against each other and keep score with their winnings. I even setup “the house”, which a player could play against and who would take 10% of every pot. I figured if I’m going to set this up I should set it up like a real business.
—
It was a good experience for me because I taught me how programing has a special relationship with money. Everything must be done in the lowest tangible unit. I wanted to work in $USD, but Stripe processes everything in cents. When I displayed things on my page I couldn’t use floats because they could lead to rounding errors. I’m still not clear on if I should use BigDecimal, which is better but still appears to give errors, or IEEE-754 which gives fewer errors, but I’m unclear has to how to apply it to my code.
I’m happy to say that I caught the rounding errors through personal dedication and testing, but I’m unsure as if the best way to solve it (for my programming skill level). Is it better to do the hard work and learn the right tool or just disallow any bet that isn’t a multiple of $1 and move on to learn topics that have more use cases.
—
I still have a lot todo to improve the site. https://github.com/ymeynot45/P10_stripe_test_case
- – It is ugly as sin. I’ve been playing around with the backend so much that I haven’t paid much attention to how it looks. I’ve learned many lessons from Jen Myers about how you can’t ignore the front end when you design the back end, so keeping that in mind I’ve tried to keep the backend flexible to facilitate the possible needs of the front end.
- – It isn’t OO. I know many places where I need to take the code out of the controller and put it in the models where it belongs and that will be the first step once I clean up the smaller bugs.
- – I need to add testing to the whole project. It was started before DBC introduced us to testing and I have yet to break out the Rspec and Jasmine to test the application.
- – I want to host it so that it may be played from multiple computers rather than two friends on the same computer. I need to make it dynamic so you can keep adding players to the race and pool a larger pot.
- – I would like to make it more than just a single button smashing game. I could make a circular track that requires you to use the WASD to move in the correct direction. OR have the computer display the correct key in the corner of the screen and if you press the wrong key it moves you backwards instead of forwards.
I’m torn between hoping that this page continues to develop as the project keeps moving forward & hoping that I never comment here again as I find bigger projects with social benefits to work on.