Rails 5 App w/JQuery
This playable game app demonstrates what can be done with a powerful database backend like Rails with livening up via JQuery. While all the game's logic is inside Rail's MVC components, event bindings triggered on mouseclicks guide the user through an interactive experience, the selection of choice is moved and score seemlessly updates.
To accomplish the components of the game logic, three models were chosen user, ship, and passenger models & controllers are created. Next, the Active Record associations between the models - specifically CruiseShip has many Tourists, while Tourist belongs to CruiseShip.
Ship Model
The choice model (responsibe for the throw of rock, paper, or scissors) belongs to a game and a winner. The private method 'set_winner_id_and_result', positioned in the model, abides by fat model skinny controller best practices. Looking into how the algorithm works, it captures all possible combinations for a player_one win, loss, and draw.
Choice Model
Here Player 1 chose Rock while Player 2 chooses Paper
App Walkthrough