void UwTDMA_frame::changeStatus() { packet_sent_curr_slot_ = 0; if (slot_status == UW_TDMA_STATUS_NOT_MY_SLOT) { my_slots_counter++; if (debug_) std::cout << NOW << " ID:" << addr << ", my_slots_counter:" << my_slots_counter << std::endl; } if (slot_status == UW_TDMA_STATUS_MY_SLOT) { slot_status = UW_TDMA_STATUS_NOT_MY_SLOT; int num_jumping_slots = getNextMySlot()->first - getCurrentSlot()->first; num_jumping_slots = num_jumping_slots > 0 ? num_jumping_slots : num_jumping_slots + tot_slots; double nextSlotTime = (num_jumping_slots - 1) * slot_duration + guard_time; tdma_timer.resched(nextSlotTime); if (debug_ < -5) std::cout << NOW << " Off ID " << addr << " " << nextSlotTime << "" << std::endl; if (sea_trial_) out_file_stats << left << "[" << getEpoch() << "]::" << NOW << "::TDMA_node(" << addr << ")::Off timeslot " << getCurrentSlot()->first << std::endl; } else UwTDMA::changeStatus(); }
void playBlackJack(struct Player* player, struct Player* dealer) { int i; printFramedText("Game start"); printf("\n"); initPlayer(player, FALSE); initPlayer(dealer, TRUE); shuffleCards(&s_cardDeck); for(i = 0; i < 2; i++) { drawCard(player); } for(i = 0; i < 2; i++) { drawCard(dealer); } showCards(player, dealer); // In case of same card, ask if player splits card. if(canSplitCard(player)){ if(getUserDecision("You have two same number cards. Split card ?")) { printFramedText("Player split card"); printf("\n"); splitCard(player); showCards(player, dealer); } } // Player draw card. while(player->isStand == FALSE) { if(player->isSplit) printf("[Slot %d] ", (int)getCurrentSlotID(player)); if(getUserDecision("Draw one more card ?")) { printFramedText("Player draw card"); printf("\n"); drawCard(player); showCards(player, dealer); } else { struct CardSlot* slot = getCurrentSlot(player); slot->isEndDraw = TRUE; } player->isStand = isStand(player); } // Dealer draw card. while(isStand(dealer) == FALSE) { drawCard(dealer); } dealer->isStand = TRUE; // Show play result. printFramedText("Dealer draw card"); printf("\n"); showCards(player, dealer); printPlayResult(player, dealer); onGameEnd(); }
void printPlayResult(struct Player* player, struct Player* dealer) { struct CardSlot* playerSlot = &player->slot; struct CardSlot* playerSpSlot = &player->spSlot; struct CardSlot* dealerSlot = getCurrentSlot(dealer); const char* scorePrefix = player->isSplit ? " [Slot1] Score: " : " Score: "; enum PlayResult result; printf("Dealer\n"); printSlotScore(dealerSlot, " Score: ", TRUE, TRUE); printf("Player\n"); printSlotScore(playerSlot, scorePrefix, TRUE, FALSE); result = getPlayResultBySlot(playerSlot, dealerSlot); printf(" => You %s\n", ResultStr[result]); if(player->isSplit) { printSlotScore(playerSpSlot, " [Slot2] Score: ", TRUE, FALSE); result = getPlayResultBySlot(playerSpSlot, dealerSlot); printf(" => You %s\n", ResultStr[result]); } printf("\n"); }
enum SlotID getCurrentSlotID(struct Player* player) { enum SlotID curSlotID = BASE_SLOT_ID; if(getCurrentSlot(player) == &player->spSlot) { curSlotID = SPLIT_SLOT_ID; } return curSlotID; }
void SFXController::_onParameterEvent( SFXParameter* parameter, SFXParameterEvent event ) { Parent::_onParameterEvent( parameter, event ); // Implement cursor semantic. if( event == SFXParameterEvent_ValueChanged && parameter->getChannel() == SFXChannelCursor ) { U32 slot = U32( mFloor( parameter->getValue() ) ); if( slot != getCurrentSlot() ) setCurrentSlot( slot ); } }
void UnlockManager::findWhatWasUnlocked(int points_before, int points_now, std::vector<std::string>& tracks, std::vector<std::string>& gps) { for (AllChallengesType::iterator it = m_all_challenges.begin(); it != m_all_challenges.end(); it++) { ChallengeData* c = it->second; if (c->getNumTrophies() > points_before && c->getNumTrophies() <= points_now ) { if (c->getMode() == ChallengeData::CM_SINGLE_RACE && c->getTrackId() != "") { if (!getCurrentSlot()->isLocked(c->getTrackId())) tracks.push_back(c->getTrackId()); } else if (c->getMode() == ChallengeData::CM_GRAND_PRIX && c->getGPId() != "") { if (!getCurrentSlot()->isLocked(c->getGPId())) gps.push_back(c->getGPId()); } } } }
void drawCard(struct Player* player) { struct CardSlot* slot = getCurrentSlot(player); int newCard; #ifdef BJDEBUG const char* drawer = player->isDealer ? "Dealer" : "Player"; printf("[DEBUG] %s draw card\n", drawer); newCard = drawCard_d(); #else newCard = serveCard(&s_cardDeck); #endif pushCardToSlot(slot, newCard); calcScoreState(slot, player->isDealer, player->isSplit); }
void UnlockManager::updateActiveChallengeList() { getCurrentSlot()->computeActive(); }
QVector2D QBlockDiagramLinkEnd::computeDir() const { if(getCurrentSlot() == NULL) return QVector2D(0,0); return QVector2D( cos(getCurrentSlot()->getLinkDirectionAngle()*M_PI/180.f), sin(getCurrentSlot()->getLinkDirectionAngle()*M_PI/180.f) ); }