#deck #card #generic #card-game

card_deck

A Generic Deck of Cards, with a draw and discard pile

9 releases

0.1.9 Aug 19, 2019
0.1.8 Jan 29, 2019
0.1.7 Aug 9, 2018
0.1.4 Jul 27, 2018

#25 in #deck


Used in flamme-rouge

MIT license

18KB
413 lines

Card Deck

The intent of this module is to provide methods for managing a deck and discard pile from a deck of generic cards.

The expectation is that cards will moved into and out of the deck, copy and clone are not used internally.

Changes

in v0.1.9

Fixed bug in card creation (All Spades) Enabled from_str and Display for PCard in playing cards Added tests for card creation

in v0.1.8

PartialEq on deck push_discards now takes an iterator

in v0.1.7

A playing cards module that works well with this deck.

in v0.1.5

Added "dig_for" and "dig_all" methods for grabbing the first/all cards that match a filter respectively.


lib.rs:

Card Deck acts as a draw and discard pile to on any kind of card.

Contributions Welcome

It is defined Generically so as not to be limited to anything specific like standard playing cards.

It takes the attitude that cards, in general, cannot be copied. As such cards are not borrowed. Instead they are consumed to be added, and when they are drawn, full ownership is returned.

For some (digital) card games, cards can be copied. If you wish to implement Clone, that will work in those cases.

Dependencies

~2MB
~42K SLoC