Code Monkey home page Code Monkey logo

tsdbcg's Introduction

Accession Server

A deck building card game backend using Ruby on Rails to handle game state for the React frontend pair application.

Build Status

About

This is the server side component to the deck building card game of Accession. This application is one half of the Accession game, and is required to generate games and manage game state. The general principles of Accession are...

  • Deck building card games start with each player having the same collection of cards, who then buy cards from a central pool and build a deck to gain victory points and win the game. Accession is a base implementation of this style of game, with plans for expansion in the future. The full set of rules can be found at the bottom of this documentation.

Hosted Version

A live version of this application can be accessed via https://accession-game-server.herokuapp.com/ using our endpoints below! If you would like to run your own local version, follow the instructions that follow.

Setup

Requirements

  • Brew Package Manager
  • Git
  • PostgreSQL
  • Ruby Version: 2.4.1
  • Rails Version: 5.2.3
Brew Installation

Brew is a package manager for Mac OS (or Linux) that allows us to install libraries using easy and convenient terminal commands. We need Brew to install later required elements of the Accession Server. To install Brew on a Mac OS machine, run in your terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

For Linux instructions, refer here.

Git Installation

If you're on GitHub, you're halfway to knowing what Git is! Git is a 'version control system' that tracks changes to code, stored in what is generally called a 'repository'. GitHub is a remote hosting service of these repositories, and you're looking at one right now! There are many ways to install and use Git:

Rbenv Installation

rbenv is an environment manager for the Ruby language that allows us to install and control multiple versions of Ruby on our computer. We can use Brew to install rbenv in our terminal:

brew install rbenv
rbenv init

The terminal will now instruct you to input some shortcuts for rbenv in your ~/.bash_profile:

  • nano ~/.bash_profile (or your preferred command line text editor)
  • CMD+V/CTRL-V eval "$(rbenv init -)" - to paste the shortcut
  • CTRL+X - to quit Nano
  • Y - to save the file
  • source ~/.bash_profile
  • curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
  • The last command will determine if your rbenv setup was successful. If you run into issues installing rbenv, I would suggest checking out their issues board, or Googling any specific errors on Google.
  • If you are unable to use Brew, refer to this section of the rbenv documentation.

PostgreSQL Installation

Postgres is a relational database management system that we use to store information in the Accession Server. All of the set up will be handled by Rails once we get to that step, but Postgres does need to be installed for that to happen. We highly suggest using Brew for this part of the process, but in the situation where Brew is not available, these are the instructions.

  • For a Brew installation:
brew install postgresql
brew services start postgresql
psql postgres

  • All below commands are to be run in your terminal or command line of choice.

To get the the Accession Server application up and running on your local machine, start by getting the source code from this GitHub repository:

git clone [email protected]:BrennanAyers/tsdbcg.git (for SSH)
cd tsdbcg

The Accession Server uses the bundler library to manage dependencies. This process will take some time to install all of the correct versions of the libraries we use. After cloning down the repo with the above commands:

bundler install

After Bundler installs all required packages, run in the the Accession Server directory:

rails db:create
rails db:migrate
rails db:seed

Now that our application files are sorted, and the database has pertinent information inside of it, we can start the application:

rails server

This will begin the server on your localhost:, generally on Port 3000. Now that that you have the game server up and running, you can interact with it through the Endpoints below, or install our UI application from here!

Endpoints

POST api/v1/games

  • A POST request used to start a new Game with a single Player. The Game does not start, as it does not have the required number of Players, but others will now be able to join using the Game ID.
  • Example Request:
POST api/v1/games
BODY: {
  "newPlayer": {
    "name": "Ted"
    }
  }
  • Example Response:
Status: 201
BODY: {
  "playerName": "Ted",
  "playerId": 1,
  "gameId": 1
}

POST api/v1/join_game

  • A POST request with a Body containing a Player name, and the Game ID of the Game the Player would like to join. Upon all Players required joining a Game, all GameCards for both the board, and all Players will be created and assigned to their respective areas. Example Request:
POST /api/v1/join_game
BODY: {
  "playerName": "George",
  "gameId": 1
}

Example Response:

Status: 200
BODY: {
  "playerName": "George",
  "playerId": 2,
  "gameId": 1,
  "gameStatus": "Game Started"
}

GET api/v1/game_state/GAME_ID

  • A GET request used to query the current Game state. This endpoint returns all publicly available information, such as all Action Cards, purchasable Money and Victory Cards, the Player turn order, Players current hand sizes, current most recent discarded Card, and all information to render the cards themselves.
  • Example Request:
