brigitte 0.1.4 → 0.1.5
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 +4 -4
- data/.github/workflows/ruby.yml +2 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +25 -0
- data/lib/brigitte/game.rb +4 -4
- data/lib/brigitte/player.rb +10 -10
- data/lib/brigitte/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2639c1b8f96714b341bd58a912330a2a13c56fd7398b25a2335c9698533263d6
|
|
4
|
+
data.tar.gz: d8c9fe893c4ca56f4ec212f24c275132b95ff90ff3bffdfe8645896025607b35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc72233255acdc7757df5f08af1d4c3209cc9ebd9d45e756258ced1190ef4df12776d8cf582c35f2ee7bdc1c07991691090a367e897080fb82d2d12efc7a2f2d
|
|
7
|
+
data.tar.gz: e6eec0b563287f02ad81184fa1d8c3f090a3b9c6e7f0a5d58ec8f75b11d9084fbc12c244d7d4a09ff3f46fa4bb5ccedbe44941ec4af68b2e5c62e07bb535616a
|
data/.github/workflows/ruby.yml
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.7.2
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -4,6 +4,31 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
|
|
|
4
4
|
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
|
7
|
+
## Game rules
|
|
8
|
+
Card game against max 4 players where you need to get rid of your cards as soon as possible.
|
|
9
|
+
|
|
10
|
+
### Game steps
|
|
11
|
+
1) You have a chance to swap the any cards in your hand with your cards that lays on the table.
|
|
12
|
+
Usually you put up your best card on table. So you can move on fast to your blind cards behind it.
|
|
13
|
+
When you have swapped your cards you push ready. When everyone is ready. The game starts with the player with the lowest card in hand.
|
|
14
|
+
Turn runs clockwise.
|
|
15
|
+
|
|
16
|
+
2) In this phase a hand should always have minimum 3 cards when there is still cards on the deck. When you hand has less cards there will be cards automatically added in your hand from the deck.
|
|
17
|
+
Everybody plays untill the deck and hands are empty.
|
|
18
|
+
|
|
19
|
+
3) The visible cards are taken into your hand. Now you play your hand untill it's empty.
|
|
20
|
+
|
|
21
|
+
4) You take one blind card when it's your turn. When you clear all the blind cards you won the game.
|
|
22
|
+
|
|
23
|
+
### Special cards
|
|
24
|
+
Usually you put an equal card or higher on the pile.
|
|
25
|
+
Except if 7 is on top of the pile. Then you can only put cards lower or equal to 7.
|
|
26
|
+
There are other special cards
|
|
27
|
+
10 clears the pile and you stay in turn. You can always throw 10
|
|
28
|
+
It has the same effect if there are 4 consecutive equal cards on the pile.
|
|
29
|
+
You can always throw 2.
|
|
30
|
+
Ace is the highest Card.
|
|
31
|
+
|
|
7
32
|
## Installation
|
|
8
33
|
|
|
9
34
|
Add this line to your application's Gemfile:
|
data/lib/brigitte/game.rb
CHANGED
|
@@ -93,13 +93,13 @@ module Brigitte
|
|
|
93
93
|
select_next_player(force: true) unless @game_over
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
def
|
|
96
|
+
def take_blind_card(player, blind_card_index)
|
|
97
97
|
return false if player != @current_player
|
|
98
98
|
return false if @cards.any?
|
|
99
99
|
return false if player.visible_cards.any?
|
|
100
100
|
return false if player.hand.any?
|
|
101
101
|
|
|
102
|
-
player.
|
|
102
|
+
player.pull_blind_card(blind_card_index)
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def to_h
|
|
@@ -131,7 +131,7 @@ module Brigitte
|
|
|
131
131
|
|
|
132
132
|
def deal_cards
|
|
133
133
|
@active_players.each do |player|
|
|
134
|
-
3.times { player.
|
|
134
|
+
3.times { player.blind_cards << @cards.pop }
|
|
135
135
|
3.times { player.visible_cards << @cards.pop }
|
|
136
136
|
3.times { player.hand << @cards.pop }
|
|
137
137
|
end
|
|
@@ -167,7 +167,7 @@ module Brigitte
|
|
|
167
167
|
|
|
168
168
|
def player_won(player)
|
|
169
169
|
return if @winners.include? player
|
|
170
|
-
return if player.
|
|
170
|
+
return if player.blind_cards.compact.any?
|
|
171
171
|
return if player.hand.any?
|
|
172
172
|
|
|
173
173
|
@winners << player
|
data/lib/brigitte/player.rb
CHANGED
|
@@ -7,20 +7,20 @@ module Brigitte
|
|
|
7
7
|
# A Player in Brigitte has a:
|
|
8
8
|
# +hand+ where from player can only throw cards from
|
|
9
9
|
# +visible_cards+ where from player can draw from if hands are empty
|
|
10
|
-
# +
|
|
10
|
+
# +blind_cards+ cards that are face down where from player can take only one
|
|
11
11
|
# if all cards are played
|
|
12
12
|
#
|
|
13
13
|
# A player is ready if cards are swapped between it's +hand+
|
|
14
14
|
# and +visible_cards+
|
|
15
15
|
class Player
|
|
16
|
-
attr_accessor :name, :hand, :
|
|
16
|
+
attr_accessor :name, :hand, :blind_cards, :visible_cards, :ready
|
|
17
17
|
attr_reader :id
|
|
18
18
|
|
|
19
19
|
def initialize(name, id = nil)
|
|
20
20
|
@id = id || SecureRandom.uuid
|
|
21
21
|
@name = name
|
|
22
22
|
@hand = []
|
|
23
|
-
@
|
|
23
|
+
@blind_cards = []
|
|
24
24
|
@visible_cards = []
|
|
25
25
|
@ready = false
|
|
26
26
|
|
|
@@ -52,15 +52,15 @@ module Brigitte
|
|
|
52
52
|
hand[hand_card_index] = visible_card
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
def
|
|
55
|
+
def pull_blind_card(index)
|
|
56
56
|
return false if hand.any?
|
|
57
57
|
return false if visible_cards.any?
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
return false unless
|
|
59
|
+
blind_card = blind_cards[index]
|
|
60
|
+
return false unless blind_card
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
hand <<
|
|
62
|
+
blind_cards[index] = nil
|
|
63
|
+
hand << blind_card
|
|
64
64
|
sort_hand!
|
|
65
65
|
true
|
|
66
66
|
end
|
|
@@ -78,7 +78,7 @@ module Brigitte
|
|
|
78
78
|
id: id,
|
|
79
79
|
name: name,
|
|
80
80
|
hand: hand.map(&:to_h),
|
|
81
|
-
|
|
81
|
+
blind_cards: blind_cards.map(&:to_h),
|
|
82
82
|
visible_cards: visible_cards.map(&:to_h),
|
|
83
83
|
ready: ready
|
|
84
84
|
}
|
|
@@ -89,7 +89,7 @@ module Brigitte
|
|
|
89
89
|
|
|
90
90
|
new(hash[:name], hash[:id]) do |p|
|
|
91
91
|
p.hand = hash[:hand].map { |h| Card.from_h(h) }
|
|
92
|
-
p.
|
|
92
|
+
p.blind_cards = hash[:blind_cards].map { |h| Card.from_h(h) }
|
|
93
93
|
p.visible_cards = hash[:visible_cards].map { |h| Card.from_h(h) }
|
|
94
94
|
p.ready = hash[:ready]
|
|
95
95
|
end
|
data/lib/brigitte/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brigitte
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- youszef
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-12-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Card game where player needs to get rid of all it's cards
|
|
14
14
|
email:
|
|
@@ -23,6 +23,7 @@ files:
|
|
|
23
23
|
- ".gitignore"
|
|
24
24
|
- ".rspec"
|
|
25
25
|
- ".rubocop.yml"
|
|
26
|
+
- ".ruby-version"
|
|
26
27
|
- CHANGELOG.md
|
|
27
28
|
- Gemfile
|
|
28
29
|
- Gemfile.lock
|