int main(int argc, const char * argv[]) { Deck cardDeck = *new Deck(); cardDeck.fillDeck(); cardDeck.shuffle(); bool deal = true; char continu; while (deal) { BlackJackHand hand = *new BlackJackHand(); hand.add(cardDeck.draw()); hand.add(cardDeck.draw()); dealerPlay(&cardDeck, &hand); std::cout << std::endl << "Deal (Y/N): "; cin >> continu; continu = toupper(continu); if (continu == 'Y') { deal = true; } else { deal=false; } } }
Deck* chance_deck() { Deck* ChanceDeck = new Deck; std::vector<uint> utils(2); utils[0] = 12; utils[1] = 28; std::vector<uint> rails(4); for (uint i = 0; i < rails.size(); i++) rails[i] = 5 + i*10; ChanceDeck->insert_card(new AdvanceTo(0)); // Go ChanceDeck->insert_card(new AdvanceTo(24)); // Illinois ChanceDeck->insert_card(new AdvanceTo(11)); // StCharles ChanceDeck->insert_card(new AdvanceTo(5)); // Reading ChanceDeck->insert_card(new AdvanceTo(39)); // BoardWalk ChanceDeck->insert_card(new AdvanceTo(utils)); // Utilities ChanceDeck->insert_card(new AdvanceTo(rails)); // Rails ChanceDeck->insert_card(new GoDirToJail); // Go to jail card ChanceDeck->insert_card(new MoveBack3); // Move back 3 spaces for (uint i = 0; i < 6; i++) ChanceDeck->insert_card(new Card); ChanceDeck->shuffle(); return ChanceDeck; }
void initSimpleTable(const Deck& deck, const std::string& keywordName, std::vector<TableType>& tableVector) { if (!deck.hasKeyword(keywordName)) return; // the table is not featured by the deck... if (deck.count(keywordName) > 1) { complainAboutAmbiguousKeyword(deck, keywordName); return; } const auto& tableKeyword = deck.getKeyword(keywordName); for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); ++tableIdx) { const auto& dataItem = tableKeyword.getRecord( tableIdx ).getItem( 0 ); if (dataItem.size() == 0) { // for simple tables, an empty record indicates that the previous table // should be copied... if (tableIdx == 0) { std::string msg = "The first table for keyword "+keywordName+" must be explicitly defined! Ignoring keyword"; OpmLog::warning(Log::fileMessage(tableKeyword.getFileName(), tableKeyword.getLineNumber(), msg)); return; } tableVector.push_back(tableVector.back()); continue; } tableVector.push_back(TableType()); tableVector[tableIdx].init(dataItem); } }
bool Engine::setDeck(const Deck &deck) { if (mDeck) { // already set return false; } if (deck.empty()) { // nothing to do with empty card set return false; } if (mPlayers.size() < 2) { // add more players return false; } mDeck = new Deck(deck); CardSet cards; cards.insert(deck.begin(), deck.end()); std::for_each(mGameObservers.begin(), mGameObservers.end(), GameStartNotification(mDeck->trumpSuit(), mGeneratedIds, cards)); return true; }
void TableManager::initGasvisctTables(const Deck& deck) { const std::string keywordName = "GASVISCT"; size_t numTables = m_tabdims->getNumPVTTables(); if (!deck.hasKeyword(keywordName)) return; // the table is not featured by the deck... auto& container = forceGetTables(keywordName , numTables); if (deck.count(keywordName) > 1) { complainAboutAmbiguousKeyword(deck, keywordName); return; } const auto& tableKeyword = deck.getKeyword(keywordName); for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); ++tableIdx) { const auto& tableRecord = tableKeyword.getRecord( tableIdx ); const auto& dataItem = tableRecord.getItem( 0 ); if (dataItem.size() > 0) { std::shared_ptr<GasvisctTable> table = std::make_shared<GasvisctTable>( deck , dataItem ); container.addTable( tableIdx , table ); } } }
//Main of the Program, This also counts the consolidations for us. //Meanwhile it also tracks how many consecutive consolidations we have int main() { int num_consolidation=0; int num_consecutive_consolidation=0; int num_max_consolidation=0; Deck list; ifstream file("deckofcards.txt"); while(!file.eof()) //file.is_open() { Card* temp; temp = new Card; file >> *temp; list.add(temp); list.display(); cout << endl; num_consecutive_consolidation = 0; while(list.consolidate()) { list.display(); num_consolidation++; num_consecutive_consolidation++; cout << endl; } if(num_consecutive_consolidation > num_max_consolidation) { num_max_consolidation = num_consecutive_consolidation; } } file.close(); cout << "\nNumber of total consolidations: " << num_consolidation << endl; cout << "Highest number of consecutive consolidations: "; cout << num_max_consolidation << endl; return 0; }
void Poker::createdeck(vector<string>& deck) { Deck<string> dk; deck = dk.createdeck(deck); deck = dk.shuffle(deck); }
/* * format: * $owner-uid;nr-spells;spell1-name;spell1-uid;spell2-name;spell2-uid;...;\n */ void instance::draw_spells(puppet_ptr inPuppet, int inNrOfSpells) { if (!inPuppet) inPuppet = active_puppet_; const int mMaxSpellsInHand = 6; drawn_spells_.str(""); drawn_spells_ << "[draw];" << inNrOfSpells << "\n"; drawn_spells_ << "$" << inPuppet->getUID() << ";"; // create nrSpellsPerTurn spells from the hero's deck Deck* lDeck = inPuppet->getDeck(); int i; for (i=0; i< inNrOfSpells; ++i) { Spell* lSpell = lDeck->drawSpell(); // assign UID and attach to puppet lSpell->setUID(generate_uid()); inPuppet->attachSpell(lSpell); pass_to_lua("Spells.onDrawSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell); drawn_spells_ << lSpell->getName() << ";" << lSpell->getUID() << ";"; lSpell = 0; } drawn_spells_ << "\n"; // tell it to drop some spells if its hand is overflown drawn_spells_ << "[drop];"; int nrOverflow = inPuppet->nrSpellsInHand() - mMaxSpellsInHand; //~ std::cout << "Puppet has " << inPuppet->nrSpellsInHand() << " spells in hand, an overflow of= " << nrOverflow << "\n"; if (nrOverflow > 0) { drawn_spells_ << nrOverflow << "\n$" << inPuppet->getUID() << ";"; } else drawn_spells_ << 0; Entity::spells_t const& lHand = inPuppet->getHand(); while (inPuppet->nrSpellsInHand() > mMaxSpellsInHand) { Spell* lSpell = lHand.front(); drawn_spells_ << lSpell->getUID() << ";"; pass_to_lua("Spells.onDropSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell); inPuppet->detachSpell(lSpell->getUID()); lSpell = 0; } drawn_spells_ << "\n"; //~ log_->infoStream() << "sending drawn spells to Puppet " << inPuppet->getName(); std::cout << "drawn spells:\n" << drawn_spells_.str() << "\n"; // broadcast the data Event evt(EventUID::DrawSpells, EventFeedback::Ok, Event::NoFormat); evt.setProperty("Data", drawn_spells_.str()); broadcast(evt); }
Deck Euchre::set_deck( ) { list<Card> draw; Card temp; Deck result; short size = 0; for ( int j = 0; j < 52; ++j ) { temp.rank( ( j % 13 ) + 1 ); if ( j < 13 ) { temp.suit( SPADES ); } else if ( j < 26 ) { temp.suit( DIAMONDS ); } else if ( j < 39 ) { temp.suit( CLUBS ); } else { temp.suit( HEARTS ); } switch ( j % 13 + 1 ) { case 1: case 7: case 8: case 9: case 10: case 11: case 12: case 13: size++; draw.push_back( temp ); break; } } result.set_draw( draw ); result.set_size( size ); return result; }
void Game::dispatchCard(std::vector<int> &vector) { int i, j; Deck *deck; Deck *deckuser; std::vector <int> ::iterator iter; deck = *(this->decklist.begin() + 1); for (iter = vector.begin(); iter != vector.end(); iter++) { for (i = 0; i < 4; i++) { deckuser = *(this->decklist.begin() + 2 + (*(this->playerlist.begin() + i))->getLocate()); for (j = 0; j < *iter; j++) { deckuser->Push(deck->Pop()); } } } this->nextuserid = 0; return; }
void TableManager::initVFPInjTables(const Deck& deck, std::map<int, VFPInjTable>& tableMap) { if (!deck.hasKeyword(ParserKeywords::VFPINJ::keywordName)) { return; } int num_tables = deck.count(ParserKeywords::VFPINJ::keywordName); const auto& keywords = deck.getKeywordList<ParserKeywords::VFPINJ>(); const auto& unit_system = deck.getActiveUnitSystem(); for (int i=0; i<num_tables; ++i) { const auto& keyword = *keywords[i]; VFPInjTable table; table.init(keyword, unit_system); //Check that the table in question has a unique ID int table_id = table.getTableNum(); if (tableMap.find(table_id) == tableMap.end()) { tableMap.insert(std::make_pair(table_id, std::move(table))); } else { throw std::invalid_argument("Duplicate table numbers for VFPINJ found"); } } }
void TableManager::initRocktabTables(const Deck& deck) { if (!deck.hasKeyword("ROCKTAB")) return; // ROCKTAB is not featured by the deck... if (deck.count("ROCKTAB") > 1) { complainAboutAmbiguousKeyword(deck, "ROCKTAB"); return; } const auto& rockcompKeyword = deck.getKeyword<ParserKeywords::ROCKCOMP>(); const auto& record = rockcompKeyword.getRecord( 0 ); size_t numTables = record.getItem<ParserKeywords::ROCKCOMP::NTROCC>().get< int >(0); auto& container = forceGetTables("ROCKTAB" , numTables); const auto rocktabKeyword = deck.getKeyword("ROCKTAB"); bool isDirectional = deck.hasKeyword<ParserKeywords::RKTRMDIR>(); bool useStressOption = false; if (deck.hasKeyword<ParserKeywords::ROCKOPTS>()) { const auto rockoptsKeyword = deck.getKeyword<ParserKeywords::ROCKOPTS>(); const auto& rockoptsRecord = rockoptsKeyword.getRecord(0); const auto& item = rockoptsRecord.getItem<ParserKeywords::ROCKOPTS::METHOD>(); useStressOption = (item.getTrimmedString(0) == "STRESS"); } for (size_t tableIdx = 0; tableIdx < rocktabKeyword.size(); ++tableIdx) { const auto& tableRecord = rocktabKeyword.getRecord( tableIdx ); const auto& dataItem = tableRecord.getItem( 0 ); if (dataItem.size() > 0) { std::shared_ptr<RocktabTable> table = std::make_shared<RocktabTable>( dataItem , isDirectional, useStressOption ); container.addTable( tableIdx , table ); } } }
IOConfig::IOConfig( const Deck& deck ) : IOConfig( GRIDSection( deck ), RUNSPECSection( deck ), TimeMap( deck ), deck.hasKeyword("NOSIM"), deck.getDataFile() ) {}
void one_run(){ Deck d; //d.print_deck(); Hand h1(d); // // Card c1(1,0); // h1.Addcard(c1); // Card c2(1,1); // h1.Addcard(c2); // Card c3(1,2); // h1.Addcard(c3); // Card c4(1,3); // h1.Addcard(c4); // Card c5(11,0); // h1.Addcard(c5); // Card c6(4,0); // h1.Addcard(c6); // Card c7(3,0); // h1.Addcard(c7); h1.Addcard(d.Deal()); h1.Addcard(d.Deal()); h1.Addcard(d.Deal()); h1.Addcard(d.Deal()); h1.Addcard(d.Deal()); h1.Pokerrank(); // h1.Printhand(); hist[h1.Get_prank()]++; }
void Controller::start(){ game = get_game(); humans = get_humans(); ai = get_ai(); Deck* deck = new Deck(52); deck->shuffle(&deck->deck); if (game == "Go Fish" || game == "Go fish"){ Gofish* goFish = new Gofish(); goFish->start(goFish, deck, humans, ai); } else if (game == "5-Card draw" || game == "5-card draw" || game == "5-Card Draw" || game == "5-card Draw"){ Fivecard* fiveCard = new Fivecard(); fiveCard->set_rounds(); int rounds = fiveCard->get_rounds(); for (int r = 0; r<rounds; r++){ int b = 0; Deck* deck = new Deck(52); deck->shuffle(&deck->deck); if (r == rounds) b = 1; fiveCard->start(fiveCard, deck, this->humans, this->ai, b); cout<<"\033[1;32mEnd of Round "<<r<<"\033[0m"<<endl; } } }
EclipseState::EclipseState(const Deck& deck, ParseContext parseContext) : m_parseContext( parseContext ), m_tables( deck ), m_runspec( deck ), m_eclipseConfig( deck ), m_deckUnitSystem( deck.getActiveUnitSystem() ), m_inputNnc( deck ), m_inputGrid( deck, nullptr ), m_eclipseProperties( deck, m_tables, m_inputGrid ), m_simulationConfig( deck, m_eclipseProperties ), m_transMult( GridDims(deck), deck, m_eclipseProperties ) { m_inputGrid.resetACTNUM(m_eclipseProperties.getIntGridProperty("ACTNUM").getData().data()); if( this->runspec().phases().size() < 3 ) m_messageContainer.info("Only " + std::to_string( this->runspec().phases().size() ) + " fluid phases are enabled" ); if (deck.hasKeyword( "TITLE" )) { const auto& titleKeyword = deck.getKeyword( "TITLE" ); const auto& item = titleKeyword.getRecord( 0 ).getItem( 0 ); std::vector<std::string> itemValue = item.getData<std::string>(); m_title = boost::algorithm::join( itemValue, " " ); } initTransMult(); initFaults(deck); m_messageContainer.appendMessages(m_tables.getMessageContainer()); m_messageContainer.appendMessages(m_inputGrid.getMessageContainer()); m_messageContainer.appendMessages(m_eclipseProperties.getMessageContainer()); }
void sresource_manager::_assign_deck(Puppet& inPuppet, string inName, string inSpells, int inUseCount) { Deck* lDeck = 0; // does the puppet already have this deck? are we updating? inPuppet.removeDeck(inName); lDeck = new Deck(&inPuppet); lDeck->setName(inName); lDeck->setUseCount(inUseCount); // parse the spells // expected format: {"Spell1 Name","...","Spell16 Name"} inSpells = inSpells.erase(0,1).erase(inSpells.size()-2,1); // strip out the {} vector<string> elements = Utility::split(inSpells, ','); assert(elements.size() == 16); vector<string>::iterator itr; for (itr = elements.begin(); itr != elements.end(); ++itr) { //~ std::cout << "assigning spell to deck " << (*itr) << "\n"; // strip out the quotes std::string spellname = (*itr).erase(0,1).erase((*itr).size()-2,1); //(*itr).pop_front(); lDeck->_assignSpell(getSpell(spellname)); } inPuppet.addDeck(lDeck); lDeck = 0; }
void TableManager::initPlyshlogTables(const Deck& deck) { const std::string keywordName = "PLYSHLOG"; if (!deck.hasKeyword(keywordName)) { return; } if (!deck.count(keywordName)) { complainAboutAmbiguousKeyword(deck, keywordName); return; } size_t numTables = m_tabdims->getNumPVTTables(); auto& container = forceGetTables(keywordName , numTables); const auto& tableKeyword = deck.getKeyword(keywordName); if (tableKeyword.size() > 2) { std::string msg = "The Parser does currently NOT support the alternating record schema used in PLYSHLOG"; throw std::invalid_argument( msg ); } for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); tableIdx += 2) { const auto& indexRecord = tableKeyword.getRecord( tableIdx ); const auto& dataRecord = tableKeyword.getRecord( tableIdx + 1); const auto& dataItem = dataRecord.getItem( 0 ); if (dataItem.size() > 0) { std::shared_ptr<PlyshlogTable> table = std::make_shared<PlyshlogTable>(indexRecord , dataRecord); container.addTable( tableIdx , table ); } } }
int main(){ Deck a; a.Shuffle(); a.Show(); system("pause"); }
int main() { Deck deck; deck.Display(); deck.Shuffle(); deck.Display(); return 0; }
GridDims::GridDims(const Deck& deck) { if (deck.hasKeyword("SPECGRID")) init(deck.getKeyword("SPECGRID")); else if (deck.hasKeyword("DIMENS")) init(deck.getKeyword("DIMENS")); else throw std::invalid_argument("Must have either SPECGRID or DIMENS to indicate grid dimensions"); }
int main(){ Deck deck; Card card; deck.shuffle(); card.print(deck.at(1)); return 0; }
int main(){ Deck deck; deck.shuffle(); vector<Card> vc = deck.deal_hand(5); cout<<deck.remain_cards()<<endl; for(int i=0; i<vc.size(); ++i) cout<<vc[i].value()<<" "<<(Suit)vc[i].suit()<<endl; return 0; }
Deck::Deck( const Deck& d ) : DeckView( d.begin(), d.begin() ), keywordList( d.keywordList ), defaultUnits( d.defaultUnits ), activeUnits( d.activeUnits ), m_dataFile( d.m_dataFile ), input_path( d.input_path ) { this->reinit(this->keywordList.begin(), this->keywordList.end()); }
void test_interface() { struct gameState stato; stato.n=1; stato.winning=new Card(1,0,0,0,3); stato.winner=new King(new player_t); ((Role *) stato.winner)->getData()->name="Vince"; stato.stillPlaying=3; msg_printState(&stato); Deck mazzo; mazzo.addCard(new Card(1,0,0,0,3)); mazzo.addCard(new Card(1,1,0,0,4)); mazzo.addCard(new Card(1,0,0,0,10)); mazzo.addCard(new Card(1,0,1,1,13)); mazzo.addCard(new Card(0,0,1,0,1)); mazzo.addCard(new Card(1,0,0,1,2)); /* Choice *ch; cout <<"--------\ntest modalità NO CARDS\n"; ch=selectCard(&stato,&mazzo,NO_CARDS); cout <<"----------\ntest modalità ONE CARD\n"; ch=selectCard(&stato,&mazzo,ONE_CARD); ch=selectCard(&stato,&mazzo,NO_CARDS); cout <<"---------\ntest modalità FOUR CARDS\n"; ch=selectCard(&stato,&mazzo,FOUR_CARDS); ch=selectCard(&stato,&mazzo,NO_CARDS); cout <<"---------\ntest modalità N CARDS\n"; ch=selectCard(&stato,&mazzo,N_CARDS); ch=selectCard(&stato,&mazzo,NO_CARDS); */ if(strToInt("-123",-999,999)!=-123) cout <<"Errore 1\n"; /* player_t *pla=readData(1); cout <<"\nnome: " <<pla->name; cout <<"\nbrain: " <<pla->brainLevel; cout <<"\ntime: " <<pla->time; cout <<"\nadvancement: " <<pla->advancement; pla=readData(2); cout <<"\nnome: " <<pla->name; cout <<"\nbrain: " <<pla->brainLevel; cout <<"\ntime: " <<pla->time; cout <<"\nadvancement: " <<pla->advancement; */ cout <<"controlli sull'interfaccia completati\n"; }
/// Adds all cards from one deck to another Deck operator+(Deck &d1,Deck &d2){ Deck new_deck; for(int i=0;i<d1.get_length();i++){ new_deck.add(*d1[i]); } for(int i=0;i<d2.get_length();i++){ new_deck.add(*d2[i]); } return new_deck; }
WellSegmentDims::WellSegmentDims(const Deck& deck) : WellSegmentDims() { if (deck.hasKeyword("WSEGDIMS")) { const auto& wsd = deck.getKeyword("WSEGDIMS", 0).getRecord(0); this->nSegWellMax = wsd.getItem("NSWLMX").get<int>(0); this->nSegmentMax = wsd.getItem("NSEGMX").get<int>(0); this->nLatBranchMax = wsd.getItem("NLBRMX").get<int>(0); } }
int main(void) { Deck test; Deck shuffled; // test zero and 52 for shuffle cut and // see if it is the same as a non shuffled deck shuffled.shuffle(0); Card testCheck; Card shuffleCheck; for (int i = 0; i < DECK_SIZE; i++) { shuffleCheck = shuffled.deal(); testCheck = test.deal(); assert(testCheck.get_rank() == shuffleCheck.get_rank()); assert(testCheck.get_suit() == shuffleCheck.get_suit()); } test.shuffle(0); shuffled.shuffle(52); for (int i = 0; i < DECK_SIZE; i++) { shuffleCheck = shuffled.deal(); testCheck = test.deal(); assert(testCheck.get_rank() == shuffleCheck.get_rank()); assert(testCheck.get_suit() == shuffleCheck.get_suit()); } return 0; }
int main(){ Deck a; a.Shuffle(); Hand s1(&a), s2(&a); cout << "[Player A] Hand¡G"; s1.Show(); cout << "[Player B] Hand¡G"; s2.Show(); Hand::whoWin(s1, s2); system("pause"); }
TEST(HandTest, testAddCard) { Hand h; Deck d; d.shuffle(); for (int i = 0; i < 5; i++) { h.add_card(d.take()); EXPECT_EQ(i + 1, h.size()); } }