GET api/v1/game_state/1
  • Example Response:
Status: 200
BODY: {
  "tableDeck": [
    {
      "name": "Gold",
      "category": ["Money"],
      "cost": 6,
      "victoryPoints": 0,
      "spendingPower": 3,
      "buyingPower": 0,
      "actionsProvided": 3,
      "cardsToDraw": 0,
      "image": "./gold.jpg",
      "desc": "",
      "tags": [],
      "countAvailable": 5,
      "id_list": [ 1011, 1012, 1013, 1014, 1015 ]
    },
    {
      "name": "Estate",
      "category": ["Victory"],
      "cost": 2,
      "victoryPoints": 1,
      "spendingPower": 0,
      "buyingPower": 0,
      "actionsProvided": 0,
      "cardsToDraw": 0,
      "image": "./estate.jpg",
      "desc": "",
      "tags": [],
      "countAvailable": 8,
      "id_list": [ 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048]
    },
    ...
  ],
  "playerOrder": [ "Player_1_Name", "Player_2_Name" ],
  "playerInfo": {
    "Player_1_Name": {
      "deckSize": 10,
      "topCardDiscard": 0,
      "handSize": 5
    },
    "Player_2_Name": {
      "deckSize": 10,
      "topCardDiscard": 0,
      "handSize": 5
    }
  },
  "activePlayerName": "Player_1_Name",
  "activePlayerId": 1
}

GET api/v1/games/GAME_ID/players/PLAYER_ID

  • A GET request to obtain the status of a given Player, in a given Game. This is used to render the given Players Deck and Discard piles, and draw cards from the Deck.
  • Example Request:
GET api/v1/games/1/players/1
  • Example Response:
Status: 200
BODY: {
  "playerId": 1,
  "deck": [
    {
      "name": "Copper",
      "category": "Money",
      "cost": 0,
      "victoryPoints": 0,
      "spendingPower": 1,
      "buyingPower": 0,
      "actionsProvided": 0,
      "cardsToDraw": 0,
      "image": "copper.jpg",
      "desc": "",
      "tags": []
    },
    ...
  ],
  "discard": [
    {
      "name": "Market",
      "category": "Action",
      "cost": 5,
      "victoryPoints": 0,
      "spendingPower": 1,
      "buyingPower": 1,
      "actionsProvided": 1,
      "cardsToDraw": 1,
      "image": "market.jpg",
      "desc": "",
      "tags": ["+1 Card", "+1 Action", "+1 Buy", "+1 Gold"]
    },
    ...
  ]
}

POST api/v1/endturn

  • A POST request to indicate the end of a specific Players turn, and send all pertinent information to be updated. This includes their Deck Cards, their Discard Cards, and any Cards they bought during the course of their turn. Deck and Discard Cards are sent as an Array of Card ID's, indicating the order of Cards to be drawn next turn, and in which order they should appear in the Discard pile. On a successful request, the Game turn counter will be advanced, moving from the current Player to the next in the queue.
  • Example Request:
POST api/v1/endturn
BODY: {
  "gameId": 123,
  "playerId": 234,
  "deck": [ 5, 2, 7, 11, 10 ],
  "bought": [ 12, 13 ],
  "discard": [ 3, 1, 9, 4, 8, 6, 12, 13 ]
}
  • Example Response:
Status: 200
BODY: {
  "Message": "Player Tom turn ended"
}

Websockets

Game State Channel

  • The Game State Channel is the ActionCable websocket that provides up to the second information about the current Game State for each Player. This is a work in progress, with only the Player Subscription functionality built out currently.
connect to '/cable' with parameters of { player_id: 1 }
  • Without a Player ID, the connection will be rejected.
  • On a Player joining, the Channel will return the following information:
    • Message Type: player-joined
    • Player ID
    • Player Name
    • List of Players already in the Game with their IDs and Names
  • The output will be identical to the above game_state endpoint, to allow for limited refactoring.

Testing

  • Because the Accession Server is built using Rails, the project is set up for testing using the RSpec framework with its robust Rails integration. All tests written are setup inside the spec, there are no required seeds or files to run our test suite.
  • The Accession Server uses SimpleCov to track test coverage on our code. The coverage folder that SimpleCov generates is in .gitignore, but you should still be able to check coverage by opening the index.html files after running the test suite. Code coverage is currently at 100%, so any further contributions should follow this lead.
  • To run all of our specs using RSpec, in the terminal: rspec or bundle exec rspec

