diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..4ae26d2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,9 @@ +source 'https://rubygems.org' +gem 'sinatra' +# Note: ERB is native to Ruby so doesn't need to be installed + +# only run this in the "development" environment +group :development do + gem 'pry-byebug' # for debugging + gem 'shotgun' +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0eafa16 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,35 @@ +GEM + remote: https://rubygems.org/ + specs: + byebug (9.0.5) + coderay (1.1.1) + method_source (0.8.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.0) + byebug (~> 9.0) + pry (~> 0.10) + rack (1.6.4) + rack-protection (1.5.3) + rack + shotgun (0.9.1) + rack (>= 1.0) + sinatra (1.4.7) + rack (~> 1.5) + rack-protection (~> 1.4) + tilt (>= 1.3, < 3) + slop (3.6.0) + tilt (2.0.5) + +PLATFORMS + ruby + +DEPENDENCIES + pry-byebug + shotgun + sinatra + +BUNDLED WITH + 1.12.5 diff --git a/README.md b/README.md index 3f18110..cc20cbc 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,6 @@ Hit me baby one more time? [A Blackjack game using the Ruby Sinatra web application framework which uses object oriented programming, cookies, sessions, and JSON from the Viking Code School](http://www.vikingcodeschool.com) + +# animated gif +![blackjack](blackjack_animated.gif) diff --git a/app.rb b/app.rb new file mode 100644 index 0000000..d3e73d7 --- /dev/null +++ b/app.rb @@ -0,0 +1,60 @@ +require 'sinatra' +require 'erb' +require 'pry-byebug' +require './helpers/deck_helpers.rb' +require './player.rb' +require './deck.rb' +helpers DeckHelper +enable :sessions + +get '/' do + reset_bankroll + erb :home +end + +get '/bet' do + erb :bet +end + +post '/bet' do + if valid_bet(params[:bet].to_i) + set_player_bet(params[:bet].to_i) + create_deck(reset_bankroll: false) + if !player_blackjack && !dealer_blackjack + erb :blackjack + elsif player_blackjack && !dealer_blackjack + @blackjack = true + binding.pry + redirect "/blackjack/stay" + else + redirect "/blackjack/stay" + end + else + @error = "INSUFFICIENT_AMOUNT" + erb :bet + end +end + +post '/blackjack/hit' do + deal_player + if player_busted? || player_blackjack + redirect "/blackjack/stay" + else + erb :blackjack + end +end + +post '/blackjack/stay' do + if !player_busted? + while dealer_count < 17 + deal_dealer + end + end + redirect "/blackjack/stay" +end + +get '/blackjack/stay' do + @winner = compare_hands + @busted = busted_player + erb :gameover +end \ No newline at end of file diff --git a/blackjack_animated.gif b/blackjack_animated.gif new file mode 100644 index 0000000..ec69561 Binary files /dev/null and b/blackjack_animated.gif differ diff --git a/deck.rb b/deck.rb new file mode 100644 index 0000000..474b806 --- /dev/null +++ b/deck.rb @@ -0,0 +1,13 @@ +class Deck + + attr_reader :cards + def initialize(cards = nil) + suits = ['H', 'D', 'S', 'C'] + values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] + cards.nil? ? @cards = suits.product(values).shuffle! : @cards = cards + end + + def pop + cards.pop + end +end \ No newline at end of file diff --git a/helpers/deck_helpers.rb b/helpers/deck_helpers.rb new file mode 100644 index 0000000..3d93209 --- /dev/null +++ b/helpers/deck_helpers.rb @@ -0,0 +1,130 @@ +module DeckHelper + BLACKJACK_AMT = 21 + + def create_deck(params = {}) + @deck = Deck.new + @dealer = Player.new("Dealer", []) + @player = Player.new("Player", []) + session[:deck] = @deck.cards + session[:dealer_cards] = @dealer.hand + session[:player_cards] = @player.hand + session[:player_bankroll] = @player.bankroll if params[:reset_bankroll] + session[:blackjack_cards] = [['S', 'J'], ['S', 'A']] + 2.times { deal_dealer ; deal_player } + end + + def new_hand + @dealer = Player.new("Dealer", []) + @player = Player.new("Player", []) + session[:dealer_cards] = @dealer.hand + session[:player_cards] = @player.hand + 2.times { deal_dealer ; deal_player } + end + + def reset_bankroll + session[:player_bankroll] = Player.new("Player", []).bankroll + end + + def dealer_hand + Player.new("Dealer", session[:dealer_cards]).hand + end + + def player_hand + Player.new("Player", session[:player_cards]).hand + end + + def deal_dealer + session[:dealer_cards] << Deck.new(session[:deck]).pop + end + + def deal_player + session[:player_cards] << Deck.new(session[:deck]).pop + end + + def player_busted? + Player.new("Player", session[:player_cards]).busted? + end + + def dealer_busted? + Player.new("Dealer", session[:dealer_cards]).busted? + end + + def player_count + Player.new("Player", session[:player_cards]).calculate_total + end + + def dealer_count + Player.new("Dealer", session[:dealer_cards]).calculate_total + end + + def player_blackjack + Player.new("Player", session[:player_cards]).calculate_total == 21 + end + + def dealer_blackjack + Player.new("Player", session[:dealer_cards]).calculate_total == 21 + end + + def busted_player + return "Player" if player_busted? + return "Dealer" if dealer_busted? + end + + def set_player_bet(amount) + session[:player_bet] = amount + session[:player_bankroll] = session[:player_bankroll].to_i - amount.to_i + end + + def valid_bet(amount) + amount <= Player.new("Player", session[:player_cards]).bankroll + end + + def get_player_bet + session[:player_bet] + end + + def player_bankroll + session[:player_bankroll] + end + + def compare_hands + pl_cnt = player_count + dl_cnt = dealer_count + if pl_cnt > 21 + "Dealer" + elsif dl_cnt > 21 + session[:player_bankroll] += 2*session[:player_bet] + "Player" + elsif pl_cnt > dl_cnt + session[:player_bankroll] += 2*session[:player_bet] + session[:player_bankroll] += session[:player_bet] if player_blackjack + "Player" + elsif pl_cnt < dl_cnt + "Dealer" + else + session[:player_bankroll] += session[:player_bet] + nil + end + end + + def card_image(card) + suit = case card[0] + when 'H' then 'hearts' + when 'D' then 'diamonds' + when 'S' then 'spades' + when 'C' then 'clubs' + end + + value = card[1] + if ['J', 'Q', 'K', 'A'].include?(value) + value = case value + when 'J' then 'jack' + when 'Q' then 'queen' + when 'K' then 'king' + when 'A' then 'ace' + end + end + "" + end + +end \ No newline at end of file diff --git a/player.rb b/player.rb new file mode 100644 index 0000000..898da53 --- /dev/null +++ b/player.rb @@ -0,0 +1,41 @@ +require 'pry' +class Player + attr_accessor :name, :hand, :bankroll + def initialize(name, hand) + @name = name + @hand = hand + @bankroll = 1000 + end + + def bet(amount) + @bet = amount + end + + def deal(deck) + @hand << deck.pop + end + + def busted? + calculate_total > 21 + end + + def calculate_total + lcl_hand = hand + arr = lcl_hand.map{|e| e[1] } + total = 0 + arr.each do |value| + if value == "A" + total += 11 + elsif value.to_i == 0 # J, Q, K + total += 10 + else + total += value.to_i + end + end + #correct for Aces + arr.select{|e| e == "A"}.count.times do + total -= 10 if total > 21 + end + total + end +end \ No newline at end of file diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000..c7fcdbe Binary files /dev/null and b/public/icon.png differ diff --git a/public/images/cards/clubs_10.jpg b/public/images/cards/clubs_10.jpg new file mode 100644 index 0000000..347e768 Binary files /dev/null and b/public/images/cards/clubs_10.jpg differ diff --git a/public/images/cards/clubs_2.jpg b/public/images/cards/clubs_2.jpg new file mode 100644 index 0000000..e9f2975 Binary files /dev/null and b/public/images/cards/clubs_2.jpg differ diff --git a/public/images/cards/clubs_3.jpg b/public/images/cards/clubs_3.jpg new file mode 100644 index 0000000..a949e49 Binary files /dev/null and b/public/images/cards/clubs_3.jpg differ diff --git a/public/images/cards/clubs_4.jpg b/public/images/cards/clubs_4.jpg new file mode 100644 index 0000000..fbcab04 Binary files /dev/null and b/public/images/cards/clubs_4.jpg differ diff --git a/public/images/cards/clubs_5.jpg b/public/images/cards/clubs_5.jpg new file mode 100644 index 0000000..e34317b Binary files /dev/null and b/public/images/cards/clubs_5.jpg differ diff --git a/public/images/cards/clubs_6.jpg b/public/images/cards/clubs_6.jpg new file mode 100644 index 0000000..a6be2c5 Binary files /dev/null and b/public/images/cards/clubs_6.jpg differ diff --git a/public/images/cards/clubs_7.jpg b/public/images/cards/clubs_7.jpg new file mode 100644 index 0000000..fa51599 Binary files /dev/null and b/public/images/cards/clubs_7.jpg differ diff --git a/public/images/cards/clubs_8.jpg b/public/images/cards/clubs_8.jpg new file mode 100644 index 0000000..eccca62 Binary files /dev/null and b/public/images/cards/clubs_8.jpg differ diff --git a/public/images/cards/clubs_9.jpg b/public/images/cards/clubs_9.jpg new file mode 100644 index 0000000..be6f7eb Binary files /dev/null and b/public/images/cards/clubs_9.jpg differ diff --git a/public/images/cards/clubs_ace.jpg b/public/images/cards/clubs_ace.jpg new file mode 100644 index 0000000..1594e78 Binary files /dev/null and b/public/images/cards/clubs_ace.jpg differ diff --git a/public/images/cards/clubs_jack.jpg b/public/images/cards/clubs_jack.jpg new file mode 100644 index 0000000..71e480d Binary files /dev/null and b/public/images/cards/clubs_jack.jpg differ diff --git a/public/images/cards/clubs_king.jpg b/public/images/cards/clubs_king.jpg new file mode 100644 index 0000000..d1e2289 Binary files /dev/null and b/public/images/cards/clubs_king.jpg differ diff --git a/public/images/cards/clubs_queen.jpg b/public/images/cards/clubs_queen.jpg new file mode 100644 index 0000000..46f4629 Binary files /dev/null and b/public/images/cards/clubs_queen.jpg differ diff --git a/public/images/cards/cover.jpg b/public/images/cards/cover.jpg new file mode 100644 index 0000000..c0ea175 Binary files /dev/null and b/public/images/cards/cover.jpg differ diff --git a/public/images/cards/diamonds_10.jpg b/public/images/cards/diamonds_10.jpg new file mode 100644 index 0000000..d8ce40f Binary files /dev/null and b/public/images/cards/diamonds_10.jpg differ diff --git a/public/images/cards/diamonds_2.jpg b/public/images/cards/diamonds_2.jpg new file mode 100644 index 0000000..92c084e Binary files /dev/null and b/public/images/cards/diamonds_2.jpg differ diff --git a/public/images/cards/diamonds_3.jpg b/public/images/cards/diamonds_3.jpg new file mode 100644 index 0000000..20685f6 Binary files /dev/null and b/public/images/cards/diamonds_3.jpg differ diff --git a/public/images/cards/diamonds_4.jpg b/public/images/cards/diamonds_4.jpg new file mode 100644 index 0000000..c0a3af7 Binary files /dev/null and b/public/images/cards/diamonds_4.jpg differ diff --git a/public/images/cards/diamonds_5.jpg b/public/images/cards/diamonds_5.jpg new file mode 100644 index 0000000..bdf2ad2 Binary files /dev/null and b/public/images/cards/diamonds_5.jpg differ diff --git a/public/images/cards/diamonds_6.jpg b/public/images/cards/diamonds_6.jpg new file mode 100644 index 0000000..5308091 Binary files /dev/null and b/public/images/cards/diamonds_6.jpg differ diff --git a/public/images/cards/diamonds_7.jpg b/public/images/cards/diamonds_7.jpg new file mode 100644 index 0000000..8e06401 Binary files /dev/null and b/public/images/cards/diamonds_7.jpg differ diff --git a/public/images/cards/diamonds_8.jpg b/public/images/cards/diamonds_8.jpg new file mode 100644 index 0000000..cf82fb1 Binary files /dev/null and b/public/images/cards/diamonds_8.jpg differ diff --git a/public/images/cards/diamonds_9.jpg b/public/images/cards/diamonds_9.jpg new file mode 100644 index 0000000..a7511df Binary files /dev/null and b/public/images/cards/diamonds_9.jpg differ diff --git a/public/images/cards/diamonds_ace.jpg b/public/images/cards/diamonds_ace.jpg new file mode 100644 index 0000000..0e5a0e7 Binary files /dev/null and b/public/images/cards/diamonds_ace.jpg differ diff --git a/public/images/cards/diamonds_jack.jpg b/public/images/cards/diamonds_jack.jpg new file mode 100644 index 0000000..4cd02cd Binary files /dev/null and b/public/images/cards/diamonds_jack.jpg differ diff --git a/public/images/cards/diamonds_king.jpg b/public/images/cards/diamonds_king.jpg new file mode 100644 index 0000000..15d3dc8 Binary files /dev/null and b/public/images/cards/diamonds_king.jpg differ diff --git a/public/images/cards/diamonds_queen.jpg b/public/images/cards/diamonds_queen.jpg new file mode 100644 index 0000000..7225dd2 Binary files /dev/null and b/public/images/cards/diamonds_queen.jpg differ diff --git a/public/images/cards/hearts_10.jpg b/public/images/cards/hearts_10.jpg new file mode 100644 index 0000000..167fbd1 Binary files /dev/null and b/public/images/cards/hearts_10.jpg differ diff --git a/public/images/cards/hearts_2.jpg b/public/images/cards/hearts_2.jpg new file mode 100644 index 0000000..733b275 Binary files /dev/null and b/public/images/cards/hearts_2.jpg differ diff --git a/public/images/cards/hearts_3.jpg b/public/images/cards/hearts_3.jpg new file mode 100644 index 0000000..fafa5d3 Binary files /dev/null and b/public/images/cards/hearts_3.jpg differ diff --git a/public/images/cards/hearts_4.jpg b/public/images/cards/hearts_4.jpg new file mode 100644 index 0000000..31c004c Binary files /dev/null and b/public/images/cards/hearts_4.jpg differ diff --git a/public/images/cards/hearts_5.jpg b/public/images/cards/hearts_5.jpg new file mode 100644 index 0000000..923feb9 Binary files /dev/null and b/public/images/cards/hearts_5.jpg differ diff --git a/public/images/cards/hearts_6.jpg b/public/images/cards/hearts_6.jpg new file mode 100644 index 0000000..52603d9 Binary files /dev/null and b/public/images/cards/hearts_6.jpg differ diff --git a/public/images/cards/hearts_7.jpg b/public/images/cards/hearts_7.jpg new file mode 100644 index 0000000..c9c6e52 Binary files /dev/null and b/public/images/cards/hearts_7.jpg differ diff --git a/public/images/cards/hearts_8.jpg b/public/images/cards/hearts_8.jpg new file mode 100644 index 0000000..9dc292c Binary files /dev/null and b/public/images/cards/hearts_8.jpg differ diff --git a/public/images/cards/hearts_9.jpg b/public/images/cards/hearts_9.jpg new file mode 100644 index 0000000..5a4f136 Binary files /dev/null and b/public/images/cards/hearts_9.jpg differ diff --git a/public/images/cards/hearts_ace.jpg b/public/images/cards/hearts_ace.jpg new file mode 100644 index 0000000..b7b079d Binary files /dev/null and b/public/images/cards/hearts_ace.jpg differ diff --git a/public/images/cards/hearts_jack.jpg b/public/images/cards/hearts_jack.jpg new file mode 100644 index 0000000..7fec826 Binary files /dev/null and b/public/images/cards/hearts_jack.jpg differ diff --git a/public/images/cards/hearts_king.jpg b/public/images/cards/hearts_king.jpg new file mode 100644 index 0000000..3ad4730 Binary files /dev/null and b/public/images/cards/hearts_king.jpg differ diff --git a/public/images/cards/hearts_queen.jpg b/public/images/cards/hearts_queen.jpg new file mode 100644 index 0000000..cf9106e Binary files /dev/null and b/public/images/cards/hearts_queen.jpg differ diff --git a/public/images/cards/joker_black.jpg b/public/images/cards/joker_black.jpg new file mode 100644 index 0000000..c21f446 Binary files /dev/null and b/public/images/cards/joker_black.jpg differ diff --git a/public/images/cards/joker_red.jpg b/public/images/cards/joker_red.jpg new file mode 100644 index 0000000..e623559 Binary files /dev/null and b/public/images/cards/joker_red.jpg differ diff --git a/public/images/cards/spades_10.jpg b/public/images/cards/spades_10.jpg new file mode 100644 index 0000000..e6b6072 Binary files /dev/null and b/public/images/cards/spades_10.jpg differ diff --git a/public/images/cards/spades_2.jpg b/public/images/cards/spades_2.jpg new file mode 100644 index 0000000..2b1a422 Binary files /dev/null and b/public/images/cards/spades_2.jpg differ diff --git a/public/images/cards/spades_3.jpg b/public/images/cards/spades_3.jpg new file mode 100644 index 0000000..c77a521 Binary files /dev/null and b/public/images/cards/spades_3.jpg differ diff --git a/public/images/cards/spades_4.jpg b/public/images/cards/spades_4.jpg new file mode 100644 index 0000000..b40a7af Binary files /dev/null and b/public/images/cards/spades_4.jpg differ diff --git a/public/images/cards/spades_5.jpg b/public/images/cards/spades_5.jpg new file mode 100644 index 0000000..f9e1521 Binary files /dev/null and b/public/images/cards/spades_5.jpg differ diff --git a/public/images/cards/spades_6.jpg b/public/images/cards/spades_6.jpg new file mode 100644 index 0000000..cc5b5d3 Binary files /dev/null and b/public/images/cards/spades_6.jpg differ diff --git a/public/images/cards/spades_7.jpg b/public/images/cards/spades_7.jpg new file mode 100644 index 0000000..a839350 Binary files /dev/null and b/public/images/cards/spades_7.jpg differ diff --git a/public/images/cards/spades_8.jpg b/public/images/cards/spades_8.jpg new file mode 100644 index 0000000..f16c753 Binary files /dev/null and b/public/images/cards/spades_8.jpg differ diff --git a/public/images/cards/spades_9.jpg b/public/images/cards/spades_9.jpg new file mode 100644 index 0000000..74b0476 Binary files /dev/null and b/public/images/cards/spades_9.jpg differ diff --git a/public/images/cards/spades_ace.jpg b/public/images/cards/spades_ace.jpg new file mode 100644 index 0000000..4bf7c7c Binary files /dev/null and b/public/images/cards/spades_ace.jpg differ diff --git a/public/images/cards/spades_jack.jpg b/public/images/cards/spades_jack.jpg new file mode 100644 index 0000000..c5f7c89 Binary files /dev/null and b/public/images/cards/spades_jack.jpg differ diff --git a/public/images/cards/spades_king.jpg b/public/images/cards/spades_king.jpg new file mode 100644 index 0000000..fcfd737 Binary files /dev/null and b/public/images/cards/spades_king.jpg differ diff --git a/public/images/cards/spades_queen.jpg b/public/images/cards/spades_queen.jpg new file mode 100644 index 0000000..07e263f Binary files /dev/null and b/public/images/cards/spades_queen.jpg differ diff --git a/public/reset.css b/public/reset.css new file mode 100644 index 0000000..0d5510c --- /dev/null +++ b/public/reset.css @@ -0,0 +1,48 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + HTML5 display-role reset for older browsers +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..da320d3 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,32 @@ +body { + background-color: #ccc; + font-family: helvetica, Arial, sans-serif; +} +.my-navbar { + margin-bottom: 10px; +} +.icon { + width: 32px; + height: 32px; +} +nav p { + display: inline-block; + margin-top: 12px; + font-size: 18px; + font-weight: bold; +} +.brand { + margin-top: 8px; + padding-top: 0; +} +.right { + float: right; +} + +.bet-button { + margin-top: 10px; +} + +img.card_image { + margin: 0px 5px 5px 0px; +} \ No newline at end of file diff --git a/views/bet.erb b/views/bet.erb new file mode 100644 index 0000000..a2cf543 --- /dev/null +++ b/views/bet.erb @@ -0,0 +1,22 @@ +
+
+
+

