blackjack1 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -1
  3. data/bin/blackjack1 +4 -11
  4. data/lib/hand.rb +5 -9
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTE0OTNjYWIzOTA0NDQzNWI2MjU4MDA1ZmQwZDMwZTMwNWI1ZjMzMQ==
4
+ MzcwNjYyOThmZDljYTU4OTk2ZTNkMDIyNWY1M2E5M2NkZGE2NzQ3OA==
5
5
  data.tar.gz: !binary |-
6
- NzMxOWViMDMzNzdkODJiZmQ5MGFhYTY4NTFjYmRiMGM5YmFiODcyMQ==
6
+ ZWExZWNlYmUzNDA0ZDkyOTNiOGNmYjY5NGNlN2Q2YzMwNDU2YThmNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWJiZDRlMWQ3MWFmODMwZjhhYjAyNTgxYzc5NmI3ODg0YWY1MDc5NGY1NTU4
10
- ZTM1OTFjNzEzZmE3M2IxYzkxOGE4ZGYwNmM5NGQ4OTg3YzY0Y2NhMGIzYTM1
11
- MWM0MGRiNDlmZWE4NTM4YThkMDlhMzcxZTFkZjQxMTdjMzg2MWU=
9
+ ZTg3MmMxZjAyNWY5Y2JmMjRlODYxMThlOTQ4M2IwMzdlZTczMTE4YzE1YWIz
10
+ MjlmZDkzMDNjZWQzN2YwOGJkZjk1MGNmNDkzMGIxMWM4NDcyZjYzYWRhMjQy
11
+ MGQ3NWIyN2VkZGJhYjdmZGZiNmIwNTdmM2YyMjZhZTUwMGI2NDI=
12
12
  data.tar.gz: !binary |-
13
- NmMzNGI4MmNmYjI4YjM5YzJiNjgxYjU5OTdjYjVkMmNlNWQzYzJkMmU4NjEy
14
- NTY3OTc1N2I3NjkyZDJjY2NjNjA5ZjAxODY4ODc2Mzg3MzIyMjczZWNkNzYz
15
- NzNkMjM5N2I5MWJjZDQzNjFjMTE3NjE0ZjY4YjdlMGIxZDY1OTM=
13
+ NmZiNTRkYzFjZjIzMmM3MjBiOGM5ZmRlOGU4NDc3MjRhYmRmMTY0MDdhYzhl
14
+ Mjc3MWQxNzdlODg4ODA1NjNmNjVjY2YwZjFkNGY3ZDQyZjgxMjZlZjNkY2M3
15
+ YjM5MThjZmE1ZTQ0ZWZjN2M3MmNlOGI5MWRiYjk3OTNlOTE4MjE=
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # blackjack
2
- The commonly played card game in casinos and for fun.
2
+ The commonly played card game in casinos and for fun. Have fun!
3
3
  ## Badges
4
4
  [![Build Status](https://travis-ci.org/Zrp200/blackjack1.svg?branch=master)](https://travis-ci.org/Zrp200/blackjack1)
5
5
  [![Code Climate](https://codeclimate.com/github/Zrp200/blackjack1/badges/gpa.svg)](https://codeclimate.com/github/Zrp200/blackjack1)
6
+ [![Test Coverage](https://codeclimate.com/github/Zrp200/blackjack1/badges/coverage.svg)](https://codeclimate.com/github/Zrp200/blackjack1)
data/bin/blackjack1 CHANGED
@@ -13,18 +13,11 @@ unless player.blackjack?
13
13
  sleep 1
14
14
  loop do
15
15
  puts
16
- catch inputerror do
17
- print "(h)it or (s)tay? "
18
- action = gets.chomp.downcase
19
- if action.include?("s") then break
20
- elsif !action.include?("h") then throw inputerror
21
- end
22
- end
23
- sleep(1)
24
- player.hit
25
16
  print view.call player
26
- sleep(1.5)
27
- break if player.value == 21
17
+ print "(h)it or (s)tay? "
18
+ action = gets.chomp.downcase
19
+ player.hit if action.include?("h")
20
+ break if action.include?("s") || player.value >= 21
28
21
  end
29
22
  puts ""
30
23
  unless player.bust?
data/lib/hand.rb CHANGED
@@ -2,20 +2,16 @@ require_relative "card.rb" rescue require "card_deck"
2
2
  class Hand # The player
3
3
  attr_accessor :cards # The cards in the hand
4
4
  MDHV = 16 # Maximum Dealer Hit Value; If the dealer's hand is valued more than this number, he will stay.
5
- def self.deck=(deck) # Set which deck the game is using. Also shuffles the deck.
6
- @@deck = deck.cards.shuffle
7
- end
8
- def self.deck # The deck the game is using
9
- @@deck
10
- end
5
+ def self.deck=(deck); @@deck = deck.cards.shuffle; end # Set which deck the game is using. Also shuffles the deck.
6
+
7
+
8
+ def self.deck; @@deck; end # The deck the game is using
11
9
  def bust?; value > 21; end # Returns true if the value is greater than 21.
12
10
  def blackjack?; value == 21 && @cards.length == 2; end # Returns true if you have blackjack.
13
11
  def initialize(cards=[@@deck.shift, @@deck.shift])
14
12
  @cards = cards
15
13
  end
16
- def view # The view of the cards
17
- @cards.each {|card| "#{card.abbr}\t"}
18
- end
14
+ def view; @cards.each {|card| "#{card.abbr}\t"}; end # The view of the cards
19
15
  def hit; @cards.push @@deck.shift; end # Add a card to @cards from @@deck
20
16
  def value # The value of the cards in @cards
21
17
  v, aces = 0, 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackjack1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Perlmutter