Contributors

Accession was a collaboration between students in the Backend and Frontend programs at the Turing School of Software and Design in Denver, Colorado. Everything was planned, programmed, and deployed in 13 days as our last project before graduation. Contributors are as follows:

Backend

Frontend

Learning Goals

  • Apply Backend and Frontend teams into one application
  • Use professional workflow techniques (Agile, CI/CD) to create quality code
  • Push ourselves outside of our comfort zone by creating a synchronous game with web technologies

Game Rules

How To Play
Introduction
You are a monarch, like your parents before you - a ruler of a small pleasant kingdom of rivers and evergreens. Unlike your parents, however, you have hopes...dreams! You want a bigger and more pleasant kingdom, with more rivers, and a wider variety of trees. You want a Accession! In all directions lie fiefs, freeholds, and feodums - all small bits of land, controlled by petty lords and verging on anarchy. You will bring civilization to these unfortunates, uniting them under your banner.

But wait. It must be something in the air; several other monarchs have had the exact same idea. You must race to get as much of the unclaimed land as possible while you can, fending them off along the way. To do this you will hire minions, construct buildings, spruce up your castle, and fill the coffers of your treasury. Your parents wouldn't be proud, but your grandparents, on your mother's side, would be delighted.

This is a game of building a deck of cards. The deck represents your Accession. It contains your resources, victory points, and the things you can do. It starts out a small sad collection of Estates and Coppers, but you hope that by the end of the game it will be brimming with Gold, Provinces, and the inhabitants and structures of your castle and kingdom. You win by having the most Victory Points in your deck when the game ends.
Overview
Accession is a game of building a deck of cards. Each player has their own deck, their own discard pile, their own hand of cards and play area. Players start with a weak initial deck and gradually acquire better cards over the course of the game.

Players take turns. Each turn has three phases: Action, then Buy, then Clean-up, which you can remember as ABC. In the Action phase, you can play one Action card from your hand; in the Buy phase, you can play any number of Treasure cards and then buy one card to add to your deck; and in Clean-up you sweep up all of your cards from play and from your hand and discard them, then draw a new hand of 5 cards, shuffling as needed.

The game ends after 3 kingdom piles are empty or the Province pile is empty.
Action Phase
In your Action phase, you can play one Action card from your hand. Those are cards that say "Action" on the bottom, and by default have a white banner (some are other colors due to additional types). Playing an Action card has three steps: announcing it; moving it to the "in play" area - the table space in front of you; and following the instructions on it, in order, top to bottom. If the card has a dividing line (e.g. Moat), you stop there; instructions below the line happen at some other time (indicated). If you cannot do everything a card tells you to do, you do as much as you can; you can still play a card even if you know you will not be able to do everything it tells you to.

Some cards give "+1 Action." This increases how many Action cards you can play in a turn. The increase happens right then, but you do not play the next Action card until completely finishing the first one. Some cards give "+2 Actions"; that means you can play two more Action cards that turn. So, for example, if you play Militia, which does not give +Actions, you resolve Militia and are done with your Action phase. But you could instead play a Market, then another Market, then a Militia; each Market gives you +1 Action, which lets you keep playing Actions.

Using up your Actions is optional; you can have an Action card left in hand that you can play, and decide not to play it.
Buy Phase
First you can play any number of Treasure cards from your hand, in any order. Treasure cards say "Treasure" on the bottom and have a yellow banner. You play one by moving it to the "in play" area; you probably will not announce your Treasures, though you can if you want. The Treasures have no text, just a big coin with a number on it. You get that many coins to spend this turn - one coin for a Copper, two for a Silver, three for a Gold, indicated on the card. You do not have to play every Treasure in your hand (but only get this turn for the Treasures you play).

Then, you can buy one card, costing as many coins as you have or less. Costs are indicated in the lower left corner of cards. You buy a card by choosing it from the Supply, and then "gaining" it. "Gaining" a card means moving it from the Supply to your discard pile. Your total amount of coins available to spend goes down by the cost of the card. For example if you played four Coppers and a Silver, that makes 6 coins total; if you bought a Market, that costs 5 coins, so you would move a Market from the Supply to your discard pile and have 1 coin left.

Buying cards does not use up Treasure cards; you still have the cards. The Treasures produce income usable every time you draw them. Buying cards just uses up the coins you have available this turn. Some cards give "+1 Buy." This increases how many cards you can buy in a turn in your Buy phase. For example with 6 coins and an extra Buy, you could buy two Silvers, which each cost 3 coins. Using up your Buys is optional. You can have two Buys but just buy one card, or skip buying entirely. As Copper costs 0 coins, you could use a Buy with no coins to buy a Copper.

You cannot go back and play more Treasures after buying a card; first play Treasures, then buy.
Clean-up Phase
Take all of the cards you have in play (both Actions and Treasures), and any remaining cards in your hand, and put them all into your discard pile. The order does not matter; you can hide the cards from your hand under the played cards if you want to.

Draw a new hand of 5 cards. If your deck has fewer than 5 cards, first shuffle your discard pile and put it under your deck, then draw.

Play passes to the player to your left. Any unused +Actions, unused +Buys, or unspent coins that you had left are gone; you start each turn fresh.
Game End
The game ends at the end of a turn, if either the Province pile is empty, or any three or more Supply piles are empty (any piles at all, including Kingdom cards, Copper, etc.).

Take all of your cards - from your hand, deck, discard pile, play area, and even set aside cards - and sort them for putting them back in their piles. Count up your Victory Points.

The player with the most Victory Points wins. If players tie for Victory Points, a player who tied but had fewer turns wins. If players tie and had the same number of turns, they rejoice in their shared victory.
Card Reference
Cellar: Choose any number of cards from your hand; discard them all at once; then draw as many cards as you actually discarded. If this causes you to shuffle, you will shuffle in the cards you discarded. You do not have to let players see any but the top card discarded; however the number of cards you discard is public.

Market: You draw a card and get +1 Action, +1 Coin, and +1 Buy.

Militia: Players with 3 or fewer cards in hand do not discard any cards. Players with more cards discard until they only have 3.

Mine: You can, for example, trash a Copper to gain a Silver, or trash a Silver to gain a Gold. The Treasure you gain comes from the Supply and is put into your hand; you can play it for coins the same turn. If you do not have a Treasure to trash, you do not gain one.

Moat: An Attack card says "Attack" on the bottom line; in this set Militia are Attacks. When another player plays an Attack card, you may reveal a Moat from your hand, before the Attack does anything, to be unaffected by the Attack - you do not discard for Militia. Moat stays in your hand, and can still be played on your next turn. Moat does not stop anything an Attack does to other players, or for the player who played it; it just protects you personally. Moat can also be played on your turn for +2 Cards. If multiple Attacks are played on a turn or in a round of turns, you may reveal Moat for as many of them as you want.

Remodel: You cannot trash the Remodel itself, since it is not in your hand after you play it. If you do not have a card to trash, you do not gain one. If you do gain a card, it comes from the Supply and is put into your discard pile. The gained card does not need to cost exactly 2 coins more than the trashed card; it can cost that much or less, and can even be another copy of the trashed card. You cannot use coins to increase how expensive of a card you gain.

Smithy: You draw 3 cards.

Village: You draw a card and get +2 Actions.

Woodcutter: You get +2 Coins, and +1 Buy.

Workshop: The card you gain comes from the Supply and is put into your discard pile. You cannot use coins to increase how expensive of a card you gain; it always costs from 0 coins to 4 coins.
Rules Credits Thank you to Donald X. Vaccarino and Rio Grande Games for making the original Dominion game!

tsdbcg's People

Contributors

davisc0801 avatar patrick-duvall avatar brennanayers avatar vjt960 avatar

Stargazers

Rion avatar

Watchers

James Cloos avatar  avatar Rion avatar

Forkers

patrick-duvall

tsdbcg's Issues

Add SimpleCov for Code Coverage

We need to be tracking our Test coverage with a tool like SimpleCov on our project. We have not done this yet.

  • Add SimpleCov gem
  • Add require simplecov and SimpleCov.start 'rails' to rails_helper.rb

Add `default: 0` to Card attributes regarding points/actions

Currently, the Integer fields on the Card objects do not have a default value. This will cause issues when Frontend is trying to render cards, as they are expecting 0's in the following attributes if they do not have that value, instead of null:

  • Victory Points
  • Spending Power
  • Buying Power
  • Actions Provided
  • Cards to Draw

We will need to update the migrations and schema for these attributes on Card.

End turn endpoint

As a user when I receive a POST to api/v1/endturn. In the format