Player's bankroll : $<%= player_bankroll %>

+ <% if @error == "INSUFFICIENT_AMOUNT" %> +

Bet amount must be less than or equal to the bankroll

+ <% end %> +
+

Enter Bet Amount


+
+ $ + + .00 +
+
+ +
+
+
+
+
+ diff --git a/views/blackjack.erb b/views/blackjack.erb new file mode 100644 index 0000000..b401693 --- /dev/null +++ b/views/blackjack.erb @@ -0,0 +1,28 @@ +
+
+
+

Dealer's hand

+ <% dealer_hand.each do |card| %> + <%= card_image(card) %> + <% end %> +

Dealer's current count : <%= dealer_count %>

+

Player's hand

+ <% player_hand.each do |card| %> + <%= card_image(card) %> + <% end %> +

Player's current count : <%= player_count %>

+
+
+ <% if !player_blackjack && !dealer_blackjack %> +

Player's Action

+
+ +
+
+ +
+ <% end %> +
+
+
+ diff --git a/views/gameover.erb b/views/gameover.erb new file mode 100644 index 0000000..f4cdf69 --- /dev/null +++ b/views/gameover.erb @@ -0,0 +1,33 @@ +
+
+
+

Dealer's hand

+ <% dealer_hand.each do |card| %> + <%= card_image(card) %> + <% end %> +

