CCard& Poke::getCard(int nPos) { if( (size_t)nPos >= 0 && (size_t)nPos < m_AllCards.size() ) { return m_AllCards[nPos]; } CCard emptyCard = CCard(0, 0); return emptyCard; }
// This function grows the map in a random direction and // puts the tunnel exit there somewhere. CLocation CMap::create_tunnel_exit() { CLocation Loc; switch(CCard().suit) { case SUIT_SPADE: grow_north(); Loc.y = random(MAP_SIZE - 2) + 2; Loc.x = random(yx[0].size() - 4) + 2; break; case SUIT_CLUB: grow_east(); Loc.y = random(yx.size() - 4) + 2; Loc.x = yx[0].size() - random(MAP_SIZE - 2) - 3; break; case SUIT_DIAMOND: grow_south(); Loc.y = yx.size() - random(MAP_SIZE - 2) - 3; Loc.x = random(yx[0].size() - 4) + 2; break; case SUIT_HEART: grow_west(); Loc.y = random(yx.size() - 4) + 2; Loc.x = random(MAP_SIZE - 2) + 2; break; } int y = Loc.y; int x = Loc.x; yx[y][x]->terrain = TRN_GRASS; yx[y][x]->Feature = new CPortal(FEA_TUNNEL_EXIT); yx[y][x]->explored = true; for(int i = 0; i < 4; i++) { yx[y + move_vec[i][0]][x + move_vec[i][1]]->terrain = TRN_GRASS; unexplored_tile.insert(yx[y + move_vec[i][0]][x + move_vec[i][1]]); } Loc.y -= yoffset; Loc.x -= xoffset; return Loc; }
CDungeon::CDungeon(domain_type d, feature_type ftype) { is_tunnel = (ftype == FEA_TUNNEL); domain = d; floors = 1; if (domain == DOM_OVERWORLD) { quest = &Quest[0]; floors = 1; Map.push_back(CMap()); } else { quest = Party.quest; Map.push_back(CMap(domain)); if (Party.KeyItem.count(itemmap["Cube"]) && !(Party.used_cube & 1 << (quest->serial - 1))) { draw_map(leftWindow, Party.L); message("You come upon %s. Activate the cube? (Y/N)", Domain[domain].name.c_str()); _chtype answer; do { answer = _getch(); if (answer == 'y') answer = 'Y'; if (answer == 'n') answer = 'N'; } while (answer != 'Y' && answer != 'N'); if (answer == 'Y') { domain_type new_domain = (domain_type)(CCard().rank + 1); message( "The dungeon collapses upon itself and %s emerges from the rubble.", Domain[new_domain].name.c_str()); domain = new_domain; Party.used_cube |= 1 << (quest->serial - 1); } } } }
int CBot::PlayHand(const bothand_t &hand, CCard rgDiscarded[20]) { int t[20], i, j, k, c = 0; memset(t, 0, sizeof(t)); switch (hand.type) { case DT_SINGLE: for (i = hand.headval - hand.cnt + 1; i <= hand.headval; i++) { for (j = 0; j < m_iNumHandCard; j++) { if (m_rgHandCard[j].GetValue() == i) { rgDiscarded[c++] = m_rgHandCard[j]; break; } } } break; case DT_DOUBLE: for (i = hand.headval - hand.cnt + 1; i <= hand.headval; i++) { for (k = 0; k < 2; k++) { for (j = 0; j < m_iNumHandCard; j++) { if (m_rgHandCard[j].GetValue() == i && !t[j]) { rgDiscarded[c++] = m_rgHandCard[j]; t[j] = 1; break; } } } } break; case DT_TRIPLE: for (i = hand.headval - hand.cnt + 1; i <= hand.headval; i++) { for (k = 0; k < 3; k++) { for (j = 0; j < m_iNumHandCard; j++) { if (m_rgHandCard[j].GetValue() == i && !t[j]) { rgDiscarded[c++] = m_rgHandCard[j]; t[j] = 1; break; } } } } break; case DT_QUAD: for (i = hand.headval - hand.cnt + 1; i <= hand.headval; i++) { for (k = 0; k < 4; k++) { for (j = 0; j < m_iNumHandCard; j++) { if (m_rgHandCard[j].GetValue() == i && !t[j]) { rgDiscarded[c++] = m_rgHandCard[j]; t[j] = 1; break; } } } } break; case DT_DBLJOKER: rgDiscarded[c++] = CCard(52); rgDiscarded[c++] = CCard(53); break; } rgDiscarded[c] = 255; return c; }
inline CCard Prev() const { if (m_iValue <= 1) return CCard(47); return CCard(m_iValue - 1); }
inline CCard Next() const { if (m_iValue >= 47) return CCard(0); return CCard(m_iValue + 1); }