Skip to content

mattbrand/campconquer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camp Conquer

Konker? I just met 'er!

Important Links

Features: http://sprint.ly/product/41137/dashboard/?statuses=backlog,current,complete&order=priority

Game Database: https://docs.google.com/spreadsheets/d/1LY9Iklc3N7RkdJKkiuVNsMJ07TFsBi973VmIqgnLO6c/

TODO

  • [/] make sure client behaves OK with maintenance mode on (503 (Service Unavailable))

    • some client calls still need to be hardened
  • optimization - look at Scout for slow requests

  • reexamine FitBit API to see if there's a more efficient call to fetch a bunch of days at once

low priority features

  • round up remainder steps

  • return # of coins received in claim response (coins and gems alike)

  • validate max. one capture per game

  • player stats across all seasons in GET player endpoint

  • set session token inside WebGL HTML; skip login in client

  • expire session token after X days

chores

  • redo dump tests

  • look into memory usage errors

  • heroku addons

    • New Relic
    • Scout
    • Papertrail
    • Honeybadger or Airbrake
    • CircleCI
  • rename attack_mvp to top_attacker and defense_mvp to top_defender

  • seed_players should use avatar.csv to determine gear asset

  • remove/unify json path files -> paths.csv

  • remove current db field

  • create prod env

    • heroku
    • fitbit
    • game client selector UI
  • fixture factories

  • merge Piece into Player in API and DB

  • make a Procfile https://devcenter.heroku.com/articles/ruby-default-web-server

  • Alex learns Unity (gratis)

  • switch from RAML to Swagger? http://swagger.io/

  • upgrade to Rails 5

Updating the Seed DB