Dealer's current count : <%= dealer_count %>

+

Player's hand

+ <% player_hand.each do |card| %> + <%= card_image(card) %> + <% end %> +

Player's current count : <%= player_count %>

+
+
+ <%= erb :"shared/busted" %> + <% unless @winner.nil? %> + <% if @winner == "Player" %> +

Congratulations you won this round!

+ <% else %> +

Sorry Dealer won this round!

+ <% end %> + <% else %> +

This round is a tie!

+ <% end %> + <%= erb :"shared/player_amount" %> +
+
+
+ + + + diff --git a/views/home.erb b/views/home.erb new file mode 100644 index 0000000..15109cf --- /dev/null +++ b/views/home.erb @@ -0,0 +1,5 @@ +
+
+ Place your bet +
+
diff --git a/views/layout.erb b/views/layout.erb new file mode 100644 index 0000000..9343a5a --- /dev/null +++ b/views/layout.erb @@ -0,0 +1,23 @@ + + + + + + + Blackjack + + + + + + + + + + + <%= erb :"shared/navbar" %> + <%= yield %> + + + + \ No newline at end of file diff --git a/views/shared/blackjack.erb b/views/shared/blackjack.erb new file mode 100644 index 0000000..43a4c2a --- /dev/null +++ b/views/shared/blackjack.erb @@ -0,0 +1,6 @@ +<% if (!player_blackjack && dealer_blackjack) && + (player_blackjack && dealer_blackjack) %> +

player stays

+<% elsif player_blackjack && !dealer_blackjack %> +

Player hit blackjack

+<% end %> \ No newline at end of file diff --git a/views/shared/busted.erb b/views/shared/busted.erb new file mode 100644 index 0000000..d0e0d01 --- /dev/null +++ b/views/shared/busted.erb @@ -0,0 +1,3 @@ +<% if @busted %> +

<%= @busted.to_s %> got busted

+<% end %> diff --git a/views/shared/navbar.erb b/views/shared/navbar.erb new file mode 100644 index 0000000..22ea4e4 --- /dev/null +++ b/views/shared/navbar.erb @@ -0,0 +1,15 @@ + diff --git a/views/shared/player_amount.erb b/views/shared/player_amount.erb new file mode 100644 index 0000000..ef060fd --- /dev/null +++ b/views/shared/player_amount.erb @@ -0,0 +1,2 @@ +

Player's bankroll : <%= player_bankroll %>

+

Player's bet : <%= get_player_bet %>

\ No newline at end of file