Example #1
0
// removes the top num cards from the deck and returns
// a "Deck" as the drawn cards. shifts all
// the cards up num
Deck Deck::draw_cards(int num) {
    Deck ret;
	if(!well_formed()) return ret;

    // draws a card from our deck to add
    // to the return deck;
    for(int i = 0; i < num; i++) {
        ret.add_card(draw_card());
	}
	
	well_formed();
	return ret;
}
Example #2
0
bool DeckBuilder::load_deck(std::string file) {
    ifstream deck_file("../decklists/"+file);
    if(deck_file.is_open()) {
        Deck* deck = new Deck(file.substr(0, file.find(".lst")));
        for(Deck* check : list)
            if(deck->get_name() == check->get_name())
                return true;
        string line;
        while(getline(deck_file, line)) {
            int num;
            stringstream ss; 
            ss << line.substr(line.find('X')+1);
            ss >> num;
            for(int i = 0; i < num; i++) {
                Card* card = new Card();
                card->build_card(line.substr(0, line.find('X')-1));
                deck->add_card(card);
            }
        }
        list.push_back(deck);
        selected = list.size() - 1;
    } else return false;