bin/99_game in 99_game-2.0.2 vs bin/99_game in 99_game-2.0.3.pre.68
- old
+ new
@@ -1,94 +1,93 @@
-#!/usr/bin/env ruby
-require '99_game'
-deck = Deck.new
-BEGIN { # Looks at its arguements
- ARGV[0] = "-h" if ARGV[0] == "--help"
- ARGV[0] = "-v" if ARGV[0] == "--version"
- case ARGV[0]
- when "-v"
- puts "2.0.1"
- exit
- when "-h"
- puts "\u00B7 Commands"
- puts "\t\u00b7 -v/--version - display version"
- puts "\t\u00B7 -h/--help - shows this message\n"
- puts "\u00B7 Abbrevations"
- puts "\t\u00B7 J -> Jack"
- puts "\t\u00b7 Q -> Queen"
- puts "\t\u00b7 K -> King"
- puts "\t\u00b7 A -> Ace"
- puts "\t\u00b7 $ -> Joker"
- puts "\u00B7 Gameplay"
- puts "\t\u00B7 Your goal is to get your opponent to bring the value over 99 by playing 1 of your 3 cards."
- puts "\t\u00B7 A card will usually increase the value by itself, but there are a few exceptions:"
- puts "\t\t\u00B7 Aces are worth 1"
- puts "\t\t\u00B7 1 - 10 are worth themselves, with the exception of 4 and 9"
- puts "\t\t\u00B7 4, 9, and Jacks are worth 0"
- puts "\t\t\u00B7 Queens decrease the value by 10"
- puts "\t\t\u00B7 Kings set the value to 99"
- puts "\t\t\u00B7 Jokers set the value to 0"
- exit
- end
-}
-END { # Thanks for playing
- sleep(1.5)
- puts "\n\tThanks for playing 99!"
- sleep(2.5)
-}
-$value, value1, value2, value3, dealer, user = 0,0,0,0, Hand.new(deck), Hand.new(deck)
-loop do
- puts
- puts "\tIt is the dealer's turn!"
- i = 1
- for card in dealer.hand
- case i
- when 1 then test card, $value, value1
- when 2 then test card, $value, value2
- when 3 then test card, $value, value3
- end
- i += 1
- end
- if value1 >= value2 and value1 >= value3
- $card = dealer.hand[0].num
- dealer.play(dealer.hand[0])
- elsif value2 >= value3
- $card = dealer.hand[1].num
- dealer.play(dealer.hand[1])
- else
- $card = dealer.hand[2].num
- dealer.play(dealer.hand[2])
- end
- pause(1.5)
- puts "\tThe dealer played a(n) #{$card}"
- pause(0.5)
- puts "\tThe value is now #{$value}"
- puts
- pause(1.5)
- if $value > 99 # Runs when you win and exits loop
- puts "\tYou win!"
- break
- end
- puts "\tIt's your turn!"
- pause(1)
- user.view
- pause(0.5)
- print "\tPick a card to play by typing in the name of the card => "
- input, turn = gets.chomp, true
- for card in user.hand
- if card.num == converter(input) && turn
- user.play(card)
- turn = false
- end
- end
- pause(1)
- puts "\tYou drew a(n) #{user.hand[2].num}"
- pause(0.5)
- puts "\tThe value is now #{$value}"
- pause(1.5)
- if $value > 99 # Runs when dealer wins and exits loop
- puts "\tYou lose"
- break
- end
-end
-__END__
-Programmed by: Zachary Perlmutter
+#!/usr/bin/env ruby
+require '99_game'
+deck = Deck.new
+BEGIN { # Looks at its arguements
+ ARGV[0] = "-h" if ARGV[0] == "--help"
+ ARGV[0] = "-v" if ARGV[0] == "--version"
+ case ARGV[0]
+ when "-v"
+ puts "2.0.1"
+ exit
+ when "-h"
+ puts "\u00B7 Commands"
+ puts "\t\u00b7 -v/--version - display version"
+ puts "\t\u00B7 -h/--help - shows this message\n"
+ puts "\u00B7 Abbrevations"
+ puts "\t\u00B7 J -> Jack"
+ puts "\t\u00b7 Q -> Queen"
+ puts "\t\u00b7 K -> King"
+ puts "\t\u00b7 A -> Ace"
+ puts "\t\u00b7 $ -> Joker"
+ puts "\u00B7 Gameplay"
+ puts "\t\u00B7 Your goal is to get your opponent to bring the value over 99 by playing 1 of your 3 cards."
+ puts "\t\u00B7 A card will usually increase the value by itself, but there are a few exceptions:"
+ puts "\t\t\u00B7 Aces are worth 1"
+ puts "\t\t\u00B7 1 - 10 are worth themselves, with the exception of 4 and 9"
+ puts "\t\t\u00B7 4, 9, and Jacks are worth 0"
+ puts "\t\t\u00B7 Queens decrease the value by 10"
+ puts "\t\t\u00B7 Kings set the value to 99"
+ puts "\t\t\u00B7 Jokers set the value to 0"
+ exit
+ end
+}
+END { # Thanks for playing
+ sleep(1.5)
+ puts "\n\tThanks for playing 99!"
+ sleep(2.5)
+}
+$value, value1, value2, value3, dealer, user = 0,0,0,0, Hand.new(deck), Hand.new(deck)
+loop do
+ puts "\n\tIt is the dealer's turn!"
+ i = 1
+ for card in dealer.hand
+ case i
+ when 1 then test card, $value, value1
+ when 2 then test card, $value, value2
+ when 3 then test card, $value, value3
+ end
+ i += 1
+ end
+ if value1 >= value2 && value1 >= value3
+ $card = dealer.hand[0].num
+ dealer.play dealer.hand[0]
+ elsif value1 <= value2 && value2 >= value3
+ $card = dealer.hand[1].num
+ dealer.play dealer.hand[1]
+ else
+ $card = dealer.hand[2].num
+ dealer.play(dealer.hand[2])
+ end
+ pause(1.5)
+ puts "\tThe dealer played a(n) #{$card}"
+ pause(0.5)
+ puts "\tThe value is now #{$value}"
+ puts
+ pause(1.5)
+ if $value > 99 # Runs when you win and exits loop
+ puts "\tYou win!"
+ break
+ end
+ puts "\tIt's your turn!"
+ pause 1
+ user.view
+ pause 0.5
+ print "\tPick a card to play by typing in the name of the card => "
+ input, turn = gets.chomp, true
+ for card in user.hand
+ if card.num == converter(input) && turn
+ user.play(card)
+ turn = false
+ end
+ end
+ pause 1
+ puts "\tYou drew a(n) #{user.hand[2].num}"
+ pause(0.5)
+ puts "\tThe value is now #{$value}"
+ pause(1.5)
+ if $value > 99 # Runs when dealer wins and exits loop
+ puts "\tYou lose"
+ break
+ end
+end
+__END__
+Programmed by: Zachary Perlmutter