Ejemplo n.º 1
0
//Wyrmgus start
//CChunkParticle::CChunkParticle(CPosition position, GraphicAnimation *smokeAnimation, GraphicAnimation *debrisAnimation,
CChunkParticle::CChunkParticle(CPosition position, int z, GraphicAnimation *smokeAnimation, GraphicAnimation *debrisAnimation,
//Wyrmgus end
							   GraphicAnimation *destroyAnimation,
							   int minVelocity, int maxVelocity, int minTrajectoryAngle, int maxTTL, int drawlevel) :
	//Wyrmgus start
//	CParticle(position, drawlevel), initialPos(position), maxTTL(maxTTL), nextSmokeTicks(0),
	CParticle(position, z, drawlevel), initialPos(position), maxTTL(maxTTL), nextSmokeTicks(0),
	//Wyrmgus end
	age(0), height(0.f)
{
	float radians = deg2rad(MyRand() % 360);
	direction.x = cos(radians);
	direction.y = sin(radians);

	this->minVelocity = minVelocity;
	this->maxVelocity = maxVelocity;
	this->minTrajectoryAngle = minTrajectoryAngle;
	this->initialVelocity = this->minVelocity + MyRand() % (this->maxVelocity - this->minVelocity + 1);
	this->trajectoryAngle = deg2rad(MyRand() % (90 - this->minTrajectoryAngle) + this->minTrajectoryAngle);
	this->lifetime = (int)(1000 * (initialVelocity * sin(trajectoryAngle) / gravity) * 2);
	if (maxTTL) {
		this->lifetime = std::min(maxTTL, this->lifetime);
	}

	this->smokeAnimation = smokeAnimation->clone();
	this->debrisAnimation = debrisAnimation->clone();
	this->destroyAnimation = destroyAnimation->clone();
}
Ejemplo n.º 2
0
//========================================================================================
// 功能 : 前面已经有人敲了
// 参数 : BYTE	byCardType			[in]		当前最大的牌类型
//========================================================================================
void CClientGameDlg::HaveSetAllNote(BYTE byCardType)
{
	int iRand = rand()%100;
	if(byCardType >= ZX_HE_PAI)				//丁皇,天,地,人,和
	{
		SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME);
	}
	else if(byCardType >= ZX_DI_GANG)		//地杠
	{
		if(iRand < 100)						//敲
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME);
		}
		else
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME);
		}
	}
	else									//散牌
	{
		if(iRand < 90)						//敲
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME);
		}
		else
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME);
		}
	}
}
Ejemplo n.º 3
0
void Point::show()
{
	if(iPart==0)
	{
		switch(iSens)
		{
			case 0:
				y -= SPRITE_WIDTH ;
				break;
			case 1:
				x += SPRITE_WIDTH ;
				break;
			case 2:
				y += SPRITE_WIDTH ;
				break;
			case 3:
				x -= SPRITE_WIDTH ;
				break;
		}

		if(  x<0 || y<0 || x + SPRITE_WIDTH > SCREEN_WIDTH || y + SPRITE_WIDTH > SCREEN_HEIGHT)
			bGameOver=true;

		//collision snake
		for(int i=1; i<SNAKE_LENGTH;i++)
		{
			if(collision(x,y,myPoints[i].x,myPoints[i].y))
				bGameOver=true;
		}

		//collision cible
		if(collision(x,y,targetX,targetY))
		{
			targetX=MyRand(0, 14)*SPRITE_WIDTH+25/2;
			targetY=MyRand(0, 11)*SPRITE_WIDTH+25/2;
			iScore++;
		}
	}
	else if (iPart>0)
	{
		x = myPoints[iPart-1].previousPosX;
		y = myPoints[iPart-1].previousPosY;
		iSens = myPoints[iPart-1].previousSens;
	}
	//Affiche le point
	apply_surface( x, y,surface, screen, &clipsSnake[ iSens ] );

	previousPosX = x;
	previousPosY = y;
	previousSens = iSens;
}
Ejemplo n.º 4
0
bool init()
{
    //Initialisation de tous les sous-système de SDL
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }

    //Mise en place de l'écran
    screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );

    //S'il y a eu une erreur lors de la mise en place de l'écran
    if( screen == NULL )
    {
        return false;
    }

	//Initialisation de SDL_mixer
    if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
    {
        return false;
    }

	SDL_Surface *ico = NULL;
	ico = load_image( "sprites/ico.png" );
	SDL_WM_SetIcon(ico,NULL);

    //Mise en place de la barre caption
    SDL_WM_SetCaption( "Snake in your face", NULL );
	FRAMES_PER_SECOND = 2;
	iScore = 0;
	bGameOver = false;
	bCredit = true;
	for(int i = 0;i<SNAKE_LENGTH;i++)
	{
		myPoints[i].iSens=0;
		myPoints[i].previousPosX=0;
		myPoints[i].previousPosY=0;
	}
	myPoints[0].x=SPRITE_WIDTH*3;
	myPoints[0].y=SPRITE_WIDTH*10;
	targetX=MyRand(0, SCREEN_WIDTH)+25;
	targetY=MyRand(0, SCREEN_HEIGHT)+25;

    //Si tout c'est bien passé
    return true;
}
Ejemplo n.º 5
0
void CMixtureGaussianKernel::InitAdaptive(const CVisDMatrix& vCentralData, int nWithin2Sigma)
{
	m_nCluster = vCentralData.NRows();
	m_vData = vCentralData;

	nWithin2Sigma++;
	assert((m_nCluster > nWithin2Sigma)&&(nWithin2Sigma>2));

	// Estimate sigma
	double Sigma;
	{
		double avgDist = 0;

		for (int iStep = 0; iStep < nWithin2Sigma; iStep++ )
		{
			CVisDVector distVec(m_nCluster);
			// Random choose center
			int iChoose = MyRand() * (m_nCluster - 1);
			for (int iData = 0; iData < m_nCluster; iData++ )
			{
				CVisDVector tempVec = vCentralData.Row(iChoose);
				tempVec = tempVec - vCentralData.Row(iData);
				double dist = sqrt(tempVec * tempVec);
				distVec[iData] = dist;
			}
	
			// Find the nWidthin2Sigma-th minvalue
			double fMax = VisDVectorMaxData(distVec);
			double fMin;
			for ( int iMin = 0; iMin < nWithin2Sigma; iMin++ )
			{
				int iTemp = VisDVectorMinIndex(distVec);
				fMin = distVec[iTemp];
				distVec[iTemp] = fMax;
			}	
			
			avgDist += fMin;
		}
		avgDist /= nWithin2Sigma;
		Sigma = avgDist / 2;
	}
	
	m_nDataDimesion = vCentralData.NCols();
	m_vMixingWeight.Resize(m_nCluster);

	double weight = (double)1.0 / m_nCluster;
	for (int iCluster = 0; iCluster < m_nCluster ; iCluster++ )
	{
		m_vMixingWeight[iCluster] = weight;
	}
	
	m_vClusterModel.resize(m_nCluster);
	for (iCluster = 0; iCluster < m_nCluster; iCluster++ )
	{
		m_vClusterModel[iCluster].SetModel(m_nDataDimesion, vCentralData.Row(iCluster), Sigma);
	}
}
Ejemplo n.º 6
0
void
ReInit(void)
{
    int i;
    float deviation;

    deviation = MyRand() / 2;
    deviation = deviation * deviation;
    for (i = 0; i < RINGS; i++) {
        offsets[i][0] = MyRand();
        offsets[i][1] = MyRand();
        offsets[i][2] = MyRand();
        angs[i] = 260.0 * MyRand();
        rotAxis[i][0] = MyRand();
        rotAxis[i][1] = MyRand();
        rotAxis[i][2] = MyRand();
        iters[i] = (deviation * MyRand() + 60.0);
    }
}
Ejemplo n.º 7
0
void CChunkParticle::update(int ticks)
{
	age += ticks;
	if (age >= lifetime) {
		if (destroyAnimation) {
			CPosition p(pos.x, calculateScreenPos(pos.y, height));
			GraphicAnimation *destroyanimation = destroyAnimation->clone();
			//Wyrmgus start
//			StaticParticle *destroy = new StaticParticle(p, destroyanimation, destroyDrawLevel);
			StaticParticle *destroy = new StaticParticle(p, this->MapLayer, destroyanimation, destroyDrawLevel);
			//Wyrmgus end
			ParticleManager.add(destroy);
		}

		destroy();
		return;
	}

	const int minSmokeTicks = 150;
	const int randSmokeTicks = 50;

	if (age > nextSmokeTicks) {
		CPosition p(pos.x, calculateScreenPos(pos.y, height));
		GraphicAnimation *smokeanimation = smokeAnimation->clone();
		//Wyrmgus start
//		CSmokeParticle *smoke = new CSmokeParticle(p, smokeanimation, 0, -22.0f, smokeDrawLevel);
		CSmokeParticle *smoke = new CSmokeParticle(p, MapLayer, smokeanimation, 0, -22.0f, smokeDrawLevel);
		//Wyrmgus end
		ParticleManager.add(smoke);

		nextSmokeTicks += MyRand() % randSmokeTicks + minSmokeTicks;
	}

	debrisAnimation->update(ticks);
	if (debrisAnimation->isFinished()) {
		GraphicAnimation *debrisanimation = debrisAnimation->clone();
		delete debrisAnimation;
		debrisAnimation = debrisanimation;
	}

	float time = age / 1000.f;

	float distance = getHorizontalPosition(initialVelocity, trajectoryAngle, time);
	pos.x = initialPos.x + distance * direction.x;
	pos.y = initialPos.y + distance * direction.y;

	height = getVerticalPosition(initialVelocity, trajectoryAngle, time);
}
Ejemplo n.º 8
0
//========================================================================================
// 功能 : 前面已经有人大了
// 参数 : BYTE	byCardType			[in]		当前最大的牌类型
//========================================================================================
void CClientGameDlg::HaveSetBigNote(BYTE byCardType)
{
	int iRand = rand()%100;
	if(byCardType >= ZX_HE_PAI)				//丁皇,天,地,人,和
	{
		if(iRand < 50)						//跟
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME);
		}
		if(iRand < 85)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME);
		}
		else								//敲
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_SET_ALL_TIME);
		}
	}
	else if(byCardType >= ZX_DI_GANG)		//地杠
	{
		if(iRand < 50)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME);
		}
		else								//跟
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME);
		}
	}
	else									//散牌
	{
		if(iRand < 60)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME);
		}
		else if(iRand < 90)				//跟
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME);
		}
		else								//丢
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_GIVE_UP_TIME);
		}		
	}
}
Ejemplo n.º 9
0
//========================================================================================
// 功能 : 还没有人操作时机器人的操作
// 参数 : BYTE	byCardType			[in]		当前最大的牌类型
//========================================================================================
void CClientGameDlg::NoOneOperator(BYTE	byCardType)	//可操作的有 敲,大,休,丢
{
	int iRand = rand()%100;
	if(byCardType >= ZX_HE_PAI)				//丁皇,天,地,人,和
	{
		if(iRand < 60)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME);
		}
		else								//敲
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME);
		}
	}
	else if(byCardType >= ZX_DI_GANG)		//地杠
	{
		if(iRand < 60)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME);
		}
		else if(iRand < 85)					//休
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_STOP_TIME);
		}
		else								//敲
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME);
		}
	}
	else									//散牌
	{
		if(iRand < 60)						//大
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME);
		}
		else if(iRand < 90)					//休
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_STOP_TIME);
		}
		else								//丢
		{
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME);
		}		
	}
}
Ejemplo n.º 10
0
void CMixtureGKernelSampler::GetOneSampleAndParam(CVisDVector& data, int& j, int method)
{
	const CMixtureGaussianKernel& model = (const CMixtureGaussianKernel&)m_ModelRef;

	float f = MyRand();
	int iCluster = 0;
	while ( iCluster < model.m_nCluster )
	{
		f -= model.m_vMixingWeight[iCluster];	
		if ( f <= 0 )
		{
			break;	
		}
		else
		{
			iCluster++;
		}
	}

	j = iCluster;
	m_vpClusterSampler[j]->GetOneSample(data);
}
Ejemplo n.º 11
0
int Chat::GroupMessage(int32_t AuthCode, int64_t fromGroup, int64_t fromQQ, const char *msg)
{
    string sql_create = "create table if not exists t_b_preset_message (id INTEGER PRIMARY KEY ASC AUTOINCREMENT, key_word TEXT, value_word TEXT, isdel INT DEFAULT (0));";

    char * errmsg = NULL;
    sqlite3_exec(mpDB, sql_create.c_str(), 0, 0, &errmsg );

    if(fromGroup == 194106997)
    {
        char szOutput[2] = {0};
        strncpy(szOutput, msg, 1);

        if(strcmp("#", szOutput) == 0)
        {
            //CQ_sendGroupMsg(AuthCode, fromGroup, "OK");
            char *instructionSet[4096];
            int nSetSize = 0;
            MySplit((char*)msg, "#",instructionSet, &nSetSize);

            char *order = instructionSet[0];
            if(strcmp("关闭", order) == 0)
            {
                CQ_sendGroupMsg(AuthCode, fromGroup, "再见, 再也不见!");
                isSendMsg = 0;
                return EVENT_BLOCK;
            }
            else if(strcmp("开启", order) == 0)
            {
                CQ_sendGroupMsg(AuthCode, fromGroup, "AV8D, 我回来啦!!!");
                isSendMsg = 1;
                return EVENT_BLOCK;
            }
            else if(strcmp("教学", order) == 0)
            {
                string question = instructionSet[1];
                string answer = instructionSet[2];

                char szInsertSQL[1000] = {0};
                sprintf(szInsertSQL, "INSERT INTO t_b_preset_message (key_word, value_word) VALUES('%s', '%s');", question.c_str(), answer.c_str());
                db.execDML(szInsertSQL);
                CQ_sendGroupMsg(AuthCode, fromGroup, "又学了一句!");
                return EVENT_BLOCK;
            }
        }
    }

    if (isSendMsg == 1)
    {
        char szSelectSQL[200] = {0};
        sprintf(szSelectSQL, "select value_word from t_b_preset_message where key_word='%s' and isdel=0", msg);
        query = db.execQuery(szSelectSQL);
        int sendNum = MyRand(query.numFields());
        int index = 0;
        while (!query.eof())
        {
            if (index++ == sendNum)
            {
                CQ_sendGroupMsg(AuthCode, fromGroup, query.fieldValue(0));
                return EVENT_BLOCK;
            }
            query.nextRow();
        }

        CQ_getLoginNick(AuthCode);
        const char * szInfo = CQ_getGroupMemberInfoV2(AuthCode, fromGroup, fromQQ, FALSE);
        return EVENT_IGNORE;
    }
    return EVENT_IGNORE;
}
Ejemplo n.º 12
0
//Wyrmgus start
//void EditorChangeTile(const Vec2i &pos, int tileIndex, int d)
void EditorChangeTile(const Vec2i &pos, int tileIndex)
//Wyrmgus end
{
	//Wyrmgus start
//	Assert(Map.Info.IsPointOnMap(pos));
	Assert(Map.Info.IsPointOnMap(pos, CurrentMapLayer));
	//Wyrmgus end

	// Change the flags
	//Wyrmgus start
//	CMapField &mf = *Map.Field(pos);
	CMapField &mf = *Map.Field(pos, CurrentMapLayer);
	//Wyrmgus end
	int tile = tileIndex;
	if (TileToolRandom) {
		int n = 0;
		for (int i = 0; i < 16; ++i) {
			if (!Map.Tileset->tiles[tile + i].tile) {
				break;
			} else {
				++n;
			}
		}
		n = MyRand() % n;
		int i = -1;
		do {
			while (++i < 16 && !Map.Tileset->tiles[tile + i].tile) {
			}
		} while (i < 16 && n--);
		Assert(i != 16);
		tile += i;
	}
	//Wyrmgus start
	mf.setTileIndex(*Map.Tileset, tile, 0);
//	mf.playerInfo.SeenTile = mf.getGraphicTile();
	mf.UpdateSeenTile();
	//Wyrmgus end
	
	//Wyrmgus start
	Map.CalculateTileTransitions(pos, false, CurrentMapLayer);
	Map.CalculateTileTransitions(pos, true, CurrentMapLayer);
	
	for (int x_offset = -1; x_offset <= 1; ++x_offset) {
		for (int y_offset = -1; y_offset <= 1; ++y_offset) {
			if (x_offset != 0 || y_offset != 0) {
				Vec2i adjacent_pos(pos.x + x_offset, pos.y + y_offset);
				if (Map.Info.IsPointOnMap(adjacent_pos, CurrentMapLayer)) {
					Map.CalculateTileTransitions(adjacent_pos, false, CurrentMapLayer);
					Map.CalculateTileTransitions(adjacent_pos, true, CurrentMapLayer);
				}
			}
		}
	}
	//Wyrmgus end
	
	//Wyrmgus start
	CUnitCache &unitcache = mf.UnitCache;
	std::vector<CUnit *> units_to_remove;

	for (CUnitCache::iterator it = unitcache.begin(); it != unitcache.end(); ++it) {
		CUnit *unit = *it;

		if (!CanBuildUnitType(unit, *unit->Type, pos, 1, true, CurrentMapLayer)) {
			units_to_remove.push_back(unit);
		}
	}
	
	for (size_t i = 0; i < units_to_remove.size(); ++i) {
		EditorActionRemoveUnit(*units_to_remove[i], false);
	}
	//Wyrmgus end

	UI.Minimap.UpdateSeenXY(pos);
	//Wyrmgus start
//	UI.Minimap.UpdateXY(pos);
	UI.Minimap.UpdateXY(pos, CurrentMapLayer);
	//Wyrmgus end

	//Wyrmgus start
//	EditorChangeSurrounding(pos, d);
	EditorChangeSurrounding(pos, tile);
	//Wyrmgus end
}
Ejemplo n.º 13
0
//游戏消息处理函数
bool CClientGameDlg::HandleGameMessage(NetMessageHead * pNetHead, void * pNetData, UINT uDataSize, CTCPClientSocket * pClientSocket)
{
	if (pNetHead->bMainID==MDM_GM_GAME_NOTIFY)
	{
		switch (pNetHead->bAssistantID)
		{
		case ASS_GM_AGREE_GAME:
			{
				if(uDataSize!=sizeof(MSG_GR_R_UserAgree))
				{
					return 0;
				}

				MSG_GR_R_UserAgree * pUser=(MSG_GR_R_UserAgree *)pNetData;

				m_bUserReady[pUser->bDeskStation] = true ;  ///游戏玩家准备状态
				m_bPlayer[pUser->bDeskStation] = true;
				m_byGameStation = 0x00;
				memset(m_i64UseAllNote,0x00,sizeof(m_i64UseAllNote));
				return true;
			}	
		case ASS_BEGIN_UPGRADE:		//游戏开始(设置簸簸时间)
			{
				if (uDataSize!=sizeof(BeginUpgradeStruct))
					return FALSE;
				SetStationParameter(GS_SEND_CARD);
				KillAllTimer();
				SetBoboTime(pNetData,uDataSize);
				return true;
			}
		case ASS_SEND_CARD:			//服务器发牌
			{
				if (uDataSize!=sizeof(SendCardStruct)) 
					return FALSE;
				Ass_Send_Card(pNetData,uDataSize);
				return true;
			}
		case ASS_SC_NOTICE_SEND_CARD:						//通知发牌
			{
				if(uDataSize!=sizeof(T_Notice_SendCard)) 
					return FALSE;
				Ass_Sc_Notice_Send_Card(pNetData, uDataSize);
				return true;
			}
		case ASS_SC_SEND_ONE_CARD_FINSH:							//第二次发牌结束
			{
				Ass_Sc_Send_One_Card_Finsh( pNetData, uDataSize);
				return true;
			}
		case ASS_SEND_FINISH:		//发牌完成
			{	
				return true;
			}
		case ASS_GAME_PLAY:		//开始游戏
			{
				//发牌完成,开始下注
				if (uDataSize!=sizeof(BeginPlayStruct)) 
					return FALSE;
				OnHandleGameBegin( pNetData, uDataSize);
				return true;
			}
		case ASS_NOTE:								//玩家押注情况
			{
				if(sizeof(NoteResult) != uDataSize)
				{
					return FALSE;
				}
				OnHandleBet(pNetData,uDataSize);
				return true;
			}
		case ASS_SC_NOTIC_SEPARET_CARD:
			{
				Ass_Sc_Notic_Separe_Card( pNetData, uDataSize);
				return true;
			}
		case ASS_SALE_END:	//游戏安全结束
		case ASS_CUT_END:	//用户强行离开
		case ASS_CONTINUE_END:	//游戏结束
		case ASS_NO_CONTINUE_END:
			{
				SetStationParameter(GS_WAIT_NEXT);
				ResetGameStation(RS_GAME_BEGIN);
				m_iBeginTime = 1;
				SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 5 +2,ID_BEGIN_TIME);					
				return TRUE;
			}
		case ASS_SET_BOBO_DATA:								//处理玩家设置BoBo
			{
				Ass_SetBobo_Data(pNetData,uDataSize);
				return true;
			}
		case ASS_SC_USER_GIVE_UP:
			{
				return true;
			}
		}
	}
	return __super::HandleGameMessage(pNetHead,pNetData,uDataSize, pClientSocket);
}
Ejemplo n.º 14
0
//----------------------------------------------------------------------------------
//设置游戏状态
bool CClientGameDlg::SetGameStation(void * pStationData, UINT uDataSize)
{
	m_iMyLogDesk = GetMeUserInfo()->bDeskStation;
	switch (GetStationParameter())
	{
	case GS_WAIT_SETGAME:	//游戏没有开始状态
	case GS_WAIT_AGREE:	//等待同意状态
	case GS_WAIT_NEXT:
		{	
			GameStation_2 * pGameStation=(GameStation_2 *)pStationData;
			//设置数据
			m_iThinkTime=pGameStation->iThinkTime;
			m_iBeginTime=pGameStation->iBeginTime;

			//函数调用
			CheckVersion(pGameStation->iVersion,pGameStation->iVersion2);	

			m_iBeginTime=pGameStation->iBeginTime;						//开始时间
			m_byBoBoTime=pGameStation->byBoBoTime;						//设置簸簸时间;
			m_iThinkTime=pGameStation->iThinkTime;						//思考时间
			m_bySeparateCardTime = pGameStation->bySeparateCardTime;	//分牌时间
			m_i64BoBase = pGameStation->i64BoBase;						//簸底
			m_i64SmallBobo = pGameStation->i64SmallBobo;				//最小簸簸
			m_i64TempBobo = m_i64SmallBobo;								//最小簸簸(临时变量)
			m_i64FrontNote = 0;
			memcpy(m_bUserReady , pGameStation->bUserReady ,sizeof(m_bUserReady)) ;
			SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BEGIN_TIME);
			return TRUE;
		}
	case GS_SEND_CARD:	//发牌状态
		{
			GameStation_3 * pGameStation=(GameStation_3 *)pStationData;
			//函数调用
			CheckVersion(pGameStation->iVersion,pGameStation->iVersion2);
			BYTE	byTimeRest;
			m_iBeginTime=pGameStation->iBeginTime;						//开始时间
			m_byBoBoTime=pGameStation->byBoBoTime;						//设置簸簸时间;
			m_iThinkTime=pGameStation->iThinkTime;						//思考时间
			m_bySeparateCardTime = pGameStation->bySeparateCardTime;	//分牌时间
			m_i64BoBase = pGameStation->i64BoBase;						//簸底
			m_i64SmallBobo = pGameStation->i64SmallBobo;				//最小簸簸
			m_i64TempBobo = m_i64SmallBobo;								//最小簸簸(临时变量)
			m_bNtPeople = pGameStation->iUpGradePeople;					//庄家位置
			m_bGameStation = pGameStation->bGameStation;				//大步骤
			m_byGameStation = pGameStation->byGameStation;				//动作小分解
			byTimeRest = pGameStation->iTimeRest;
			m_i64FrontNote = 0;
			::CopyMemory(m_i64Bobo,pGameStation->i64Bobo,sizeof(m_i64Bobo));			//制簸簸数值
			::CopyMemory(m_bPlayer,pGameStation->bPlayer,sizeof(m_bPlayer));			//标记是否是开始时所进入的人
			if(pGameStation->byGameStation == GS_SEND_CARD_TIME)						//发牌时间
			{
				::CopyMemory(m_iDeskCardCount,pGameStation->byAlreadySendCardCount,sizeof(m_iDeskCardCount));	//已经发的牌张数
				::CopyMemory(m_iUserCardCount,pGameStation->iUserCardCount,sizeof(m_iUserCardCount));			//牌总张数
				::CopyMemory(m_bSendCardCount,pGameStation->byAlreadySendCardCount,sizeof(m_bSendCardCount));	//已经发的牌张数
				for(int i = 0x00;i < PLAY_COUNT;i ++)
				{
					memset(m_iDeskCard[i],0x00,sizeof(m_iDeskCard[i]));
					::memcpy(m_iDeskCard[i],pGameStation->iUserCard[i],sizeof(BYTE)*m_iDeskCardCount[i]);
				}
			}
			return TRUE;
		}
	case GS_PLAY_GAME:	//游戏进行中
		{
			GameStation_4 * pGameStation=(GameStation_4 *)pStationData;
			//函数调用
			CheckVersion(pGameStation->iVersion,pGameStation->iVersion2);
			//设置数据
			BYTE	byTimeRest;
			m_iBeginTime=pGameStation->iBeginTime;							//开始时间
			m_byBoBoTime=pGameStation->byBoBoTime;							//设置簸簸时间
			m_iThinkTime=pGameStation->iThinkTime;							//思考时间
			m_bySeparateCardTime = pGameStation->bySeparateCardTime;		//分牌时间
			m_i64BoBase = pGameStation->i64BoBase;							//簸底
			m_i64SmallBobo = pGameStation->i64SmallBobo;					//最小簸簸
			m_i64TempBobo = m_i64SmallBobo;									//最小簸簸(临时保存)
			m_bNtPeople = pGameStation->bNtPeople;							//庄家
			m_byGameStation = pGameStation->byGameStation;					//动作小分解
			m_iNowOutPeople=pGameStation->iOutCardPeople;					//现在出牌的用户
			m_i64FrontNote = pGameStation->iCurNote;						//前家所下的注
			m_iFirstOutPeople=pGameStation->iFirstOutPeople;				//第一家出的牌
			int iRestTime = pGameStation->iTimeRest;
			m_bSendCardPos = pGameStation->iFirstOutPeople;
			m_iFirstOutPeople=pGameStation->iFirstOutPeople;
			byTimeRest = pGameStation->iTimeRest;							//实际还有的时间
			//保存当前用户下注总额
			::CopyMemory(m_i64UseAllNote,pGameStation->iTotalGameNote,sizeof(m_i64UseAllNote));		//用户所下的总注
			::CopyMemory(m_i64Bobo,pGameStation->i64Bobo,sizeof(m_i64Bobo));						//设置的簸簸数
			::CopyMemory(m_bPlayer,pGameStation->bPlayer,sizeof(m_bPlayer));						//标记是否是开始时所进入的人
			::CopyMemory(m_i64NoteMoney,pGameStation->i64NoteMoney,sizeof(m_i64NoteMoney));			//用户所下注筹码信息
			::CopyMemory(m_i64UseAllNote,pGameStation->iTotalGameNote,sizeof(m_i64UseAllNote));		//各玩家所下的注
			::CopyMemory(m_bSendCardCount,pGameStation->byAlreadySendCardCount,sizeof(m_bSendCardCount));	//已经发牌的张数
			::CopyMemory(m_iDeskCardCount,pGameStation->byAlreadySendCardCount,sizeof(m_iDeskCardCount));	//桌面牌的张数
			::CopyMemory(m_iUserCard,pGameStation->iUserCard,sizeof(m_iUserCard));							//用户手中的牌
			::CopyMemory(m_iUserCardCount,pGameStation->iUserCardCount,sizeof(m_iUserCardCount));			//用户手中牌的数量
			::CopyMemory(m_byUserOperatorType,pGameStation->byOperationState,sizeof(m_byUserOperatorType));	//玩家的操作
			::CopyMemory(m_byNoteTime,pGameStation->byNoteTime,sizeof(m_byNoteTime));						//已经下注的次数
			for(int i = 0x00;i< PLAY_COUNT;i ++)							//复制牌数据
			{
				for(int j = 0x02;j < m_bSendCardCount[i];j++)
					m_iDeskCard[i][j] = m_iUserCard[i][j];
			}
			return TRUE;
		}
	}
	return false;
}
Ejemplo n.º 15
0
//==========================================================================================
// 功能 : 分牌函数
// 参数 : int iMyDesk		[in]		要传的坐位号
//==========================================================================================
void  CClientGameDlg::GetSeparatorCardShap(int iMyDesk)
{
	int iCardShap[3][2];						//用于保存牌型
	BYTE iCardValue[2];
	BYTE byCardValue[3][4];
	int iTemp;
	memset(iCardShap,0x00,sizeof(iCardShap));	//牌型请空
//-------------------------------------------------------------
	byCardValue[0][0] = m_iUserCard[iMyDesk][0];				//第一组				
	byCardValue[0][1] = m_iUserCard[iMyDesk][1];

	iCardShap[0][0] = m_Logic.GetCmpCardValue(byCardValue[0],0x02);
	byCardValue[0][2] = m_iUserCard[iMyDesk][2];					
	byCardValue[0][3] = m_iUserCard[iMyDesk][3];

	iCardShap[0][1] = m_Logic.GetCmpCardValue(&byCardValue[0][2],0x02);
	if(iCardShap[0][0] < iCardShap[0][1])
	{
		iTemp = byCardValue[0][0];
		byCardValue[0][0] = byCardValue[0][2];
		byCardValue[0][2] = iTemp;

		iTemp = byCardValue[0][1];
		byCardValue[0][1] = byCardValue[0][3];
		byCardValue[0][3] = iTemp;

		iTemp = iCardShap[0][0];
		iCardShap[0][0] = iCardShap[0][1];
		iCardShap[0][1] = iTemp;
	}
//-------------------------------------------------------------
	byCardValue[1][0] = m_iUserCard[iMyDesk][0];				//第二组				
	byCardValue[1][1] = m_iUserCard[iMyDesk][2];
	iCardShap[1][0] = m_Logic.GetCmpCardValue(byCardValue[1],0x02);
	byCardValue[1][2] = m_iUserCard[iMyDesk][1];					
	byCardValue[1][3] = m_iUserCard[iMyDesk][3];
	iCardShap[1][1] = m_Logic.GetCmpCardValue(&byCardValue[1][2],0x02);
	if(iCardShap[1][0] < iCardShap[1][1])
	{
		iTemp = byCardValue[1][0];
		byCardValue[1][0] = byCardValue[1][2];
		byCardValue[1][2] = iTemp;

		iTemp = byCardValue[1][1];
		byCardValue[1][1] = byCardValue[1][3];
		byCardValue[1][3] = iTemp;
		
		iTemp = iCardShap[1][0];
		iCardShap[1][0] = iCardShap[1][1];
		iCardShap[1][1] = iTemp;
	}
//-------------------------------------------------------------
	byCardValue[2][0] = m_iUserCard[iMyDesk][0];				//第三组				
	byCardValue[2][1] = m_iUserCard[iMyDesk][3];
	iCardShap[2][0] = m_Logic.GetCmpCardValue(byCardValue[2],0x02);
	byCardValue[2][2] = m_iUserCard[iMyDesk][1];					
	byCardValue[2][3] = m_iUserCard[iMyDesk][2];
	iCardShap[2][1] = m_Logic.GetCmpCardValue(&byCardValue[2][2],0x02);
	if(iCardShap[2][0] < iCardShap[1][1])
	{
		iTemp = byCardValue[2][0];
		byCardValue[2][0] = byCardValue[2][2];
		byCardValue[2][2] = iTemp;

		iTemp = byCardValue[2][1];
		byCardValue[2][1] = byCardValue[2][3];
		byCardValue[2][3] = iTemp;

		iTemp = iCardShap[2][0];
		iCardShap[2][0] = iCardShap[2][1];
		iCardShap[2][1] = iTemp;
	}
	int iMaxIndex = 0x00;
	for(int i = 0x01;i < 0x03;i ++)
	{
		if(iCardShap[iMaxIndex][0] < iCardShap[i][0] && iCardShap[iMaxIndex][1] < iCardShap[i][1])			//两个都大肯定行
		{
			iMaxIndex = i;
		}
		else if(iCardShap[iMaxIndex][0] < iCardShap[i][0] && iCardShap[iMaxIndex][1] == iCardShap[i][1])	//有一个大,一个等也行
		{
			iMaxIndex = i;
		}
		else if(iCardShap[iMaxIndex][0] == iCardShap[i][0] && iCardShap[iMaxIndex][1] < iCardShap[i][1])
		{
			iMaxIndex = i;
		}
	}
	for(int i = 0x00;i < MAX_CARD_COUNT;i ++)
	{
		m_bySeparatorCard[i] = byCardValue[iMaxIndex][i];
	}
	SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SEPARATE_TIME);
}
Ejemplo n.º 16
0
int main() {

	srand(time(NULL));

	const double xMin = -1, yMin = -1;
	const double xMax = 1, yMax = 1;

	{
		epswriter c("circle.eps", xMin, yMin, xMax, yMax);
		epswriter cF("circleF.eps", xMin, yMin, xMax, yMax);
		const double radius = 0.5;
		const double centerX = 0;
		const double centerY = 0;

		c.circle(centerX, centerY,radius,MyRand(), MyRand(), MyRand());
		cF.filledCircle(centerX, centerY,radius,MyRand(), MyRand(), MyRand());
	}

	{
		epswriter t("triangle.eps", xMin, yMin, xMax, yMax);
		epswriter tF("triangleFilled.eps", xMin, yMin, xMax, yMax);

		const double x1= 0  , y1=.5;
		const double x2=-.25, y2=-.25;
		const double x3= .25, y3=-.25;

		t.triangle(x1,y1,x2,y2,x3,y3,MyRand(),MyRand(),MyRand());
		tF.filledTriangle(x1,y1,x2,y2,x3,y3,MyRand(),MyRand(),MyRand());
	}

	{
		epswriter s("square.eps", xMin, yMin, xMax, yMax);
		epswriter sF("squareFilled.eps", xMin, yMin, xMax, yMax);
			
		const double leftDownX = -.5, leftDownY=-.5;
		const double rightUpX = .5, rightUpY = .5;
		s.square(leftDownX, leftDownY, rightUpX, rightUpY,MyRand(),MyRand(),MyRand());
		sF.filledSquare(leftDownX, leftDownY, rightUpX, rightUpY,MyRand(),MyRand(),MyRand());
	}

	{
		epswriter l("line.eps", xMin, yMin, xMax, yMax);
		epswriter ml("multiline.eps",xMin, yMin, xMax, yMax);

		const double lineWidth = .05;
		const double x0 = -1, y0=-1;
		const double xf = .5, yf=1.0;
		std::vector<double> x,y;
		x.push_back(.5);x.push_back(.7); x.push_back(.9);
		y.push_back(-.3);y.push_back(.4); y.push_back(0);

		l.line(x0,y0,xf,yf, lineWidth, MyRand(),MyRand(),MyRand());
		ml.multiline(x,y, lineWidth, MyRand(),MyRand(),MyRand());
	}

	{
		epswriter n("names.eps", xMin, yMin, xMax, yMax);
		const double x1= 0  , y1=.5;
		const double x2=-.25, y2=-.25;

		n.writeText(x1,y1,"Very nice name", 0.2, 0,0, 0);
		n.writeText(x2,y2,"Nice name indeed", 0.2, 0,0,0);
	}
}
Ejemplo n.º 17
0
static void Finish(COrder_Built &order, CUnit &unit)
{
	const CUnitType &type = *unit.Type;
	CPlayer &player = *unit.Player;

	DebugPrint("%d: Building %s(%s) ready.\n" _C_ player.Index _C_ type.Ident.c_str() _C_ type.Name.c_str());

	// HACK: the building is ready now
	player.UnitTypesCount[type.Slot]++;
	if (unit.Active) {
		player.UnitTypesAiActiveCount[type.Slot]++;
	}
	unit.Constructed = 0;
	if (unit.Frame < 0) {
		unit.Frame = -1;
	} else {
		unit.Frame = 0;
	}
	CUnit *worker = order.GetWorkerPtr();

	if (worker != NULL) {
		if (type.BoolFlag[BUILDERLOST_INDEX].value) {
			// Bye bye worker.
			LetUnitDie(*worker);
			worker = NULL;
		} else { // Drop out the worker.
			worker->ClearAction();

			DropOutOnSide(*worker, LookingW, &unit);

			// If we can harvest from the new building, do it.
			if (worker->Type->ResInfo[type.GivesResource]) {
				CommandResource(*worker, unit, 0);
			}
			// If we can reurn goods to a new depot, do it.
			if (worker->CurrentResource && worker->ResourcesHeld > 0 && type.CanStore[worker->CurrentResource]) {
				CommandReturnGoods(*worker, &unit, 0);
			}
		}
	}

	if (type.GivesResource && type.StartingResources != 0) {
		// Has StartingResources, Use those
		unit.ResourcesHeld = type.StartingResources;
	}

	player.Notify(NotifyGreen, unit.tilePos, _("New %s done"), type.Name.c_str());
	if (&player == ThisPlayer) {
		if (type.MapSound.Ready.Sound) {
			PlayUnitSound(unit, VoiceReady);
		} else if (worker) {
			PlayUnitSound(*worker, VoiceWorkCompleted);
		} else {
			PlayUnitSound(unit, VoiceBuilding);
		}
	}

	if (player.AiEnabled) {
		/* Worker can be NULL */
		AiWorkComplete(worker, unit);
	}

	// FIXME: Vladi: this is just a hack to test wall fixing,
	// FIXME:  also not sure if the right place...
	// FIXME: Johns: hardcoded unit-type wall / more races!
	if (&type == UnitTypeOrcWall || &type == UnitTypeHumanWall) {
		Map.SetWall(unit.tilePos, &type == UnitTypeHumanWall);
		unit.Remove(NULL);
		UnitLost(unit);
		UnitClearOrders(unit);
		unit.Release();
		return ;
	}

	UpdateForNewUnit(unit, 0);

	// Set the direction of the building if it supports them
	if (type.NumDirections > 1 && type.BoolFlag[NORANDOMPLACING_INDEX].value == false) {
		if (type.BoolFlag[WALL_INDEX].value) { // Special logic for walls
			CorrectWallDirections(unit);
			CorrectWallNeighBours(unit);
		} else {
			unit.Direction = (MyRand() >> 8) & 0xFF; // random heading
		}
		UnitUpdateHeading(unit);
	}

	if (IsOnlySelected(unit) || &player == ThisPlayer) {
		SelectedUnitChanged();
	}
	MapUnmarkUnitSight(unit);
	unit.CurrentSightRange = unit.Stats->Variables[SIGHTRANGE_INDEX].Max;
	MapMarkUnitSight(unit);
	order.Finished = true;
}