bool ContactManager::onContactBeginPro_End(){ target_pro = node_Pro->getScheduler()->pauseAllTargets(); MenuManager menuManager; Node* layer =menuManager.create_Menu(SUCCESS_LAYER); getScore(); strstream ss; string score; ss<<SCORE_GET; ss>>score; auto text_score=layer->getChildByName<ui::TextBMFont*>("Text_Score"); text_score->setString(score); if(GameManager::stepNow==STEP){ STEP++; } //此处应该有个算星星的方法 int stateN = getState(); strstream ss1; string state; ss1<<stateN; ss1>>state; CCLOG("星星:%d",stateN); auto text_state=layer->getChildByName<ui::TextBMFont*>("Text_State"); text_state->setString(state); GameVo gVo; GameVo gvoG = getGameInfo(GameManager::stepNow); if(gvoG._score<SCORE_GET){ gVo.setData(SCORE_GET, 3, getState()); setGameInfo(gVo,GameManager::stepNow); } updateConstant(); node_else->getParent()->addChild(layer); MenuManager::move_in(layer); return false; }
void AIBotSpadesClient::processMessageFromGame( SpadesCSMessageEnum msg, const std::vector<int>& args ) { //code to process event switch(msg) { case SEND_GAME_INFO_D_S: setGameInfo(args); break; case REQUEST_GAME_INIT_S: //eventually this will cause a button to appear //but for now we just reply right away sendMessageToGame(REPLY_INIT_GAME_C,std::vector<int>()); break; case REQUEST_DECK_CUT_POS_S: //eventually we let the player pick a card { std::vector<int> deckCutPos; deckCutPos.push_back(rand() % 52); sendMessageToGame(SEND_DECK_CUT_POS_C,deckCutPos); } break; case DISPATCH_CARDS_A_D_S: { //give bot his cards std::vector<Card> cards; for(size_t i = 4; i < args.size(); i++) { cards.push_back(Card::cardFromNumber(args[i])); } m_cards = cards; sendMessageToGame(FINISH_DISPATCH_CARDS_C,std::vector<int>()); } break; case REQUEST_PLAYER_TRICK_COUNT_S: { std::vector<int> cardCount; cardCount.push_back(2); sendMessageToGame(SEND_PLAYER_TRICK_COUNT_C,cardCount); } break; case SEND_PLAYER_TRICK_COUNT_D_S: { } break; case REQUEST_SELECTED_CARD_S: { std::vector<int> cardCount; int r = 0; r = rand() % (int)m_enabledCards.size(); cardCount.push_back(m_enabledCards[r]); m_cards.erase(m_cards.begin() + m_enabledCards[r]); std::sort(m_cards.begin(),m_cards.end()); sendMessageToGame(SEND_SELECTED_CARD_C,cardCount); std::vector<int> cc; sendMessageToGame(FINISH_PERFORM_CARD_ON_TABLE_C,cc); } break; case FILTER_CARDS_S: { m_enabledCards.clear(); for(int i = 0; i < m_cards.size(); ++i) { m_enabledCards.push_back(i); } for(int i = 0; i < args.size(); i++) { for(int j = 0; j < m_enabledCards.size(); ++j) { if(m_enabledCards[j] == args[i]) { m_enabledCards.erase(m_enabledCards.begin() + j); break; } } } } break; case PERFORM_CARD_ON_TABLE_A_D_S: { std::vector<int> cardCount; sendMessageToGame(FINISH_PERFORM_CARD_ON_TABLE_C,cardCount); } break; case REQUEST_CARD_SWAP_S: { std::vector<int> cardCount; int r = rand() % m_cards.size(); cardCount.push_back(m_cards[r].getCardNumber()); m_cards.erase(m_cards.begin() + r); int p = rand() % m_cards.size(); cardCount.push_back(m_cards[p].getCardNumber()); m_cards.erase(m_cards.begin() + p); sendMessageToGame(SEND_SWAPPED_CARDS_C,cardCount); } break; case PERFORM_SWAP_S: { if(args[0] == 0 || args[0] == 1) //does it need to swap? { std::vector<Card> incoming; incoming.push_back(Card::cardFromNumber(args[1])); incoming.push_back(Card::cardFromNumber(args[2])); m_cards.push_back(incoming[0]); m_cards.push_back(incoming[1]); std::sort(m_cards.begin(),m_cards.end()); } std::vector<int> cardCount; sendMessageToGame(FINISHED_CARD_SWAP_C,cardCount); } break; case PLAYER_MADE_TRICK_A_D_S: { std::vector<int> cardCount; sendMessageToGame(FINISHED_PLAYER_MADE_TRICK_C,cardCount); } break; } }
static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static char path[XFIRE_MAX_STATIC_STRING_LEN] = ""; static WCHAR wpath[256]; static HICON gameicon = 0; static HICON voiceicon = 0; static MCONTACT uhandle = 0; static HWND listbox; LVCOLUMNA pcol; switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); ghwndDlg = hwndDlg; listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST); pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; pcol.pszText = "Key"; pcol.cx = 65; pcol.fmt = LVCFMT_LEFT; SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol); pcol.cx = 80; pcol.pszText = "Value"; SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol); HFONT hFont; LOGFONT lfFont; memset(&lfFont, 0x00, sizeof(lfFont)); memcpy(lfFont.lfFaceName, TEXT("Arial"), 8); lfFont.lfHeight = 13; lfFont.lfWeight = FW_BOLD; lfFont.lfCharSet = ANSI_CHARSET; lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS; lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; lfFont.lfQuality = DEFAULT_QUALITY; // Create the font from the LOGFONT structure passed. hFont = CreateFontIndirect(&lfFont); SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE); return TRUE; } case WM_CTLCOLORSTATIC: { break; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->idFrom) { case 0: { switch (((LPNMHDR)lParam)->code) { case PSN_INFOCHANGED: { char* szProto; MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; uhandle = hContact; //handle sichern if (hContact == NULL) szProto = protocolname; else szProto = GetContactProto(hContact); if (szProto == NULL) break; //alle items aus der liste entfernen SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0); if (hContact) { DBVARIANT dbv; if (!db_get(hContact, protocolname, "Username", &dbv)) { int usernamesize = mir_strlen(dbv.pszVal) + 1; char* username = new char[usernamesize]; if (username) { strcpy_s(username, usernamesize, dbv.pszVal); mir_forkthread(LoadProfilStatus, (LPVOID)username); } //LoadProfilStatus db_free(&dbv); } if (!db_get(hContact, protocolname, "GameInfo", &dbv)) { setGameInfo(listbox, dbv.pszVal); db_free(&dbv); } addToList(listbox, hContact, "Servername", "ServerName"); addToList(listbox, hContact, "GameType", "GameType"); addToList(listbox, hContact, "Map", "Map"); addToList(listbox, hContact, "Players", "Players"); SetItemTxt(hwndDlg, IDC_DNICK, "Nick", hContact, 0); SetItemTxt(hwndDlg, IDC_DUSERNAME, "Username", hContact, 0); SetItemTxt(hwndDlg, IDC_GIP, "ServerIP", hContact, 0); SetItemTxt(hwndDlg, IDC_VIP, "VServerIP", hContact, 0); SetItemTxt(hwndDlg, IDC_GPORT, "Port", hContact, 1); SetItemTxt(hwndDlg, IDC_VPORT, "VPort", hContact, 1); SetItemTxt(hwndDlg, IDC_GAME, "RGame", hContact, 0); SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0); //render icons { DBVARIANT dbv; if (!db_get(hContact, protocolname, "GameId", &dbv)) { SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0); db_free(&dbv); } if (!db_get(hContact, protocolname, "VoiceId", &dbv)) { SendDlgItemMessage(hwndDlg, IDC_VOICEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0); db_free(&dbv); } if (db_get(hContact, protocolname, "ServerIP", &dbv)) { EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE); db_free(&dbv); } if (db_get(hContact, protocolname, "VServerIP", &dbv)) { EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE); db_free(&dbv); } //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE) } } } break; } } break; } } break; case WM_COMMAND: { switch (wParam) { case IDC_COPYGAME: GetIPPortUDetails(uhandle, "ServerIP", "Port"); break; case IDC_COPYVOICE: GetIPPortUDetails(uhandle, "VServerIP", "VPort"); break; } } } return FALSE; }