示例#1
0
void CTaxasRoom::onPlayerWillStandUp(ISitableRoomPlayer* pPlayer )
{
	if ( pPlayer->isHaveState(eRoomPeer_WaitCaculate) )
	{
		ISitableRoom::onPlayerWillStandUp(pPlayer) ;
		return ;
	}

	if ( pPlayer->isHaveState(eRoomPeer_StayThisRound) )
	{
		if ( getCurRoomState()->getStateID() != eRoomState_DidGameOver )
		{
			CTaxasPlayer* p = (CTaxasPlayer*)pPlayer ;
			LOGFMTE("will stand up update offset uid = %d",pPlayer->getUserUID());

			if ( getDelegate() )
			{
				getDelegate()->onUpdatePlayerGameResult(this,pPlayer->getUserUID(),p->getGameOffset());
			}
		}
		else
		{
			LOGFMTI("if here update player uid = %d offeset will occure a bug ",pPlayer->getUserUID() ) ;
		}
	}
	playerDoStandUp(pPlayer);
}
示例#2
0
void IRoom::onPlayerEnterRoom(stEnterRoomData* pEnterRoomPlayer ,int8_t& nSubIdx)
{
	stStandPlayer* pp = getPlayerByUserUID(pEnterRoomPlayer->nUserUID);
	stStandPlayer * pStandPlayer = nullptr ;
	if ( pp )
	{
		LOGFMTE("player uid = %d , already in this room, can not enter twice, data svr crashed ?",pEnterRoomPlayer->nUserUID) ;
		pStandPlayer = pp ;
		pStandPlayer->nUserSessionID = pEnterRoomPlayer->nUserSessionID;
	}
	else
	{
		pStandPlayer = new stStandPlayer ;
		memset(pStandPlayer,0,sizeof(stStandPlayer));
	}

	memcpy_s(pStandPlayer,sizeof(stStandPlayer),pEnterRoomPlayer,sizeof(stEnterRoomData));
	if ( getDelegate() && getDelegate()->isOmitNewPlayerHalo(this)  )
	{
		pStandPlayer->nNewPlayerHaloWeight = 0 ;
		LOGFMTD("room id = %d omit new player halo so halo weith = 0  for uid = %d", getRoomID(),pStandPlayer->nUserUID) ;
	}

	addRoomPlayer(pStandPlayer) ;
}
示例#3
0
void ISitableRoom::onGameDidEnd()
{
	for ( uint8_t nIdx = 0 ; nIdx < m_nSeatCnt ; ++nIdx )
	{
		auto pPlayer = m_vSitdownPlayers[nIdx] ;
		if ( pPlayer == nullptr )
		{
			continue;
		}

		if ( pPlayer->isHaveState(eRoomPeer_StayThisRound) && getDelegate() )
		{
			getDelegate()->onUpdatePlayerGameResult(this,pPlayer->getUserUID(),pPlayer->getGameOffset()) ;
			LOGFMTD("update room peer offset uid = %u, offset = %d",pPlayer->getUserUID(),pPlayer->getGameOffset());
		}

		if ( pPlayer->getNoneActTimes() >= getMaxNoneActTimeForStandUp() || (pPlayer->isDelayStandUp() || pPlayer->getCoin() < coinNeededToSitDown() || (getDelegate() && getDelegate()->isPlayerLoseReachMax(this,pPlayer->getUserUID())) ) )
		{
			playerDoStandUp(pPlayer);	
			pPlayer = nullptr ;
			m_vSitdownPlayers[nIdx] = nullptr ;
		}

		if ( pPlayer )
		{
			pPlayer->onGameEnd() ;
		}
	}
	m_vSortByPeerCardsAsc.clear();
	IRoom::onGameDidEnd() ;
}
		void SceneDirector::pop()
		{
			if(getDelegate())
			{
				getDelegate()->onSceneWillDie(this, *_scenes.back().first);
			}
			_scenes.pop_back();
		}
示例#5
0
void ISitableRoom::playerDoStandUp( ISitableRoomPlayer* pPlayer )
{
	m_pRobotDispatchStrage->onRobotLeave(pPlayer->getSessionID()) ;
	// remove from m_vSortByPeerCardsAsc ;
	auto iterSort = m_vSortByPeerCardsAsc.begin() ;
	for ( ; iterSort != m_vSortByPeerCardsAsc.end(); ++iterSort )
	{
		if ( *iterSort == pPlayer )
		{
			m_vSortByPeerCardsAsc.erase(iterSort) ;
			break;
		}
	}

	// remove other player data ;
	assert(isSeatIdxEmpty(pPlayer->getIdx()) == false && "player not sit down" );
	pPlayer->willStandUp();
	m_vSitdownPlayers[pPlayer->getIdx()] = nullptr ;
	auto standPlayer = getPlayerByUserUID(pPlayer->getUserUID()) ;
	
	if ( pPlayer->isHaveState(eRoomPeer_StayThisRound) )
	{
		LOGFMTD("uid = %d invoke game end , before stand up",pPlayer->getUserUID()) ;
		pPlayer->onGameEnd();
	}

	if ( standPlayer == nullptr )
	{
		if ( getDelegate() )
		{
			getDelegate()->onDelayPlayerWillLeaveRoom(this,pPlayer) ;
		}
	}
	else
	{
		standPlayer->nCoin += pPlayer->getCoin() ;
		standPlayer->nNewPlayerHaloWeight = pPlayer->getHaloWeight() ;
		standPlayer->nPlayerTimes += pPlayer->getPlayTimes();
		standPlayer->nWinTimes += pPlayer->getWinTimes();
		standPlayer->nGameOffset += pPlayer->getTotalGameOffset() ;
		if ( pPlayer->getSingleWinMost() > standPlayer->nSingleWinMost )
		{
			standPlayer->nSingleWinMost = pPlayer->getSingleWinMost() ;
		}
		LOGFMTD("player uid = %d just normal stand up ",pPlayer->getUserUID() ) ;
	}

	stMsgRoomStandUp msgStandUp ;
	msgStandUp.nIdx = pPlayer->getIdx() ;
	sendRoomMsg(&msgStandUp,sizeof(msgStandUp));

	m_vReserveSitDownObject.push_back(pPlayer) ;
}
		void SceneDirector::push(ScenePtr scene, PushType::Type pushType)
		{
			assert(scene != NULL);
			
			if(getDelegate())
			{
				getDelegate()->onSceneWillBeAddedToStack(this, *scene);
			}
			
			_scenes.push_back(ScenePair(scene, pushType));
			
			if(getDelegate())
			{
				getDelegate()->onSceneHasBeenAddedToStack(this, *scene);
			}
			
			if(getDelegate())
			{
				getDelegate()->onSceneWillBeInitialized(this, *scene);
			}
			
			// initialize the scene
			scene->initialize();
			
			if(getDelegate())
			{
				getDelegate()->onSceneHasBeenInitialized(this, *scene);
			}
		}
示例#7
0
bool IRoom::onMessage( stMsg* prealMsg , eMsgPort eSenderPort , uint32_t nPlayerSessionID )
{
	if ( m_pCurRoomState && m_pCurRoomState->onMessage(prealMsg,eSenderPort,nPlayerSessionID) )
	{
		return true ;
	}

	switch ( prealMsg->usMsgType )
	{
	case MSG_MODIFY_ROOM_RANK:
		{
			stMsgRobotModifyRoomRank* pRet = (stMsgRobotModifyRoomRank*)prealMsg ;
			if ( getDelegate() && getPlayerByUserUID(pRet->nTargetUID) )
			{
				getDelegate()->onUpdatePlayerGameResult(this,pRet->nTargetUID,pRet->nOffset);
				LOGFMTI("modify uid = %u offset = %d",pRet->nTargetUID,pRet->nOffset) ;
			}
			else
			{
				LOGFMTE("modify room rank uid = %u not in room ", pRet->nTargetUID);
			}
		}
		break;
	case MSG_PLAYER_LEAVE_ROOM:
		{
			LOGFMTD("player apply to leave ") ;
			stMsgPlayerLeaveRoomRet msg ;
			stStandPlayer* pp = getPlayerBySessionID(nPlayerSessionID) ;
			if ( pp )
			{
				onPlayerWillLeaveRoom(pp) ;
				LOGFMTD("do leave remove object") ;
				playerDoLeaveRoom(pp);
				msg.nRet = 0 ;
			}
			else
			{
				msg.nRet = 1 ;
				LOGFMTE("session id not in this room how to leave session id = %d",nPlayerSessionID) ;
			}
			sendMsgToPlayer(&msg,sizeof(msg),nPlayerSessionID) ;
			LOGFMTD("finish leave room msg");
		}
		break;
	default:
		return false ;
	}

	return true ;
}
示例#8
0
uint8_t IRoom::canPlayerEnterRoom( stEnterRoomData* pEnterRoomPlayer )  // return 0 means ok ;
{
	stStandPlayer* pp = getPlayerByUserUID(pEnterRoomPlayer->nUserUID);
	if ( pp )
	{
		LOGFMTE("player uid = %d , already in this room, can not enter twice",pEnterRoomPlayer->nUserUID) ;
		//return 0;
	}

	if ( getDelegate() )
	{
		return getDelegate()->canPlayerEnterRoom(this,pEnterRoomPlayer) ;
	}
	return 0 ;
}
void Pull2RefreshTableView::scrollViewDidScroll(CCScrollView* view)
{
	// judge offset to trigger refresh
	float fDis = getPullDistance();
	Pull2RefreshTableViewDelegate* pDelegate = getDelegate();

	switch(m_nPullType)
	{
		case kPull2RefreshTypeDown:
			// if (m_nPullActionStatus == kPull2RefreshStatusPullDownReleaseToRefresh)
			// {
			// 	// reset stauts
			// 	m_nPullActionStatus = kPull2RefreshStatusNormal;
			// }
			if (pDelegate)
			{
				pDelegate->onPullDownDidScroll(this, fDis, m_fPullDownThreshold);
			}
			break;
		case kPull2RefreshTypeUp:
			// if (m_nPullActionStatus == kPull2RefreshStatusPullUpReleaseToRefresh)
			// {
			// 	// reset status
			// 	m_nPullActionStatus = kPull2RefreshStatusNormal;
			// }
			if (pDelegate)
			{
				pDelegate->onPullUpDidScroll(this, fDis, m_fPullUpThreshold);
			}
			break;
	}

	CCTableView::scrollViewDidScroll(view);
}
示例#10
0
QPointer<Ui::RoundButton> BoxContent::addLeftButton(
		Fn<QString()> textFactory,
		Fn<void()> clickCallback) {
	return getDelegate()->addLeftButton(
		std::move(textFactory),
		std::move(clickCallback),
		st::defaultBoxButton);
}
示例#11
0
bool CMJRoomBattleEnd::isGameOver()
{
	if ( getDelegate() && getDelegate()->canGameOver(this) )
	{
		return true ;
	}

	if ( getLeftCardCnt() <= 0 )
	{
		return true ;
	}

	if ( getPlayerCntWithState(eRoomPeer_AlreadyHu) >= getSeatCount() - 1 )
	{
		return true ;
	}
	return false ;
}
示例#12
0
void IRoom::playerDoLeaveRoom( stStandPlayer* pp )
{
	// send msg to data svr tell player leave room ;
	if ( pp )
	{
		if ( getDelegate() )
		{
			getDelegate()->onPlayerWillDoLeaveRoom(this,pp) ;
		}
		LOGFMTD("uid = %d , do leave this room ",pp->nUserUID) ;
		removePlayer(pp);
	}
	else
	{
		LOGFMTE("player , not in this room can not do leave room" ) ;
	}
	
}
示例#13
0
void ProxyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
	const QModelIndex &index) const
{
	BaseDelegate * delegete = getDelegate(index);

	if(delegete)
		delegete->paint(painter, option, index);
	else
		QItemDelegate::paint(painter, option, index);
}
示例#14
0
void ProxyDelegate::updateEditorGeometry(QWidget *editor,
	const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	BaseDelegate * delegete = getDelegate(index);

	if(delegete)
		delegete->updateEditorGeometry(editor, option, index);
	else
		QItemDelegate::updateEditorGeometry(editor, option, index);
}
示例#15
0
void ProxyDelegate::setEditorData(QWidget *editor,
	const QModelIndex &index) const
{
	BaseDelegate * delegete = getDelegate(index);

	if(delegete)
		delegete->setEditorData(editor, index);
	else
		QItemDelegate::setEditorData(editor, index);
}
示例#16
0
void ProxyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
	const QModelIndex &index) const
{
	BaseDelegate * delegete = getDelegate(index);

	if(delegete)
		delegete->setModelData(editor, model, index);
	else
		QItemDelegate::setModelData(editor, model, index);
}
示例#17
0
QWidget *ProxyDelegate::createEditor(QWidget *parent,
	const QStyleOptionViewItem &option,
	const QModelIndex &index) const
{
	BaseDelegate * delegete = getDelegate(index);

	if(delegete)
		return delegete->createEditor(parent, option, index);

	return QItemDelegate::createEditor(parent, option, index);
}
		void SceneDirector::remove(ScenePtr scene)
		{
			// loop through all the scenes in the array
			for(SceneStack::iterator i = _scenes.begin(); i != _scenes.end(); ++i)
			{
				// if we have a match
				if(i->first.get() == scene)
				{
					if(getDelegate())
					{
						getDelegate()->onSceneWillDie(this, *i->first.get());
					}
					
					// erase the crap out of it
					_scenes.erase(i);
					
					
					break; // break out of the loop
				}
			}
		}
void RepeatedTimeData::init(TimePlotParams *timePlotParams) {
    PartialTimeDataParams* _baseProp=dynamic_cast<PartialTimeDataParams*>(GenericTimeData::getDataParameters());
    Q_ASSERT(_baseProp);
    DataUiHandlerDelegate* _delegate=getDelegate();
    RepeatedTimeDataParams* _derivedProp=new RepeatedTimeDataParams( _baseProp,timePlotParams,(QObject*)this);
    DataUiHandlerProperty* _castedDerivedProp=dynamic_cast<DataUiHandlerProperty*>(_derivedProp);
    _delegate->replacePropertiesAndUI(_castedDerivedProp,
                                      dynamic_cast<DataUiHandlerUI*> (new RepeatedTimeDataUI() ));
    RepeatedTimeDataParams* _rtp=dynamic_cast<RepeatedTimeDataParams*>(getDataParameters());
    Q_ASSERT(_rtp);
    _rtp->setBlankTime(REPEATEDTIMEDATA_DEFAULT_BLANK);
    _rtp->setDuration(PARTIALTIMEDATA_DEFAULT_DURATION/(REPEATEDTIMEDATA_DEFAULT_BLANK*2));
    updateRepetitions();
    connectSignals();
}
示例#20
0
void BoxContent::setInner(object_ptr<TWidget> inner, const style::ScrollArea &st) {
	if (inner) {
		getDelegate()->setLayerType(true);
		_scroll.create(this, st);
		_scroll->setGeometryToLeft(0, _innerTopSkip, width(), 0);
		_scroll->setOwnedWidget(std::move(inner));
		if (_topShadow) {
			_topShadow->raise();
			_bottomShadow->raise();
		} else {
			_topShadow.create(this);
			_bottomShadow.create(this);
		}
		if (!_preparing) {
			// We didn't set dimensions yet, this will be called from finishPrepare();
			finishScrollCreate();
		}
	} else {
		getDelegate()->setLayerType(false);
		_scroll.destroyDelayed();
		_topShadow.destroyDelayed();
		_bottomShadow.destroyDelayed();
	}
}
void Pull2RefreshTableView::onPullDownRefresh()
{
	Pull2RefreshTableViewDelegate* pDelegate = getDelegate();
	if (pDelegate && pDelegate->onPullDownRefresh(this))
	{
		if (m_pHeader)
		{
			// set header node show in offset
			// CCLOG("view.height=%0.2f, container.height=%0.2f, header.height=%0.2f, offset.y=%0.2f", getViewSize().height, getContentSize().height, m_pHeader->getContentSize().height, getContentOffset().y);
			stopScrollAnimation();
			CCPoint offset = ccp(0, getViewSize().height - getContentSize().height - m_pHeader->getContentSize().height);
			this->setContentOffsetInDuration(offset, 0.2f);
		}
	}
}
void Pull2RefreshTableView::onPullUpRefresh()
{
	Pull2RefreshTableViewDelegate* pDelegate = getDelegate();
	if (pDelegate && pDelegate->onPullUpRefresh(this))
	{
		if (m_pFooter)
		{
			stopScrollAnimation();
			float fOffsetY = getViewSize().height - getContentSize().height;
			fOffsetY = fOffsetY < 0 ? 0 : fOffsetY;
			CCPoint offset = ccp(0, fOffsetY + m_pFooter->getContentSize().height);
			this->setContentOffsetInDuration(offset, 0.2f);
		}
	}
}
示例#23
0
uint8_t CTaxasRoom::OnPlayerAction( uint8_t nSeatIdx ,eRoomPeerAction act , uint32_t& nValue )
{
	if ( nSeatIdx >= getSeatCount() || getPlayerByIdx(nSeatIdx) == nullptr )
	{
		return 2 ;
	}

	if ( nSeatIdx != m_nCurWaitPlayerActionIdx && act != eRoomPeerAction_GiveUp )
	{
		return 1 ;
	}

	if ( getPlayerByIdx(nSeatIdx)->isHaveState(eRoomPeer_CanAct) == false )
	{
		return 3 ;
	}

	CTaxasPlayer* pData = (CTaxasPlayer*)getPlayerByIdx(nSeatIdx) ;
	switch ( act )
	{
	case eRoomPeerAction_GiveUp:
		{
			m_nCurMainBetPool += pData->getBetCoinThisRound() ;
			pData->setCurActType(eRoomPeerAction_GiveUp);
			pData->setState(eRoomPeer_GiveUp);
			// remove from vice pool
			for ( uint8_t nIdx = 0 ; nIdx < MAX_PEERS_IN_TAXAS_ROOM; ++nIdx )
			{
				if ( m_vAllVicePools[nIdx].bUsed == false )
				{
					break;
				}
				m_vAllVicePools[nIdx].RemovePlayer(nSeatIdx) ;
			}
		}
		break;
	case eRoomPeerAction_Follow:
		{
			if ( pData->getCoin() + pData->getBetCoinThisRound() <= m_nMostBetCoinThisRound )
			{
				nValue = pData->getCoin() ; // when all in must tell what value have allIned 
				return OnPlayerAction(nSeatIdx,eRoomPeerAction_AllIn,nValue);
			}
			pData->setCurActType(act);
			pData->betCoin(m_nMostBetCoinThisRound - pData->getBetCoinThisRound()) ;
		}
		break;
	case eRoomPeerAction_Add:
		{
			if ( pData->getCoin() <= nValue )
			{
				nValue = pData->getCoin() ; // when all in must tell what value have allIned
				return OnPlayerAction(nSeatIdx,eRoomPeerAction_AllIn,nValue);
			}

			if ( pData->getBetCoinThisRound() + nValue < m_nMostBetCoinThisRound + m_nLittleBlind * 2  )
			{
				return 6 ;
			}

			if ( ((pData->getBetCoinThisRound() + nValue) - m_nMostBetCoinThisRound ) % (m_nLittleBlind * 2) != 0  )
			{
				return 7 ;
			}

			pData->setCurActType(act);
			pData->betCoin(nValue) ;
			m_nMostBetCoinThisRound = pData->getBetCoinThisRound() ;
		}
		break;
	case eRoomPeerAction_AllIn:
		{
			pData->setCurActType(act);
			pData->setState(eRoomPeer_AllIn);
			nValue = pData->getCoin() ;
			pData->betCoin(nValue) ;
			if ( pData->getBetCoinThisRound() == 0 )
			{
				pData->setBetCoinThisRound(1);// avoid 0 all In bug ;
				LOGFMTE("room id = %d , 0 coin all in player idx = %d, uid = %d",getRoomID(),nSeatIdx,pData->getUserUID()) ;
			}

			if ( pData->getBetCoinThisRound() > m_nMostBetCoinThisRound )
			{
				m_nMostBetCoinThisRound = pData->getBetCoinThisRound() ;
			}
		}
		break;
	case eRoomPeerAction_Pass:
		{
			if ( m_nMostBetCoinThisRound != pData->getBetCoinThisRound() )
			{
				return 5 ;
			}

			pData->setCurActType(eRoomPeerAction_Pass);
		}
		break;
	default:
		return 4 ;
	}

	stMsgTaxasRoomAct msgOtherAct ;
	msgOtherAct.nPlayerAct = act ;
	msgOtherAct.nPlayerIdx = nSeatIdx ;
	msgOtherAct.nValue = nValue ;
	sendRoomMsg(&msgOtherAct,sizeof(msgOtherAct)) ;
	LOGFMTD("player do act") ;

	if ( pData->isDelayStandUp() && act == eRoomPeerAction_GiveUp )
	{
		LOGFMTD("uid = %d have delay standup , give up act , right standup and update offset ",pData->getUserUID());
		if ( getDelegate() )
		{
			getDelegate()->onUpdatePlayerGameResult(this,pData->getUserUID(),pData->getGameOffset());
		}
		playerDoStandUp(pData);	
	}

	return 0 ;
}
示例#24
0
X_VOID	MainGame::ConnectServerDone(X_BOOL nRet)
{
	NetworkSystem* pNetworkSystem =  NetworkSystem::GetSingleton();
	if(pNetworkSystem == X_NULL)
		return;
	if(nRet)
	{
			SettingData::onEnterServer(Game::sm_SelectServer);
			pNetworkSystem->SetNetworkState(NetworkSystem::NET_DATA_WORKING);

			if(LOGIN_CONNECT)
			{
				MainGame::GetSingleton()->AskRolelist();
			}
			else
				SetGameMainProState(RUNING_IN_LOGIN);


	}else
	{
			DataPool::GetSingleton()->bConnect = false;
			pNetworkSystem->SetNetworkState(NetworkSystem::NET_NORMAL);
			pNetworkSystem->DisconnectServer();
			if(LOGIN_CONNECT)
			{
				m_nGameRunState = NONE_STATE;
			

			}else
			{
				SetGameMainProState(NONE_STATE);	
			}
			// vector<string> strV;strV.clear();
			// strV.push_back(UtilTools::GET_TEXT_FROM_LANG(615));
			//EventSystem::GetSingleton()->PushEvent(GAME_EVENT_TIP_UPDATA,strV);
			//wstring str = UtilTools::utf8_wchar(strV[0].c_str());
			//OutputDebugString(str.c_str());
			 
			ModalDialogView * pView = ModalDialogView::createDialog(UtilTools::GET_TEXT_FROM_LANG(615),getDelegate() ,DIALOG_MODEL_SINGLE);
			SceneManger::GetSingleton()->AddChildToScene(pView,true);

			 

#ifdef _WINDOWS_
			//MessageBoxA(0,"网络异常","error",MB_OK);
#endif // _WINDOWS_
 
	}
}