{
gameId: 123,
playerId: 234
deck: [ ordered array cards ids], 
bought: [array ids ]
discard: [ordered array card ids]
}

Successfully returns a 200

Documentation for Base Set of cards

We need a collapsable section in our README about the Base Set of cards we are implementing, and their rules and interaction patterns. This can be copied and pasted from the Dominion rulebook to ensure parity.

Establish common Git hooks

Creating Git hooks will allow all contributors to follow the same style and ensure passing tests. These will differ between BE and FE because of the languages, but this is something we should establish between the teams so we can be held to the same standards.

Add player class

Player class has a deck and is in charge of its hand, inplay, deck, discard, buys, coins, actions.

-Include logic to draw
-To shuffle deck
-To discard
-To end turn
-To play card

Add JSON response with status to `endturn` endpoint

Currently, the endturn endpoint does not return any information for the Frontend on a successful Game Update. Following general convention, we should return a 200 or 204 status code.
200:

render json: { "message": "Player 1 turn successfully processed" }, status: 200

204:

head :no_content

DTR

Define The Relationship:
We will outline our processes, needs and wants for the project, and what we envision our schedule looking like at this time.
Following this template

Quick Fix Game State Documentation

Kevin from the Frontend team reported this morning that the documentation for the Game State endpoint was not full accurate:

note: there is a discrepancy in the docs for game_state endpoint
docs:
"currentPlayerName": "Player_1_Name",
"currentPlayerId": 1
actual:
"activePlayerName": "Player_1_Name",
"activePlayerId": 1

He also noticed that the documentation has nulls in some spots for attributes, instead of 0s like they should be.

Seed file with all Base Set Cards

For us to be able to accurately QA our application, and for the Frontend team to be able to run against a local/staging environment, we need to have actual data in our DB. Currently, we have been testing using Factories, but we should set up a Seeds file for Rails to create Cards resources that match the final Base Set of Cards that we plan on implementing.

Add Card Images to Backend

Card images are currently served through local storage on the frontend, we would like to change to use our backend to serve said images.

  • Add image resources to the rails application
  • Add production URL paths to seed file for the card table

Story Writing Meeting

Using the previously determined Wireframes, the team will write fleshed out User Stories that will determine interaction and experiences while playing the game.

This can be done as a whole group but this tends to lead to some people doing all of the work while others might just be sitting and watching. Probably best done in pairs while the others work on design and branding.

  • Suggestion: 1 FE and 2 BE work on this, other FE and BE focus on another meeting

Documentation for Database

We should add documentation for the fact that we are using Postgres, and how to:

  • Create
  • Migrate
  • Seed (if applicable)

Documentation for Buy Card Endpoint

Since we did not add Documentation for the buy_card endpoint with our implementation PR, we should add it in later. We will need to add:

  • Usage
  • Required information in request
  • Response example

Architecture and Schema Decision Meeting

Following the Architecture and Schema Brainstorming, the team will decide on what ideas were most appropriate, and what can be performed in the limited time frame. While this is the game plan, it is expected things will change over the course of the project, and that's fine. This is a map of where we want things to go with the knowledge we have at this time.

Time limit: 30-60 minutes

Assigned Roles:

  • Time Enforcer:
  • Notetaker:
  • Facilitator:

One way to quickly exhaust a group is to allow debates to go on too long. Have the team vote if any decision takes more than 10 minutes. If the team can’t decide bring in an instructor and they’ll be the deciding vote.

- What should the schema look like?
- What will your architecture look like? (background workers, caching, websockets, JavaScript)
- What tasks need cards created in your project management tool? Who will add these? Label these tasks as chores. Note: migrations should be run in the context of the user stories that need them and shouldn’t have cards associated with them. An example of a chore might be is more for setting things up like Redis on Heroku.

Notes linked here:

Wireframes Meeting

This will be a meeting to determine the outline of the three most important MVP features, determined through prior meetings.

Time limit: 30 minutes

Assigned Roles:

  • Time Enforcer:
  • Notetaker (builds the wireframes):
  • Facilitator:

One way to quickly exhaust a group is to allow debates to go on too long. Have the team vote if any decision takes more than 10 minutes. If the team can’t decide bring in an instructor and they’ll be the deciding vote.

Design and Branding Meeting

Using the previously determined Wireframes, this meeting will be decisions on color scheme, fonts, logo, etc. HTML/CSS, if relevant, can be used to sketch out basic ideas and concepts.