To update the gear database,

  1. go to https://docs.google.com/spreadsheets/d/1LY9Iklc3N7RkdJKkiuVNsMJ07TFsBi973VmIqgnLO6c/
  2. select the "Gear" worksheet
  3. select "File > Download As > CSV (current sheet)"
  4. save as db/gear.csv
  5. verify everything locally (rake spec, open http://localhost:3000, etc.)
  6. git add db; git push; ./deploy.sh

Name must be unique and remain consistent. NEVER remove or change the short name ("Name") of an item that already exists inside a player's inventory or was used in a game that has ever been played.

(We may want to add a "disabled" flag to the spreadsheet for that scenario in order to retire gear.)

For paths, similar to above but

  1. use the "Paths" sheet
  2. save as db/paths.csv
  3. git add db; git push; ./deploy.sh to deploy

This should be obsolete soon, but I wrote a little script to convert Matt's path json into tab-delimited format for easy pasting into the gdoc. Put the various json files in db e.g. db/bluePaths.json and then...

  • run rails r "Path.print_rows('blue', 'defense')" | pbcopy
  • switch to the gdoc, click on a cell and hit Cmd-V to paste

API Docs

Reference doc: campconquer.raml

Atom

  1. Install https://atom.io/

  2. Install http://apiworkbench.com/ with apm install api-workbench

    • or open Settings/Preferences -> Install and search for api-workbench
  3. Activate autosave:

     autosave:
       enabled: true
    
  4. Read http://apiworkbench.com/docs/

command-line raml2html

First, install raml2html

cd ..
git clone git@github.com:raml2html/raml2html.git
cd raml2html
chmod a+x ./bin/raml2html
npm install

Then go back to this project dir and run:

./doc.sh -o

and when the server is running later on you can access

http://localhost:3000/campconquer-api.html or http://campconquer-staging.herokuapp.com/campconquer-api.html

Admin

We are using ActiveAdmin for some non-API UI

http://activeadmin.info/docs/documentation.html

Local Development

First Time Setup:

  • install Homebrew, XCode Command-Line Tools, RVM, Bundler, Rails, etc.; see http://installfest.railsbridge.org/ for more info

      rvm get master
      rvm install ruby-2.3.3
      gem install bundler
    
  • git clone git@github.com:mattbrand/campconquer.git

  • cd campconquer

  • bundle install

  • edit .env (see below)

  • rake db:setup

Problems with Nokogiri? Check here: http://stackoverflow.com/questions/40038953/installing-nokogiri-on-mac-os-sierra-10-12

Optional setup:

Alex recommends JSON Viewer for nicely viewing JSON output in Chrome

and Postman for exploring APIs

Pulling Code

  • git pull
  • bundle install
  • rake db:migrate
  • rake db:seed (if seeds.rb or its data files have changed)
  • rake spec
  • rails server or heroku local
  • open http://localhost:3000

Unity

Open the campconquer-unity directory as a project dir in Unity

Building a Unity Build in Unity

  1. click "Build Settings" (cmd-shift-B)
  2. make sure platform is "WebGL" (select it and click "Switch Platform" if it's not)
  3. click "Player Settings" button and make sure memory is 2032
  4. click "Build" button
  5. click on "public" and Save As "CampConquer" -- if it doesn't say "Are you sure?" then you clicked wrong

API Usage

  1. Sign in and get a token (use your actual name and password)

    http://localhost:3000/api/sessions?name=mod&password=xyzzy =>

     {
       "status": "ok",
       "token": "c1478346db1f93b79030d3d8a7753716ac4c634247af16bd48ab31fa371aee27",
       "player_id": 1024
     }
    
  2. Pass that token in to every subsequent call

    http://localhost:3000/api/players?token=c1478346db1f93b79030d3d8a7753716ac4c634247af16bd48ab31fa371aee27 =>

     {
       "status": "ok",
       "players": [
         {
           "id": 1024,
           "name": "mod",
           "team_name": "red",
           ...
    
  3. Use POSTMAN, it's good

Terminal Commands

command description
rake state_machine:draw CLASS=Game update the state diagram in Game_state.png
rake db:seed_players create 50 random players with random roles / positions / paths / etc. (and erases all previous players and games)
rake db:seed_game create 1 random game

Rails Console Commands

command description
rails console enter the console
Game.current.destroy! destroy the current game and all related pieces/setup
g = Game.current get the current game, creating it if necessary
g.lock_game! lock the game and copy pieces from the players
g.finish_game! winner: 'red' force a completion (this may break soon)
g.unlock_game! unlock the game and delete the copied pieces
reload! load changed source code (ignores initializers)
reload!; Game.current.destroy!; Game.current.lock_game! quick game restart
p = Player.find(123) load a player by their id
p = Player.find_by_name('fred') load a player by their name
p.buy_gear! 'hat9' buy gear for a player
p.equip_gear! 'hat9' equip gear for a player
p.drop_gear! 'hat9' throw away (un-own and un-equip) gear for a player
p.update!(password: '123456') sets player's password

####More complicated Rails Console examples:

show all player names and their owned gear

Player.all.map{|p| [p.name, p.gear_owned]}

=> [["Thatcher", ["hat1", "hat2", "hat3", "shirt0", "shirt1", "shirt2", "shirt3", "shoes0", "hat0"]],
 ["Megan", ["hat1", "hat2", "hat3", "shirt0", "shirt1", "shirt2", "shirt3", "shoes0", "hat0"]], ...

buy (but don't re-buy) the default gear for all players

Player.all.each {|p| Gear.where(owned_by_default: true).each {|g| p.buy_gear! g.name unless p.gear_owned.include?(g.name)}}

set a random path on a player p

 path = path: Path.where(team_name: 'red', role: 'offense').sample
 player.piece.update!(path.points)

Local development with Fitbit

  • Create an app for yourself at https://dev.fitbit.com/apps named e.g. "Matt's Local CampConquer"

    • Callback URL must be http://localhost:3000/players/auth-callback
  • Put values inside .env in the project dir, e.g.:

      FITBIT_CLIENT_ID=123XXX
      FITBIT_CLIENT_SECRET=abc123abc123abc123abc123abc123abc123
      FITBIT_CALLBACK_URL=http://localhost:3000/players/auth-callback
    

Note that FITBIT_CALLBACK_URL must correspond with the Callback URL on https://dev.fitbit.com/apps/edit/xxxxx

  • https://ngrok.com/ may be useful if you want to demo a locally-running app to someone on the wider Internet

Production and Staging

Local Setup

git remote add prod https://git.heroku.com/campconquer-prod.git
git remote add staging https://git.heroku.com/campconquer-staging.git

Heroku Commands

command description
./deploy.sh staging deploy local master branch to staging
heroku console -r staging open Rails console on staging
heroku config -r staging display config vars for staging
--- ---
./deploy.sh production deploy local master branch to production
heroku whatever -r prod do whatever on production

Check Logs

scheduled jobs

We use Heroku Scheduler to run rake pull_activity from lib/tasks/scheduler.rake every night at 5:30 UTC (12:30 or 1:30 Eastern)

see https://devcenter.heroku.com/articles/scheduler

Fitbit Integration Is Functional!

Want to see what other Fitbit info is available? Check out https://dev.fitbit.com/docs/activity/ for docs

Miscellaneous Links

BestHTTP: https://docs.google.com/document/d/181l8SggPrVF1qRoPMEwobN_1Fn7NXOu-VtfjE6wvokg/edit#

Xamarin Studio Community Edition: https://www.xamarin.com/download

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published