Skip to content

Instantly share code, notes, and snippets.

@oliverlee
Created May 31, 2019 22:25
Show Gist options
  • Select an option

  • Save oliverlee/1d67bfa810c011f1bde9d6670c85af04 to your computer and use it in GitHub Desktop.

Select an option

Save oliverlee/1d67bfa810c011f1bde9d6670c85af04 to your computer and use it in GitHub Desktop.
player.rs
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