This can be done as a whole group but this tends to lead to some people doing all of the work while others might just be sitting and watching. Probably best done in pairs while the others work on writing stories.

  • Suggestion: 1 FE and 1 BE handle this, while the rest of the team focuses on a different meeting

Final Prioritization Meeting

After all other meetings, come to a final conclusion about the first steps for the project. This should take context from both a developer view and a customer standpoint. This is the time to determine User Story weight and priority, keeping in mind delivery deadlines and time management.

Time limit: 30-60 minutes

Assigned Roles:

  • Product Representative (probably someone who was writing the user stories):
  • Technical Representative:
  • Time Enforcer: Everyone
  • Notetaker:
  • Facilitator:

One way to quickly exhaust a group is to allow debates to go on too long. Have the team vote if any decision takes more than 10 minutes. If the team can’t decide bring in an instructor and they’ll be the deciding vote.

If there is a time for adding final thoughts into cards/stories with the full understanding of the team, it is now.

Notes linked here:

Get Common Card Endpoint

As a user
I should be able to request GET '/api/v1/game_state'
And receive a JSON object containing all Kingdom Cards not in a player's Deck - 
This endpoint will return information in the following format:
  [
    {
      name: "Gold",
      type: "Treasure",
      cost: 6,
      spendingPower: 3
      numberAvalible: 30
    },
    {
      name: "Duchy",
      type: "Victory",
      cost: 5,
      victoryPoints: 3
      numberAvalible: 8
    }
  ]

Initialize Rails

We will be pivoting and using Rails for this project. We need to do our initial Rails commit, bringing in the framework, and whatever base tools we will need.

  • Rspec
  • FactoryBot

Implement Deck Order mechanic

To maintain parity between the Frontend and the Backend with a Players GameCards, we will need to implement logic to send and receive the order of a given Players deck of GameCards.
The flow for this looks like:

  • GET Player State endpoint contains an array of GameCard objects in the order they should be drawn
  • Frontend draws cards in this determined order for players
  • Frontend sends POST at end of turn dictating which cards are discarded (and in what order)
  • Backend finds new cards/existing cards to mark as Discarded

Edge Cases

  • Frontend shuffles Discard into Deck, Frontend sends us an updated Deck Order during the End Turn phase
  • We update GameCard deck_order number to reflect this change

Heroku Staging ENV not wrapped in quotes

My bad.
When we try to access the ENV[HEROKU_STAGING], the HEROKU_STAGING needs to be wrapped in quotes, otherwise Ruby reads it as a constant variable.
I misremembered.

Documentation for Player State endpoint

Since this documentation was not added initially, we should add information for the Player State endpoint.

  • How to format request
  • Example Response
UPDATE

This should now also include information about how the Deck cards will be returned in the determined deck_index order.

Player Join Validations

The endpoint /api/v1/join_game needs the following edge cases considered:

  • The connection should reject the player if the game is full (currently 2 players)
  • The player should be able to rejoin a game if they are disconnected without creating another player object on the game.
  • The game start script should only run if all players have joined and the game is already started.

Game Player Lobbies

UPDATE

We can implement this for only 2 players initially.

As a user
I should be able to visit the TSDBCG Lobby website
And put my name in to join the queue
And once a Game with enough Players is started
I will be a part of that Game in the main App

This will be built out on another repo.


If a Player joins an existing Game, and is not the last required Player (out of 4), the Game will not be started, and the Player will be put into a Lobby of other waiting Players in that Game.

Game Start

A Game needs to be started to initialize the state of the Game, and state of the Players in the Game.

  • All Players start with 7 Copper and 3 Estates in their deck (collection of GameCards)
  • All Games start with an additional 60 Copper and 8 Estates

This facet is required for #27 to function, as Player State is not established until the Game is started.

Update Player State endpoint to follow Card Serialization conventions

After confirming with the Frontend what Serialized Card objects should look like for the Game State, the same update needs to be applied to the Player State endpoint as well.
The final serialized Card Object should look like this:

{
      name: "Copper",
      category: "Money",
      cost: 0,
      victoryPoints: 0,
      spendingPower: 1,
      buyingPower: 0,
      actionsProvided: 0,
      cardsToDraw: 0,
      image: "copper.jpg",
      desc: "",
      tags: []
    }

Product Vision Meeting

Brainstorming session to decide collaboratively the MVP of the project. This will include the main features that both FE and BE are interesting in developing.

Time limit: 30 minutes

Assigned Roles

  • Time Enforcer:
  • Notetaker:
  • Facilitator:

Make sure this session isn’t used to make decisions. That comes later. Allow everyone’s voice to be heard and make sure no one is dominating the discussion.

Encourage your team to be creative. Encourage people to share bad ideas as well as good. Sometimes bad ideas lead to good ones.

If you need questions guiding the discussion:

- What would an MVP (minimum viable product) look like? If your team needed to ship features every evening to prove value to an investor, what would you work on and in what order?
- What would set you apart during demo night?
- What intimidates you but would be amazing to pull off?
- How should your users experience the app? Desktop, mobile, native app?
- What features or technology choices would spark interesting discussions during job interviews?
- Would you use this product? If not, what is it missing?

If debating a single idea goes longer than 5 minutes point it out. There’s no need to make a decision now and allowing one idea to dominate the discussion can hinder creativity and cause frustration.

Notes linked here:

Game Initializes with All Cards

A Game needs to be started to initialize the state of the Game, and state of the Players in the Game.

  • This method needs to create and add all cards in the game.
  • This method needs to assign the initial player hands and deck.

Tie In to issue #33

Fix current Documentation for typos/ordering

Currently, the README has some typos, and the order of the Endpoints is not in the correct order to facilitate gameplay.
The order should be as follows:

  • Game Start
  • Game Join
  • Game State
  • Player State
  • Player End Turn

There are typos in the:

  • Player State
    • Deck and Discard are Card objects inside of an array, not inside of an object
  • Rails setup
    • It's rails server not rails start

Card Categories are serialized as an Array

For the Frontend, to handle Single or Multiple categories, the Card attribute of category should be an Array of categorical (Action, Money, Victory) identifier strings.
We should store these in the DB as a String of comma separated values, which we then can serialize as an Array.

UPDATE

This has been set up correctly on the Player State endpoint, will need to be implemented on the Game State endpoint.

Product Vision Decision Meeting

A meeting to make a final decision on the MVP of the project. This will be done after the Brainstorming Product Vision meeting.

Time limit: 15-30 minutes

Assigned Roles:

  • Time Enforcer:
  • Notetaker:
  • Facilitator:

One way to quickly exhaust a group is to allow debates to go on too long. Have the team vote if any decision takes more than 10 minutes. If the team can’t decide bring in an instructor and they’ll be the deciding vote.

What are the three most important features?
How would you prioritize them?

Upate Get `api/v1/game_state/:id`

Endpoint tentatively returns

