Skip to content

JoeSpizz/phase-3-sinatra-react-project

 
 

Repository files navigation

The Star Wars Battler: Ruby Sinatra Back-end

The goal of the SW Battler App is simple: 1)A user creates a "Commander" name and logs in with it. 2) The user creates a Fleet by designating a name. 3) The user is immediately brought to the "Ships" page wherein they can choose which fleet (they can have multiple fleets) they'd like to add which ship to. 4) After they have exhausted their budget of 1.5 million "credits" the can review the fleet details back on their 'Fleets' page. 5) When a user is happy with their fleet, it's time to Battle. Head to the Battle page. 6) On the battle page a user selects the fleet they want to use from their own list of fleets, chooses any fleet from any other user to battle against. And then picks a planet. The planet will augment their combat power based on the 'local envrionment'. 7) A win or loss is presented with a banner and GIF and the wins/losses and percentages are incrememnted for that fleet and the commander as a whole.

This back end utilizes Sinatra and ActiveRecord to enable easy communicaiton between tables. There are 3 primary tables; Users, Fleets, Ships. Each of these as joined with the FleetsShipsUser table.

*NOTE: This is the back-end, for the React front-end please see fork and clone Star Wars Battle Front-End as well. *

After cloning this repo you can install by running bundle install.

The problem you'll have is that all the ship data was hand-crafted after the initial seed from the SWAPI. I've left the seed data in the seed.rb file. Note that you'll have to run the star wars ship api call for ALL FOUR pages of starships. This is only the beginning as you will have to manually adjust combat rankings for all ships. If you would like to match my creation as close as possible you can request access to this Google sheet of details that I used to create combat power, etc.

Once this is created you are ready to go!

The vast majority of requests are simply getting and returning information for various fleets and the ships within. However the -get '/Battle' method/endpoint could use a bit of an explainer. This method will take the fleet information for the user and whichever fleet they've chosen and run simple math on the base statistics depending on the planet chosen. This is executed with a series of if, elsif statements in the application_controller. Finally this method WOULD have been an 'udpdate' method for win/losses however my install of Chrome is broken, denying PATCH requests. So a get request that iterates the table 'internally' was made.

The Chrome Patch issue is still ongoing and yet to be understood/resolved. If you have this issue where Chrome Dev Tools does not show Patch as an option and valid Patch requests are blocked due to the CORS, without any of the typical "access-control-alllow-origin" tricks working, please let me know! Especially if you've found a way to resolve it!

This API communicates with a separate React built front-end that houses all of the display information.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Ruby 83.4%
  • Dockerfile 16.6%