Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sashadev-sky/blackjack
Terminal console game
https://github.com/sashadev-sky/blackjack
colorize game rspec ruby terminal
Last synced: about 1 month ago
JSON representation
Terminal console game
- Host: GitHub
- URL: https://github.com/sashadev-sky/blackjack
- Owner: sashadev-sky
- Created: 2018-08-06T02:11:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-08T22:29:32.000Z (over 6 years ago)
- Last Synced: 2024-11-09T09:54:20.517Z (3 months ago)
- Topics: colorize, game, rspec, ruby, terminal
- Language: Ruby
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blackjack
- Terminal version of the classic Blackjack card game written in Ruby. Please note specific house rules outlined on this page
## Overview
- Run the command `bundle install` in your terminal
- To play, then run `ruby lib/blackjack.rb` in your terminal
- This game supports multiple players: currently it is set to one player vs. a dealer
- To add more, utilize the `add_player` method in the `blackjack.rb` file and save your changes before running the game
- Reference the commented out `add_player` invocations at the bottom of the file as an example## Testing
- Written in RSpec
- To test all at once: run command `bundle exec rspec`
- To test individual spec files:
- run, for ex: `bundle exec rspec ./spec/dealer_spec.rb`## House Rules
- Each player starts with a bankroll of $1000
- Each round begins with players entering their bets
- The minimum bet is $2
- The maximum is equal to the current value of the players bankroll
- The deck is shuffled prior to each round
- 2 cards are dealt to each player and the dealer from a standard deck of 52 cards
- The dealer's 2nd card will be face down until the players complete their turns
- An ace counts as a 1 or 11
- Face cards are 10 and any other card is its pip value
- The dealer will always hit until the value of their hand is >= 17 points
- Players play against the dealer - multiple players can win
- If a player's hand is not busted (over 21) and has a higher score than the dealer, the player will receive their bet double at the end of the round
- Otherwise, the player will lose the amount they bet (ties with the dealer are considered a loss)
- Bets are reset after each round
- If a player goes bankrupt, they are out of the game
- Rounds are unlimited and the game is only over when all of the players go bankrupt (in this case, when they can't afford the minimum bet of $2)#### Ruby Concepts (personal use)
- RSpec
- Unit Testing
- Test doubles
- Cases where the `dup` method is vital
- `respond_to` for checking if variables are exposed
- When to use context block
- Integration Testing
- `send` method
- `colorize` gem
- `background` argument for rendering cards
- Freezing constants
- Overriding `==`
- Overriding `to_s`
- Class inheritance
- `product` method - to create a deck of cards
- splat operator - to return cards to deck w/out nested arrays
- `shift(n)` method