📄 player.cpp
字号:
} int count[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}, i; int suit = m_Hand.m_Tiles[0].tile.GetSuit(); bool b = false; for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].tile.GetSuit() != suit) { return; // fail } assert(m_Hand.m_Tiles[i].tile.GetValue() >= 1); assert(m_Hand.m_Tiles[i].tile.GetValue() <= 9); count[m_Hand.m_Tiles[i].tile.GetValue() - 1]++; } for (i = 0; i < 9; i++) { int s = ((i == 0 || i == 8) ? 3 : 1); if (count[i] == s + 1) { if (b) { return; // fail } b = true; } else if (count[i] != s) { return; // fail } } m_Result.cyurenpotou = 1; // success}void CBasePlayer::CalcResult_sukantu(){ int count = 0, i; for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & (HT_OPENKONG | HT_CLOSEDKONG)) count++; } if (count >= 4) m_Result.sukantu = 1; // success! else if (count >= 3) m_Result.sankantu = 1;}void CBasePlayer::CalcResult_reach(){ if (m_fReach) m_Result.reach = 1;}void CBasePlayer::CalcResult_ippatu(){ if ((m_iState & PS_CALLREACH) && m_iNumDiscarded > 0 && (m_Discarded[m_iNumDiscarded - 1].flags & DT_REACH)) m_Result.ippatu = 1;}void CBasePlayer::CalcResult_double_reach(){ if (m_fReach && m_iNumDiscarded > 0 && (m_Discarded[0].flags & DT_REACH)) m_Result.double_reach = 1;}void CBasePlayer::CalcResult_tanyao(){ for (int i = 0; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].tile.IsMajor()) return; // fail! } m_Result.tanyao = 1;}void CBasePlayer::CalcResult_ryanpeikou(){ if (!m_Result.concealed) { return; // fail } int i, j, count = 0; for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & (HT_CLOSEDCHOW | HT_OPENCHOW)) { for (j = i + 1; j < m_Hand.m_iNumTileSets; j++) { if (m_Hand.m_TileSets[j].type & (HT_CLOSEDCHOW | HT_OPENCHOW)) { if (m_Hand.m_TileSets[j].first == m_Hand.m_TileSets[i].first) { count++; } } } } } if (count >= 2) { m_Result.ryanpeikou = 1; } else if (count >= 1) { m_Result.iipeikou = 1; }}void CBasePlayer::CalcResult_sansiki(){ int i, j; for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (!(m_Hand.m_TileSets[i].type & (HT_OPENCHOW | HT_CLOSEDCHOW))) { continue; } CTile t = m_Hand.m_TileSets[i].first; if (t.GetSuit() != TILESUIT_CHAR) { continue; } bool b[2] = {false, false}; for (j = 0; j < m_Hand.m_iNumTileSets; j++) { if (!(m_Hand.m_TileSets[j].type & (HT_OPENCHOW | HT_CLOSEDCHOW))) { continue; } CTile s = m_Hand.m_TileSets[j].first; if (s.GetValue() == t.GetValue()) { if (s.GetSuit() == TILESUIT_BAMBOO) { b[0] = true; } else if (s.GetSuit() == TILESUIT_CIRCLE) { b[1] = true; } } } if (b[0] && b[1]) { m_Result.sansiki = 1; return; // success! } }}void CBasePlayer::CalcResult_sansiki_doukoku(){ int i, j; const int flags = (HT_OPENPUNG | HT_CLOSEDPUNG | HT_OPENKONG | HT_CLOSEDKONG); for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (!(m_Hand.m_TileSets[i].type & flags)) { continue; } CTile t = m_Hand.m_TileSets[i].first; if (t.GetSuit() != TILESUIT_CHAR) { continue; } bool b[2] = {false, false}; for (j = 0; j < m_Hand.m_iNumTileSets; j++) { if (!(m_Hand.m_TileSets[j].type & flags)) { continue; } CTile s = m_Hand.m_TileSets[j].first; if (s.GetValue() == t.GetValue()) { if (s.GetSuit() == TILESUIT_BAMBOO) { b[0] = true; } else if (s.GetSuit() == TILESUIT_CIRCLE) { b[1] = true; } } } if (b[0] && b[1]) { m_Result.sansiki_doukoku = 1; return; // success! } }}void CBasePlayer::CalcResult_toitoi(){ if (m_Result.chitoitu) { return; } for (int i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & (HT_OPENCHOW | HT_CLOSEDCHOW)) return; // found a chew, fail! } m_Result.toitoi = 1; // all are pungs, success!}void CBasePlayer::CalcResult_junchan(){ if (m_Result.honraotou) { return; } bool mixed = false; if (m_Hand.m_iNumTileSets <= 0) { return; // fail } for (int i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & (HT_OPENCHOW | HT_CLOSEDCHOW)) { int v = m_Hand.m_TileSets[i].first.GetValue(); if (v != 1 && v != 7) { return; // fail } } else { const CTile &t = m_Hand.m_TileSets[i].first; if (!t.IsMajor()) { return; // fail } if (!t.IsNumMajor()) { mixed = true; } } } if (mixed) { m_Result.chanta = 1; } else { m_Result.junchan = 1; }}void CBasePlayer::CalcResult_ittu(){ for (int i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & (HT_OPENCHOW | HT_CLOSEDCHOW)) { const CTile &t = m_Hand.m_TileSets[i].first; if (t.GetValue() == 1) { bool h[2] = {false, false}; for (int j = 0; j < m_Hand.m_iNumTileSets; j++) { if (m_Hand.m_TileSets[j].type & (HT_OPENCHOW | HT_CLOSEDCHOW)) { const CTile &s = m_Hand.m_TileSets[j].first; if (s.GetSuit() != t.GetSuit()) { continue; } else if (s.GetValue() == 4) { h[0] = true; } else if (s.GetValue() == 7) { h[1] = true; } } } if (h[0] && h[1]) { m_Result.ittu = 1; return; // success! } } } }}void CBasePlayer::CalcResult_chinitu(){ int suit = m_Hand.m_Tiles[0].tile.GetSuit(); for (int i = 1; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].tile.GetSuit() != suit) return; // fail! } m_Result.chinitu = 1; // success!}void CBasePlayer::CalcResult_honitu(){ if (m_Result.chinitu) return; int i, suit = -1; for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (!(m_Hand.m_Tiles[i].tile.GetSuit() & (TILESUIT_DRAGON | TILESUIT_WIND))) { suit = m_Hand.m_Tiles[i].tile.GetSuit(); break; } } if (suit == -1) return; // fail! for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].tile.GetSuit() != suit && !(m_Hand.m_Tiles[i].tile.GetSuit() & (TILESUIT_DRAGON | TILESUIT_WIND))) { return; // fail! } } m_Result.honitu = 1; // success!}void CBasePlayer::CalcResult_chitoitu(){ int i; for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (!(m_Hand.m_Tiles[i].flags & HT_PAIR)) { return; // fail! } } m_Result.chitoitu = 1; // success! m_Result.fu = 25; m_Result.selfdrawn = false; m_Result.tumo = 0; m_Result.pinfu = 0; for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].flags & HT_JUSTGOT) { m_Result.tumo = 1; m_Result.selfdrawn = true; } }}void CBasePlayer::CalcResult_honraotou(){ for (int i = 0; i < m_Hand.m_iNumTiles; i++) { if (!m_Hand.m_Tiles[i].tile.IsMajor()) return; // fail! } m_Result.honraotou = 1; // success!}void CBasePlayer::CalcResult_haitei(){ int i; if (m_pOpponent->m_iNumDiscarded >= 20 || m_iNumDiscarded >= 20) { for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & HT_TUMO) { m_Result.haitei = 1; break; } else if ((m_Hand.m_TileSets[i].type & HT_RON) && m_iNumDiscarded >= 20) { m_Result.houtei = 1; break; } } if (m_Hand.m_iNumTileSets <= 0) { for (i = 0; i < m_Hand.m_iNumTiles; i++) { if (m_Hand.m_Tiles[i].flags & HT_JUSTGOT) { m_Result.haitei = 1; break; } else if ((m_Hand.m_Tiles[i].flags & HT_FROMOPPONENT) && m_iNumDiscarded >= 20) { m_Result.houtei = 1; break; } } } }}void CBasePlayer::CalcResult_rinshan(){ if (m_iState & PS_KONGED) { m_Result.rinshan = 1; }}void CBasePlayer::CalcResult_fanpai(){ int count = 0, i; for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (!(m_Hand.m_TileSets[i].type & (HT_OPENPUNG | HT_CLOSEDPUNG | HT_OPENKONG | HT_CLOSEDKONG))) continue; const CTile &t = m_Hand.m_TileSets[i].first; if (t.GetSuit() == TILESUIT_DRAGON || t == ((gpGame->GetRound() == TURN_EAST) ? CTile("EW") : CTile("SW"))) count++; if (t == ((m_iTurn == TURN_EAST) ? CTile("EW") : CTile("SW"))) count++; } m_Result.fanpai = count;}void CBasePlayer::CalcResult_dora(){ for (int i = 0; i < m_Hand.m_iNumTiles; i++) { m_Result.dora += gpGame->IsDora(m_Hand.m_Tiles[i].tile, m_fReach); }}void CBasePlayer::CalcFu(){ if (m_Result.chitoitu) { m_Result.fu = 25; return; } int i, fu = 20, n, ron = 0; for (i = 0; i < m_Hand.m_iNumTileSets; i++) { if (m_Hand.m_TileSets[i].type & HT_OPENKONG) { n = 8; if (m_Hand.m_TileSets[i].first.IsMajor()) n *= 2; fu += n; } else if (m_Hand.m_TileSets[i].type & HT_CLOSEDKONG) { n = 16; if (m_Hand.m_TileSets[i].first.IsMajor()) n *= 2; fu += n; } else if (m_Hand.m_TileSets[i].type & HT_OPENPUNG) { n = 2; if (m_Hand.m_TileSets[i].first.IsMajor()) n *= 2; fu += n; } else if (m_Hand.m_TileSets[i].type & HT_CLOSEDPUNG) { n = 4; if (m_Hand.m_TileSets[i].first.IsMajor()) n *= 2; fu += n; } else if (m_Hand.m_TileSets[i].type & HT_PAIR) { const CTile &t = m_Hand.m_TileSets[i].first; if (t.GetSuit() == TILESUIT_DRAGON || t == ((gpGame->GetRound() == TURN_EAST) ? CTile("EW") : CTile("SW"))) { fu += 2; } if (t == ((m_iTurn == TURN_EAST) ? CTile("EW") : CTile("SW"))) { fu += 2; } } if (m_Hand.m_TileSets[i].type & HT_RON) { ron = 1; handtile_t *p[3] = {NULL, NULL, NULL}, *pt; int count = 0, j; for (j = 0; j < m_Hand.m_iNumTiles; j++) { if (m_Hand.m_Tiles[j].tileset == i) { assert(count < 3); p[count++] = &m_Hand.m_Tiles[j]; } } assert(count >= 2); if (count == 2) { fu += 2; } else if (m_Hand.m_TileSets[i].type & HT_OPENCHOW) { for (j = 0; j < count; j++) { if (p[j]->flags & HT_FROMOPPONENT) { pt = p[0]; p[0] = p[j]; p[j] = pt; break; } } if (p[1]->tile > p[2]->tile) { pt = p[1]; p[1] = p[2]; p[2] = pt; } if (p[0]->tile() == p[1]->tile() + 1 && p[0]->tile() == p[2]->tile() - 1) { fu += 2; } else { if ((p[0]->tile.GetValue() == 3 && p[1]->tile.GetValue() == 1) || (p[0]->tile.GetValue() == 7 && p[1]->tile.GetValue() == 8)) { fu += 2; } } } } else if (m_Hand.m_TileSets[i].type & HT_TUMO) { if (m_Result.concealed) { m_Result.tumo = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -