void Deck::reshuffle(int N){ for (int i=0; i<cards.size(); i++){ delete(cards[i]); } createCards(N); shuffle(); }
GameLogic::GameLogic(QObject *parent) : QObject(parent) { // Create cards createCards(); // Create seed for the random QTime time = QTime::currentTime(); qsrand((uint)time.msec()); }
void CharSelectScreen::Initialize() { ArrayList<int> types; for(int i=1; i<=4; i++) { types.add(0); } createCards(types); createCharIcons(); resetCards(types); }
Deck::Deck() { bWithReplacement = false; bDrawHeatmap = false; numProperties = 4; numOptions = 3; poRandSeed(); createCards(); //printDeck(); dealCards(12); updateNeededCards(); printNeededRatios(); addEvent(PO_KEY_DOWN_EVENT, this); }
Deck::Deck(){ createCards(1); }
Deck::Deck(int numDecks){ createCards(numDecks); }
void iniciaJogo() { int numberOfRounds, x; int i = 0,j = 0 ,random; int vetIsUsed[100]; int ptoPlayer1 = 0, ptoPlayer2 = 0; Node* player1 = NULL; Node* player2 = NULL; Card foundCard1; Card foundCard2; Card card [53]; printf("\t\t\t\t\\----------------------- Welcome to House of Cards ---------------------------/"); printf("\nSelect the number of rounds : "); scanf("%d", &numberOfRounds); printf("O jogo começou !\n"); createCards(card); while(i < numberOfRounds) { while(j < 10){ random = 1 + rand() % 52; while(search(vetIsUsed,random)) random = 1 + rand() % 52; insertVector(vetIsUsed,random); player1 = insert(player1,card[random]); random = 1 + rand() % 52; while(search(vetIsUsed,random)) random = 1 + rand() % 52; insertVector(vetIsUsed,random); player2 = insert(player2,card[random]); j++; } player1 = fixAVL(player1); player2 = fixAVL(player2); foundCard1 = searchCards(player1); foundCard2 = searchCards(player2); if((foundCard1.number) > (foundCard2.number)) { ptoPlayer1++; printf("Player 1 Tem a Carta %s e pontua !\n", foundCard1.suits); } else if ((foundCard1.number) < (foundCard2.number)) { printf("Player 2 Tem a Carta %s e pontua !\n", foundCard2.suits); ptoPlayer2++; } else { printf("Players Tem as mesmas cartas %s e %s , ambos pontuam !\n", foundCard1.suits, foundCard2.suits); ptoPlayer1++; ptoPlayer2++; } if(ptoPlayer1 > ptoPlayer2) printf("Player 1 ganhou a primeira rodada !\n"); else if (ptoPlayer1 < ptoPlayer2) printf("Player 2 ganhou a primeira rodada !\n"); else printf("Deu empate ! \n"); free(player1); free(player2); i++; } i++; }
bool GameMain::init() { if(!Layer::init()){return false;} createBackground(); createLabel(); createCards(); createBoards(); createMenuButton(); settingStart(); auto listener=EventListenerTouchOneByOne::create(); //ドラッグ開始 listener->onTouchBegan=[this](Touch* touch,Event* event){ //// if(!_moveCards.empty()){ if(_moveCards.front()->getNumberOfRunningActions()){//ダブルタッチアニメーション中 auto card=_moveCards.front(); card->stopAllActions();//アニメーションをキャンセル this->dragTouchEnded(_homeCellLayer->getHomeCellTalonPosition(card->getCardType()));//CallFuncの処理を実行 } } //// auto position=touch->getLocation(); if(_gameState==GameState::TOUCH_WAITING){ _moveCards.clear(); if(TALON_AREA_RECT.containsPoint(position)){ _moveCards=_talonLayer->dragCards(position); this->setDragLayer(_talonLayer); }else if(BOARD_CARD_AREA_RECT.containsPoint(position)){ _moveCards=_boardCardLayer->dragCards(position); this->setDragLayer(_boardCardLayer); }else if(HOME_CELL_AREA_RECT.containsPoint(position)){ _moveCards=_homeCellLayer->dragCards(position); this->setDragLayer(_homeCellLayer); } if(!_moveCards.empty()){//カードがドラッグできれば auto cardPosition=Vec2(0,-CARD_SIZE.height/4); int z=1; for(auto card:_moveCards){ card->setPosition(cardPosition); _moveLayer->addChild(card,z); cardPosition+=TALON_DIFF; z++; } _moveLayer->setPosition(position); _gameState=GameState::DRAG; //ダブルタップ処理 _doubleTouchFlag=false; if(_dragLayer==_talonLayer || _dragLayer==_boardCardLayer){//山札あるいは場札からのドロップ if(_homeCellLayer->checkDropCard(_moveCards)){//ホームセルに置けるカードである _doubleTouchFlag=true;//ダブルタップ処理フラグをtrue _oneTouch=false;//一回タップされたかのフラグをfalse _touchTime=0;//タップ時間の初期化 } } }else{ this->setDragLayer(nullptr); } } return true; }; //ドロップ、山札の切り替え listener->onTouchEnded=[this](Touch* touch,Event* event){ auto position=touch->getLocation(); if(_gameState==GameState::TOUCH_WAITING){ if(TALON_AREA_RECT.containsPoint(position)){ if(_talonLayer->touchTalonCard(position)){ //山札が一巡 if(_talonLayer->getPullCount()==3){ //引くカードが3枚ずつの場合-20 this->updateScore(-20); }else if(_talonLayer->getPullCount()==1){ //引くカードが1枚ずつの場合-100 this->updateScore(-100); }else{ log("Talon::_pullCoount neither 1 nor 3."); } } } }else if(_gameState==GameState::DRAG){ if(_doubleTouchFlag){//ダブルタップを行う可能性がある if(_oneTouch){//既に一度タップされている if(_touchTime<TOUCH_TIME_PERIOD){//ダブルタップ受付時間以内 this->unschedule(DRAG_SCHEDULE); auto card=_moveCards.front(); //this->dragTouchEnded(_homeCellLayer->getHomeCellTalonPosition(card->getCardType())); _doubleTouchFlag=false; //// //カードを移すホームセルの位置 auto homeCellPosition=_homeCellLayer->getHomeCellTalonPosition(card->getCardType()); //_moveLayerとGameMainレイヤーは基準座標が違うためconvertする card->runAction(Sequence::create(MoveTo::create(0.3,_moveLayer->convertToNodeSpace(homeCellPosition)) ,CallFunc::create([this,homeCellPosition](){ this->dragTouchEnded(homeCellPosition); }) ,NULL)); //// } }else{ if(_touchTime<TOUCH_TIME_PERIOD){//ダブルタップ受付時間以内 _oneTouch=true; //ダブルタップされなかったときのためにスケジュールを設定 this->scheduleOnce([this,position](float dt){ this->dragTouchEnded(position); _doubleTouchFlag=false; },TOUCH_TIME_PERIOD-_touchTime+0.1,DRAG_SCHEDULE); }else{ this->dragTouchEnded(position); _doubleTouchFlag=false; } } }else{ this->dragTouchEnded(position); } } }; //ドロップ中の移動 listener->onTouchMoved=[this](Touch* touch,Event* event){ auto position=touch->getLocation(); if(_gameState==GameState::DRAG){ _moveLayer->setPosition(position); } }; //キャンセル listener->onTouchCancelled=[this](Touch* touch,Event* event){ if(_gameState==GameState::DRAG){ _moveLayer->removeAllChildren(); _dragLayer->cancelCards(_moveCards); _gameState=GameState::TOUCH_WAITING; } }; //test Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,this); return true; }