Created
May 31, 2019 22:25
-
-
Save oliverlee/1d67bfa810c011f1bde9d6670c85af04 to your computer and use it in GitHub Desktop.
player.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate rand; | |
| use crate::dominion::CardKind; | |
| use rand::thread_rng; | |
| use rand::seq::SliceRandom; | |
| type CardVec = Vec<&'static CardKind>; | |
| #[derive(Debug)] | |
| pub struct Player { | |
| deck_pile: CardVec, | |
| hand: CardVec, | |
| in_play: CardVec, | |
| discard_pile: CardVec, | |
| } | |
| impl Player { | |
| pub fn new() -> Player { | |
| let mut deck_pile = vec![&CardKind::Copper; 7]; | |
| deck_pile.append(&mut vec![&CardKind::Estate; 3]); | |
| deck_pile.shuffle(&mut thread_rng()); | |
| Player { | |
| deck_pile, | |
| hand: CardVec::new(), | |
| in_play: CardVec::new(), | |
| discard_pile: CardVec::new(), | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment