between_the_sheets 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +6 -0
- data/between_the_sheets-1.0.0.gem +0 -0
- data/between_the_sheets.gemspec +26 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/between_the_sheets +3 -0
- data/lib/between_the_sheets/application_exit.rb +4 -0
- data/lib/between_the_sheets/application_help.rb +4 -0
- data/lib/between_the_sheets/ask.rb +35 -0
- data/lib/between_the_sheets/card.rb +78 -0
- data/lib/between_the_sheets/game/constants.rb +11 -0
- data/lib/between_the_sheets/game/messages.rb +54 -0
- data/lib/between_the_sheets/game/rules/bust/consecutive.rb +10 -0
- data/lib/between_the_sheets/game/rules/bust/joker.rb +10 -0
- data/lib/between_the_sheets/game/rules/win/joker.rb +10 -0
- data/lib/between_the_sheets/game/rules/win/same_cards.rb +10 -0
- data/lib/between_the_sheets/game/screens.rb +26 -0
- data/lib/between_the_sheets/game.rb +130 -0
- data/lib/between_the_sheets/game_over.rb +4 -0
- data/lib/between_the_sheets/rules/bust/consecutive.rb +6 -0
- data/lib/between_the_sheets/rules/bust/joker.rb +6 -0
- data/lib/between_the_sheets/rules/win/joker.rb +6 -0
- data/lib/between_the_sheets/rules/win/same_cards.rb +6 -0
- data/lib/between_the_sheets/version.rb +3 -0
- data/lib/between_the_sheets/wager.rb +17 -0
- data/lib/between_the_sheets.rb +33 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e1e5acfbe2a02afc110fe4bcc60ba8bc65bfee7
|
4
|
+
data.tar.gz: f2ede03c1027ebba6e458aab5f28e2c3f982c295
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 372e18fee3fe134464159a0b367b7c3f56b4e48c30416ebb4a8b8ef5570969a2910e0b3d8dd63386957d28e92629d734d4936c5f0f2fd557f0264f1559af0616
|
7
|
+
data.tar.gz: 2af07db56f0981cfaa5152cf229dd020b70af35a829f51513dd081c08fa2f103e7323cb3aa43045eb3270e55f1a6658ad6c1b7282520827628adbfea0a36bd2e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Chris Roerig
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# BetweenTheSheets
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
$ gem install between_the_sheets
|
6
|
+
$ between_the_sheets
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
```
|
11
|
+
KEY COMMANDS:
|
12
|
+
|
13
|
+
e or q at any prompt will quit the game.
|
14
|
+
h or help prints the message.
|
15
|
+
|
16
|
+
GAME RULES:
|
17
|
+
|
18
|
+
The dealer draws 2 cards and places them face up. Next, the player may
|
19
|
+
bet up to the entire pot or any portion of the number of chips in the
|
20
|
+
pot, but he must always bet a minimum of #{Game::Constants::MINIMUM_BET}
|
21
|
+
chip. When the player has placed a bet, the dealer turns up the top card
|
22
|
+
from the pack and places it between the two cards already face up.
|
23
|
+
If the card ranks between the two cards already face up, the player
|
24
|
+
wins and takes back the amount of his bet plus an equivalent amount
|
25
|
+
from the pot. If the third card is not between the face-up cards, or
|
26
|
+
is of the same rank as either of them, the player loses his bet, and
|
27
|
+
it is added to the pot. If the two face-up cards up are consecutive,
|
28
|
+
the player automatically loses, and a third card need not be turned up.
|
29
|
+
If the two face-up cards are the same, the player wins two chips and,
|
30
|
+
again, no third card is turned up.
|
31
|
+
|
32
|
+
"Acey-Deucey" (ace, 2) is the best combination, and a player tends to
|
33
|
+
bet the whole pot, if he can. This is because the only way an
|
34
|
+
ace-deuce combination can lose is if the third card turned up is also
|
35
|
+
an ace or a deuce.
|
36
|
+
|
37
|
+
Game rules taken and slightly modified from:
|
38
|
+
http://www.bicyclecards.com/how-to-play/in-between/#sthash.aJuEouh8.dpuf
|
39
|
+
```
|
40
|
+
|
41
|
+
## Development
|
42
|
+
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec between_the_sheets` to use the gem in this directory, ignoring other installed copies of this gem.
|
44
|
+
|
45
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chris-roerig/between_the_sheets.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'between_the_sheets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "between_the_sheets"
|
8
|
+
spec.version = BetweenTheSheets::VERSION
|
9
|
+
spec.authors = ["Chris Roerig"]
|
10
|
+
spec.email = ["idwyjm@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A simple card game I used to play at the bar.}
|
13
|
+
spec.description = %q{The player is shown 2 cards and then wagers if the next card will be between them. }
|
14
|
+
spec.homepage = "https://github.com/chris-roerig/between_the_sheets"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "colorize", "~> 0"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "between_the_sheets"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module BetweenTheSheets
|
2
|
+
class Ask
|
3
|
+
def self.print(output = "", options = {})
|
4
|
+
$stdout.print output
|
5
|
+
prompt(options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.puts(output = "", options = {})
|
9
|
+
$stdout.puts output
|
10
|
+
prompt(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.prompt(options = {})
|
14
|
+
options = { to_int: false, match: nil }.merge(options)
|
15
|
+
match = options[:match]
|
16
|
+
|
17
|
+
input = gets.chomp.downcase
|
18
|
+
raise ApplicationExit if input.match(/^q|quit|^e|exit/)
|
19
|
+
raise ApplicationHelp if input.match(/^h|help/)
|
20
|
+
|
21
|
+
if match && input.match(match).to_s.empty?
|
22
|
+
input = loop do
|
23
|
+
try = self.print("Invalid response. Choices are: " + match.to_s.gsub("?-mix:", "") + " ")
|
24
|
+
break try if try.match(match)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if options[:to_int]
|
29
|
+
input.gsub(/\D/, "").to_i
|
30
|
+
else
|
31
|
+
input
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "digest"
|
2
|
+
|
3
|
+
module BetweenTheSheets
|
4
|
+
class CardImage
|
5
|
+
#🂡 🂢 🂣 🂤 🂥 🂦 🂧 🂨 🂩 🂪 🂫 🂬 🂭 🂮
|
6
|
+
#🂱 🂲 🂳 🂴 🂵 🂶 🂷 🂸 🂹 🂺 🂻 🂼 🂽 🂾
|
7
|
+
#🃁 🃂 🃃 🃄 🃅 🃆 🃇 🃈 🃉 🃊 🃋 🃌 🃍 🃎
|
8
|
+
#🃑 🃒 🃓 🃔 🃕 🃖 🃗 🃘 🃙 🃚 🃛 🃜 🃝 🃞
|
9
|
+
#🃟
|
10
|
+
#🂠
|
11
|
+
end
|
12
|
+
|
13
|
+
class Card
|
14
|
+
NAMES = %w{A 2 3 4 5 6 7 8 9 10 J Q K JOKER}.freeze
|
15
|
+
SUITS = %w{clubs diamonds hearts spades}.freeze
|
16
|
+
SUIT_COLORS = {
|
17
|
+
clubs: :white,
|
18
|
+
diamonds: :red,
|
19
|
+
hearts: :red,
|
20
|
+
spades: :white
|
21
|
+
}.freeze
|
22
|
+
IMAGES = {
|
23
|
+
clubs: "\u2664",
|
24
|
+
hearts: "\u2661",
|
25
|
+
diamonds: "\u2662",
|
26
|
+
spades: "\u2667"
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
attr_reader :name, :suit, :value
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@name = NAMES.sample
|
33
|
+
@suit = SUITS.sample
|
34
|
+
@image = IMAGES[@suit.to_sym]
|
35
|
+
@value = self.class.value(@name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.draw(*skip_cards)
|
39
|
+
return Card.new if skip_cards.empty?
|
40
|
+
|
41
|
+
loop do
|
42
|
+
card = Card.new
|
43
|
+
break card unless skip_cards.include? card.id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.value(name)
|
48
|
+
case name
|
49
|
+
when "A"
|
50
|
+
1
|
51
|
+
when "J"
|
52
|
+
11
|
53
|
+
when "Q"
|
54
|
+
12
|
55
|
+
when "K"
|
56
|
+
13
|
57
|
+
when "JOKER"
|
58
|
+
0
|
59
|
+
else
|
60
|
+
NAMES.index(name) + 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_s
|
65
|
+
# The space at the end is intentional to pad the image with the
|
66
|
+
# next character.
|
67
|
+
"#{@name}#{@image.colorize(SUIT_COLORS[@suit.to_sym])} "
|
68
|
+
end
|
69
|
+
|
70
|
+
def id
|
71
|
+
(Digest::MD5.new << self.to_s).to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def joker?
|
75
|
+
@name == "JOKER"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module BetweenTheSheets
|
2
|
+
class Game
|
3
|
+
module Messages
|
4
|
+
MESSAGES = {
|
5
|
+
error: "Sorry, there was an error.".colorize(:orange),
|
6
|
+
exit: "Good bye.",
|
7
|
+
game_over: "GAME OVER".colorize(:red),
|
8
|
+
lose: "You LOSE!".colorize(:red),
|
9
|
+
win: "You WIN!".colorize(:green),
|
10
|
+
jackpot: "JACKPOT!".colorize(:green),
|
11
|
+
banner: "\n\n \u2664 \u2661 BETWEEN THE SHEETS \u2662 \u2667\n\n"
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
def message(name)
|
15
|
+
MESSAGES.fetch(name) { help }
|
16
|
+
end
|
17
|
+
|
18
|
+
def help
|
19
|
+
<<-TXT
|
20
|
+
|
21
|
+
KEY COMMANDS:
|
22
|
+
|
23
|
+
e or q at any prompt will quit the game.
|
24
|
+
h or help prints the message.
|
25
|
+
|
26
|
+
GAME RULES:
|
27
|
+
|
28
|
+
The dealer draws 2 cards and places them face up. Next, the player may
|
29
|
+
bet up to the entire pot or any portion of the number of chips in the
|
30
|
+
pot, but he must always bet a minimum of #{Game::Constants::MINIMUM_BET}
|
31
|
+
chip. When the player has placed a bet, the dealer turns up the top card
|
32
|
+
from the pack and places it between the two cards already face up.
|
33
|
+
If the card ranks between the two cards already face up, the player
|
34
|
+
wins and takes back the amount of his bet plus an equivalent amount
|
35
|
+
from the pot. If the third card is not between the face-up cards, or
|
36
|
+
is of the same rank as either of them, the player loses his bet, and
|
37
|
+
it is added to the pot. If the two face-up cards up are consecutive,
|
38
|
+
the player automatically loses, and a third card need not be turned up.
|
39
|
+
If the two face-up cards are the same, the player wins two chips and,
|
40
|
+
again, no third card is turned up.
|
41
|
+
|
42
|
+
"Acey-Deucey" (ace, 2) is the best combination, and a player tends to
|
43
|
+
bet the whole pot, if he can. This is because the only way an
|
44
|
+
ace-deuce combination can lose is if the third card turned up is also
|
45
|
+
an ace or a deuce.
|
46
|
+
|
47
|
+
Game rules taken and slightly modified from:
|
48
|
+
http://www.bicyclecards.com/how-to-play/in-between/#sthash.aJuEouh8.dpuf
|
49
|
+
|
50
|
+
TXT
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BetweenTheSheets
|
2
|
+
class Game
|
3
|
+
module Screens
|
4
|
+
def intro_screen
|
5
|
+
if @credits <= Game::ANTE
|
6
|
+
puts "You're out of credits."
|
7
|
+
raise GameOver
|
8
|
+
end
|
9
|
+
|
10
|
+
puts Game.message :banner
|
11
|
+
|
12
|
+
puts "Round: #{@rounds} | Jackpot: #{@jackpot} | Ante: #{Game::ANTE} | Credits: #{@credits.to_s.colorize(:green)}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def is_between_screen
|
16
|
+
@play = Ask.print "Is the next card between #{@card1} and #{@card2}? ",
|
17
|
+
match: /y|n/
|
18
|
+
end
|
19
|
+
|
20
|
+
def transition_screen
|
21
|
+
Ask.print "Hit enter to deal again. "
|
22
|
+
system ( Gem.win_platform? ? "cls" : "clear" )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "between_the_sheets/game/constants"
|
2
|
+
require "between_the_sheets/game/messages"
|
3
|
+
require "between_the_sheets/game/screens"
|
4
|
+
require "between_the_sheets/game/rules/bust/consecutive"
|
5
|
+
require "between_the_sheets/game/rules/bust/joker"
|
6
|
+
require "between_the_sheets/game/rules/win/joker"
|
7
|
+
require "between_the_sheets/game/rules/win/same_cards"
|
8
|
+
|
9
|
+
module BetweenTheSheets
|
10
|
+
class Game
|
11
|
+
include Constants
|
12
|
+
include Screens
|
13
|
+
extend Messages
|
14
|
+
|
15
|
+
attr_reader :card1, :card2, :card3, :jackpot, :play
|
16
|
+
|
17
|
+
def initialize(jackpot = STARTING_JACKPOT)
|
18
|
+
@rounds = 1
|
19
|
+
@credits = STARTING_CREDITS
|
20
|
+
@jackpot = jackpot
|
21
|
+
end
|
22
|
+
|
23
|
+
# Loads the first 2 cards and checks rules.
|
24
|
+
def draw_initial_cards
|
25
|
+
@card1 = Card.draw
|
26
|
+
@card2 = Card.draw(@card1.id)
|
27
|
+
|
28
|
+
# check for joker
|
29
|
+
raise Rules::Bust::Joker if @card1.joker? || @card2.joker?
|
30
|
+
|
31
|
+
# check for consecutive
|
32
|
+
raise Rules::Bust::Consecutive if (@card1.value - @card2.value).abs == 1
|
33
|
+
|
34
|
+
# player wins if the cards are the same
|
35
|
+
raise Rules::Win::SameCards if @card1.value == @card2.value
|
36
|
+
end
|
37
|
+
|
38
|
+
# Loads the 3rd card and checks for rules.
|
39
|
+
def draw_final_card
|
40
|
+
@card3 = Card.draw(@card1.id, @card2.id)
|
41
|
+
puts "The next card is the #{@card3}"
|
42
|
+
|
43
|
+
# player wins if card is Joker
|
44
|
+
raise Rules::Win::Joker if @card3.joker?
|
45
|
+
end
|
46
|
+
|
47
|
+
# Bool whether card 3 is between cards 1 & 2
|
48
|
+
def is_between?
|
49
|
+
is_between = @card3.value.between?(@card1.value, @card2.value)
|
50
|
+
|
51
|
+
is_between && @play == "y" || !is_between && @play == "n"
|
52
|
+
end
|
53
|
+
|
54
|
+
# Prints the win message and increments the players credits.
|
55
|
+
def win(credits=nil)
|
56
|
+
@credits += credits if credits
|
57
|
+
puts self.class.message(:win).colorize :green
|
58
|
+
end
|
59
|
+
|
60
|
+
# Prints the jackpot message and increments the players credits.
|
61
|
+
def win_jackpot
|
62
|
+
@credits += @jackpot
|
63
|
+
@jackpot = STARTING_JACKPOT
|
64
|
+
puts self.class.message(:jackpot).colorize :green
|
65
|
+
end
|
66
|
+
|
67
|
+
# Prints the lost message and decrements the players credits.
|
68
|
+
def lose(credits=nil)
|
69
|
+
@credits -= credits if credits
|
70
|
+
puts self.class.message(:lose).colorize :red
|
71
|
+
end
|
72
|
+
|
73
|
+
# The main game loop.
|
74
|
+
def execute
|
75
|
+
loop do
|
76
|
+
transition_screen if @rounds > 1
|
77
|
+
|
78
|
+
# Show the intro screen
|
79
|
+
intro_screen
|
80
|
+
|
81
|
+
@rounds += 1
|
82
|
+
@credits -= ANTE
|
83
|
+
@jackpot += JACKPOT_ANTE
|
84
|
+
|
85
|
+
puts "\nAfter ante you have #{@credits.to_s.colorize(:green)} credits"
|
86
|
+
|
87
|
+
continue = begin
|
88
|
+
draw_initial_cards
|
89
|
+
rescue Rules::Bust::Joker
|
90
|
+
puts "House drew a Joker "
|
91
|
+
lose
|
92
|
+
rescue Rules::Bust::Consecutive
|
93
|
+
puts "House drew consecutive cards #{@card1} & #{@card2} "
|
94
|
+
lose
|
95
|
+
rescue Rules::Win::SameCards
|
96
|
+
puts "House drew #{@card1} and #{@card2} "
|
97
|
+
win_jackpot
|
98
|
+
else
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
next unless !!continue
|
103
|
+
|
104
|
+
# Ask player if next card is between
|
105
|
+
is_between_screen
|
106
|
+
|
107
|
+
# Ask player for their wager
|
108
|
+
wager = Wager.get(@credits, @jackpot)
|
109
|
+
|
110
|
+
continue = begin
|
111
|
+
draw_final_card
|
112
|
+
rescue Rules::Win::Joker
|
113
|
+
puts "You drew a #{@card3}"
|
114
|
+
win wager
|
115
|
+
else
|
116
|
+
true
|
117
|
+
end
|
118
|
+
|
119
|
+
next unless !!continue
|
120
|
+
|
121
|
+
# check the between rules
|
122
|
+
if is_between?
|
123
|
+
win wager
|
124
|
+
else
|
125
|
+
lose wager
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetweenTheSheets
|
2
|
+
class Wager
|
3
|
+
def self.get(credits, pot)
|
4
|
+
loop do
|
5
|
+
input = Ask.print "What's your wager? ", to_int: true
|
6
|
+
|
7
|
+
if input > pot
|
8
|
+
puts "Invalid amount. You can't bet more than the pot (#{pot})"
|
9
|
+
next
|
10
|
+
end
|
11
|
+
|
12
|
+
break input if input > 0 && input <= credits
|
13
|
+
puts "Invalid amount. You have #{credits} credits."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "pry"
|
2
|
+
require "colorize"
|
3
|
+
require_relative "between_the_sheets/application_exit"
|
4
|
+
require_relative "between_the_sheets/application_help"
|
5
|
+
require_relative "between_the_sheets/ask"
|
6
|
+
require_relative "between_the_sheets/card"
|
7
|
+
require_relative "between_the_sheets/game"
|
8
|
+
require_relative "between_the_sheets/game_over"
|
9
|
+
require_relative "between_the_sheets/wager"
|
10
|
+
require_relative "between_the_sheets/version"
|
11
|
+
|
12
|
+
module BetweenTheSheets
|
13
|
+
loop do
|
14
|
+
begin
|
15
|
+
@game = Game.new(@jackpot || Game::STARTING_JACKPOT)
|
16
|
+
@game.execute
|
17
|
+
rescue GameOver
|
18
|
+
@jackpot = @game.jackpot
|
19
|
+
puts Game.message :game_over
|
20
|
+
next if Ask.print("Play again? ", match: /y|n/) == "y"
|
21
|
+
rescue ApplicationHelp
|
22
|
+
puts Game.message :help
|
23
|
+
rescue ApplicationExit
|
24
|
+
puts Game.message :exit
|
25
|
+
break
|
26
|
+
rescue => e
|
27
|
+
# TODO log e.message
|
28
|
+
puts Game.message :error
|
29
|
+
puts e.message
|
30
|
+
break
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: between_the_sheets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Roerig
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: 'The player is shown 2 cards and then wagers if the next card will be
|
70
|
+
between them. '
|
71
|
+
email:
|
72
|
+
- idwyjm@gmail.com
|
73
|
+
executables:
|
74
|
+
- between_the_sheets
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- between_the_sheets-1.0.0.gem
|
86
|
+
- between_the_sheets.gemspec
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- exe/between_the_sheets
|
90
|
+
- lib/between_the_sheets.rb
|
91
|
+
- lib/between_the_sheets/application_exit.rb
|
92
|
+
- lib/between_the_sheets/application_help.rb
|
93
|
+
- lib/between_the_sheets/ask.rb
|
94
|
+
- lib/between_the_sheets/card.rb
|
95
|
+
- lib/between_the_sheets/game.rb
|
96
|
+
- lib/between_the_sheets/game/constants.rb
|
97
|
+
- lib/between_the_sheets/game/messages.rb
|
98
|
+
- lib/between_the_sheets/game/rules/bust/consecutive.rb
|
99
|
+
- lib/between_the_sheets/game/rules/bust/joker.rb
|
100
|
+
- lib/between_the_sheets/game/rules/win/joker.rb
|
101
|
+
- lib/between_the_sheets/game/rules/win/same_cards.rb
|
102
|
+
- lib/between_the_sheets/game/screens.rb
|
103
|
+
- lib/between_the_sheets/game_over.rb
|
104
|
+
- lib/between_the_sheets/rules/bust/consecutive.rb
|
105
|
+
- lib/between_the_sheets/rules/bust/joker.rb
|
106
|
+
- lib/between_the_sheets/rules/win/joker.rb
|
107
|
+
- lib/between_the_sheets/rules/win/same_cards.rb
|
108
|
+
- lib/between_the_sheets/version.rb
|
109
|
+
- lib/between_the_sheets/wager.rb
|
110
|
+
homepage: https://github.com/chris-roerig/between_the_sheets
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.4.3
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: A simple card game I used to play at the bar.
|
134
|
+
test_files: []
|