/** * @brief 计时时间到触发的时间 */ void CSoMJFrameLogic::OnTimeOut(int nTimerID) { _DOUT1("OnTimerOut(%d)", nTimerID); CMJSoStateMgr<PLAYER_NBR>::OnTimeOut(nTimerID); if (MJ_TIMER_GIVE == nTimerID) { m_nTimeOutCount[GetTurn()]++; if (m_nTimeOutCount[GetTurn()] >= MJ_TURST_TIMEOUT_MAX) { m_nTimeOutCount[GetTurn()] = 0; // 玩家超时数次超过 MJ_TURST_TIMEOUT_MAX 次, 默认托管 if (NULL != m_pSoUserMgr) { m_pSoUserMgr->SetPlayerTrusteeStatus(GetTurn(), TRUE); } } } }
// 换牌功能 BOOL CSoMJFrameLogic::TransGMCmdSwap(int nChair, char* pStr) { int i; char chStr[2], * pData1, *pData2; TILE tile; // 获取需要交换的牌集 pData1 = strtok(pStr, ","); // 获取需要改变的目标牌集 pData2 = strtok(NULL, " "); if (pData1 == NULL || pData2 == NULL) { return FALSE; } if (strncmp("*", pData1, strlen("*")) == 0) { // * 号, 更换所有手牌 int nDataLength = Mystrnlen(pData2, 128); //int nDataLength = strlen(pData2); CMJHand mjHand; mjHand.ReleaseAll(); for (i = 0; i < nDataLength; i += 2) { chStr[0] = pData2[i]; chStr[1] = pData2[i+1]; // 将字符串转换成一张牌 tile = TransChatToTile(chStr); if (tile > TILE_BEGIN) { mjHand.AddTile(tile); } } // 判断换的牌数据长度, 是否等于换牌玩家手牌长度 if (mjHand.CurrentLength() == m_TilesHand[nChair].CurrentLength()) { // 换牌 m_TilesHand[nChair] = mjHand; // 强刷更新客户端牌数据 UpdateHandTiles(nChair); // 判断当前是否为出牌玩家 if (GetTurn() == nChair) { if (m_TilesHand[nChair].CurrentLength() % 3 == 2) { // 检测换牌后, 是否可以拦牌 if (CheckBlock(nChair)) { m_pStateEvent->SetMJState(MJ_STATE_BLOCK); GetSoGameProcess()->SendGameDataToSeat((UINT)nChair, (char*)&GetBlockInfo(nChair), sizeof(TCMD_NOTIFY_BLOCK)); } } } return TRUE; } } else { // 更换手里已经有的牌 int nDataLength1 = Mystrnlen(pData1, 128); int nDataLength2 = Mystrnlen(pData2, 128); // 判断要交换的牌长度是否相等 if (nDataLength1 == nDataLength2) { CMJHand mjHand, tmpHand; mjHand.ReleaseAll(); tmpHand.ReleaseAll(); for (i = 0; i < nDataLength1; i += 2) { chStr[0] = pData1[i]; chStr[1] = pData1[i+1]; // 将字符串转换成一张牌 tile = TransChatToTile(chStr); if (tile > TILE_BEGIN) { mjHand.AddTile(tile); } } if (!m_TilesHand[nChair].IsSubSet(mjHand)) { // 要换的牌数据, 在手牌中不存在 return FALSE; } for (i = 0; i < nDataLength2; i += 2) { chStr[0] = pData2[i]; chStr[1] = pData2[i+1]; // 将字符串转换成一张牌 tile = TransChatToTile(chStr); if (tile > TILE_BEGIN) { tmpHand.AddTile(tile); } } if (mjHand.CurrentLength() == tmpHand.CurrentLength()) { // 可以换牌 m_TilesHand[nChair].DelTiles(mjHand); m_TilesHand[nChair].AddTiles(tmpHand); // 强刷更新客户端牌数据 UpdateHandTiles(nChair); // 判断当前是否为出牌玩家 if (GetTurn() == nChair) { if (m_TilesHand[nChair].CurrentLength() % 3 == 2) { // 检测换牌后, 是否可以拦牌 if (CheckBlock(nChair)) { m_pStateEvent->SetMJState(MJ_STATE_BLOCK); } } } return TRUE; } } } return FALSE; }
bool Game_Battle::AreConditionsMet(const RPG::TroopPageCondition& condition) { if (condition.flags.switch_a && !Game_Switches[condition.switch_a_id]) return false; if (condition.flags.switch_b && !Game_Switches[condition.switch_b_id]) return false; if (condition.flags.variable && !(Game_Variables[condition.variable_id] >= condition.variable_value)) return false; if (condition.flags.turn && !CheckTurns(GetTurn(), condition.turn_b, condition.turn_a)) return false; /* TODO RPG 2k3 if (condition.flags.turn_enemy && !CheckTurns(GetEnemy(condition.turn_enemy_id).GetTurns(), condition.turn_enemy_b, condition.turn_enemy_a)) return false; if (condition.flags.turn_actor) { Battle::Ally* ally = FindAlly(condition.turn_actor_id); if (!ally) return false; if (!CheckTurns(ally->GetTurns(), condition.turn_actor_b, condition.turn_actor_a)) return false; }*/ if (condition.flags.fatigue) { int fatigue = Main_Data::game_party->GetFatigue(); if (fatigue < condition.fatigue_min || fatigue > condition.fatigue_max) return false; } if (condition.flags.enemy_hp) { Game_Battler& enemy = (*Main_Data::game_enemyparty)[condition.enemy_id - 1]; int hp = enemy.GetHp(); int hpmin = enemy.GetMaxHp() * condition.enemy_hp_min / 100; int hpmax = enemy.GetMaxHp() * condition.enemy_hp_max / 100; if (hp < hpmin || hp > hpmax) return false; } if (condition.flags.actor_hp) { Game_Actor* actor = Game_Actors::GetActor(condition.actor_id); int hp = actor->GetHp(); int hpmin = actor->GetMaxHp() * condition.actor_hp_min / 100; int hpmax = actor->GetMaxHp() * condition.actor_hp_max / 100; if (hp < hpmin || hp > hpmax) return false; } if (condition.flags.turn_actor) { if (!CheckTurns(Game_Actors::GetActor(condition.actor_id)->GetBattleTurn(), condition.turn_actor_b, condition.turn_actor_a)) { return false; } } /* TODO RPG2k3 if (condition.flags.command_actor) { Battle::Ally* ally = FindAlly(condition.actor_id); if (!ally) return false; if (ally->last_command != condition.command_id) return false; }*/ return true; }