{
tableDeck: [
   { name: "Gold",
    category: ["Treasure"],
    cost: 6,
    image: "Gold.jpg",
    spendingPower: 3,
  },
  {
    name: "Estate",
    type: ["Victory"],
    cost: 2,
    image: "Estate.jpg",
    victoryPoints: 1,
    id: 6123
  }
  ],
  player_order: [player1, player2],
  player_info:  {
  player1: {
    deckSize: 13,
    topCardDiscard: "Village",
    handSize: 5
  },
   player2: {
    deckSize: 13,
    topCardDiscard: "Village",
    handSize: 5
}

Buy Card Endpoint

As a user
I should be able to purchase a card for a Player in the Game
Using POST 'api/v1/games/:game_id/buy_card'
And a Body containing:
- Player ID
- Bought Cards
- - Card Name
- - Amount Bought
And receive a response containing the Players Name
And the Cards bought with their quantities

CI Implementation and Heroku Pipeline

UPDATE:

Travis needs a database setup, and needs to know it is using Postgres.

Setting up a Heroku Pipeline will allow our project to flourish and be testing in a Production environment consistently as we add features and functionality.
For BE this looks like a Staging environment where we can hit endpoints with real live variables, and then pushing to Production after passing our QA stage.
For FE this looks like:
Additionally, Travis CI or another CI tool will be another barrier to ensuring our code is functional alongside our tests.

Fix incorrect `.map` syntax on PlayerSerializer

Currently, the .map call when building deck and discard in the PlayerSerializer are formatted for a one-line syntax. This is not appropriate, because the block inside is building a hash that has multiple key value pairs.
This should instead be converted to a .map do |card| with an end.

Validation Specs for Models

We did not write validation specs for Models, only testing their Associations. At this moment in time, we do not plan on allowing User input, except for Player names. Otherwise, all of our resources should be hand built by us. This does not mean that we shouldn't cover our bases.

Database Setup

We need to set up our Database with the information that we understand at this time. This involves:

  • Games
    • Have Many Cards
    • Have Many Players
  • Cards
    • Have Many Games
    • name
    • type
    • cost
    • victory_points
    • spending_power
  • GameCards
    • Belong to Game
    • Belong to Card
    • CAN belong to Player
    • trashed (boolean)
    • discarded (boolean)
  • Players
    • Belong to Game
    • CAN Have Many GameCards
    • name

Architecture and Schema Brainstorming Meeting

After determining Wireframes, the team will decide on the building blocks and database considerations to facilitate the project.

Time limit: 30-45 minutes

Assigned Roles:

  • Time Enforcer:
  • Notetaker:
  • Facilitator:

Clarifying Questions:

- Are there parts of the app that would benefit from things happening in the background? (tasks that take a long time or need to run on a regular basis; nightly, hourly, etc.)
- Are there parts of the app that would benefit from breaking away from the request/response cycle by updating the page automatically? (websockets, AJAX, etc.)
- Should you cache data to improve page load times?
- Should this be one big Rails app?
- How might the schema look?
- Is there anything different you might need to try in your schema? (self-referential associations, serialized columns, etc.)

Notes linked here:

Player Join Endpoint

As a user
I should be able to POST request 'api/v1/join_game'
With a Body containing my Player Name, and the Game ID
Of the Game I would like to join
And I will receive a response with a 200 status code, the Player Name, Player ID, and the Game ID
And a successful message of Game Started

Request:
POST /api/v1/join_game
BODY: {player_name: "George", game_id: 1}
Response:
BODY: {player_name: "George", player_id: 2, game_id: 1, game_status: "Game Started"}

Game Started implies that all required players have joined this game, and the backend has run the Game.start method, building out decks and cards for the frontend to render to each Player.

Add turn change to POST `api/v1/end_turn`

Before a POST request to api/v1/end_turn

game = Game.find(id)
game.current_player == "Player One"

After a POST request to api/v1/end_turn

game = Game.find(id)
game.current_player == "Player Two"

Full Setup instructions for Rbenv, Ruby, Rails, Postgres

As it turns out, setting up a Ruby environment and getting Rails fully set up on a vanilla machine is a pretty rough experience. We need to expand our documentation for the Setup section to really make it flawless to get up and running.

  • Brew setup
  • Rbenv setup
  • Postgres setup
  • Rails setup

Generate Pull Request Template

To ensure proper code review, merging, and quality, we will want to create a Pull Request Template to follow for ALL PRs.
An outline could be:

# Pull Request Template

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:
* Toolchain:
* SDK:

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

New Game Endpoint

As a user
I should be able to POST to the Games endpoint with my 
- Name
And start a new Game
And receive a body containing:
- My Player Name
- Player ID
- Game ID

Request:
POST /api/v1/games
BODY: {player_name: "Ted"}
Response
BODY: {player_name: "Ted", player_id: 1, game_id: 1}

On the backend, we will need to first create a new Game object, and then the new Player object attached to that Game. The Game will not start yet, as it does not have all required players.

Documentation for GameStateEndpoint

Since documentation for the Game State Endpoint was not added during the PR for the implementation of said endpoint, we should add it later.

Add GET api/v1/games/:game_id/players/:id endoint

This endpoint returns a players specific deck and discard info in the format

{
  playerId: 99,
  deck: [{
    name: "Gold",
    category: ["Treasure"],
    cost: 6,
    image: "Gold.jpg",
    spendingPower: 3,
    id: 1515
  },
    {
    name: "Gold",
    category: ["Treasure"],
    cost: 6,
    image: "Gold.jpg",
    spendingPower: 3,
    id: 1515
  },
{
    name: "Gold",
    category: ["Treasure"],
    cost: 6,
    image: "Gold.jpg",
    spendingPower: 3,
    id: 1515
  }],
  discard: [{
    name: "Estate",
    type: ["Victory"],
    cost: 2,
    image: "Estate.jpg",
    victoryPoints: 1,
    id: 6123
  },
{
    name: "Estate",
    type: ["Victory"],
    cost: 2,
    image: "Estate.jpg",
    victoryPoints: 1,
    id: 6123
  }
  ]}
}

Requires #33

Documentation for Rails

We should add documentation for the fact we're using Rails, and what version.
This goes hand in hand with documentation for Ruby as well, and mentioning the version.

  • Bundle installation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.