예제 #1
0
void CTicTacToe::setPlayerNamesFromUi()
{

    setPlayerName(SPIELER_1, g_cp.optionsInstance->ui->lineEditName1->text());
    setPlayerName(SPIELER_2, g_cp.optionsInstance->ui->lineEditName2->text());
    setPlayerCheckBoxState(SPIELER_1, g_cp.optionsInstance->ui->checkBoxSymbol1->checkState());
    setPlayerCheckBoxState(SPIELER_2, g_cp.optionsInstance->ui->checkBoxSymbol2->checkState());
}
예제 #2
0
파일: player.cpp 프로젝트: xbackupx/showeqx
void EQPlayer::zoneEntry(const ServerZoneEntryStruct* zsentry)
{
  m_shortZoneName = zsentry->zoneShortName;
  clear();
  setPlayerName(zsentry->name);
  setPlayerDeity(zsentry->deity);
}
예제 #3
0
void HumanConsole::restart() {
    timeCount = 0;
    lastMove = 0;
    lastSpeedup = -1000;
    running = false;

    keyUp = keyDown = keyLeft = keyRight = false;
    keyShift = keyZ = keyX = false;

    gameInfo.gameStatus = INIT;
    gameInfo.score = gameInfo.round = 0;
    gameInfo.planeX = PLANE_INIT_X;
    gameInfo.planeY = PLANE_INIT_Y;
    gameInfo.planeSkillsNum = 0;

    string bossName;
    init(bossName);
    emit setBossName(QString(bossName.c_str()));
    emit setPlayerName(QString("Human"));
    emit setTime(0);
    emit setScore(0);
    emit setValue1(0);
    emit setValue2(0);

    gameCenter->init(QPointF(gameInfo.planeX, gameInfo.planeY), QPointF(BULLET_X, BULLET_Y));
}
예제 #4
0
player :: player ( int playerNo )
{
       player_no = playerNo ;  
       stringstream ss;  
       ss << "Player" << player_no ; 
       setPlayerName(ss.str() )   ;
       setColor(player_no) ;     
       initialise () ; 
}
예제 #5
0
/*
** when a remote player leaves an arena game do this!
**
** @param player -- the one we need to clear
** @param quietly -- true means without any visible effects
*/
void clearPlayer(UDWORD player,bool quietly)
{
	UDWORD			i;
	STRUCTURE		*psStruct,*psNext;

	debug(LOG_NET, "R.I.P. %s (%u). quietly is %s", getPlayerName(player), player, quietly ? "true":"false");

	ingame.JoiningInProgress[player] = false;	// if they never joined, reset the flag
	ingame.DataIntegrity[player] = false;

	(void)setPlayerName(player,"");				//clear custom player name (will use default instead)

	for(i = 0;i<MAX_PLAYERS;i++)				// remove alliances
	{
		alliances[player][i]	= ALLIANCE_BROKEN;
		alliances[i][player]	= ALLIANCE_BROKEN;
	}

	debug(LOG_DEATH, "killing off all droids for player %d", player);
	while(apsDroidLists[player])				// delete all droids
	{
		if(quietly)			// don't show effects
		{
			killDroid(apsDroidLists[player]);
		}
		else				// show effects
		{
			destroyDroid(apsDroidLists[player], gameTime);
		}
	}

	debug(LOG_DEATH, "killing off all structures for player %d", player);
	psStruct = apsStructLists[player];
	while(psStruct)				// delete all structs
	{
		psNext = psStruct->psNext;

		// FIXME: look why destroyStruct() doesn't put back the feature like removeStruct() does
		if(quietly || psStruct->pStructureType->type == REF_RESOURCE_EXTRACTOR)		// don't show effects
		{
			removeStruct(psStruct, true);
		}
		else			// show effects
		{
			destroyStruct(psStruct, gameTime);
		}

		psStruct = psNext;
	}

	return;
}
void GuiGameController::setWindow(Proxy* g){

    gui = g;

    qDebug() << "connecting window signals";
    connect(gui, SIGNAL( readyToStartOnePersonPlay( int,int )), this, SLOT( startOnePersonPlay( int,int ) ),Qt::QueuedConnection  );
    connect(gui, SIGNAL( readyToStartTwoPersonPlay() ),     this, SLOT( startTwoPersonPlay() ),     Qt::QueuedConnection  );
    connect(gui, SIGNAL( sendPlayerName( QVariant ) ) ,     this, SLOT( setPlayerName( QVariant ) ),Qt::QueuedConnection  );
    connect(gui, SIGNAL( enterNetworkLobby() ),             this, SLOT( enterNetworkLobby() ),      Qt::QueuedConnection  );
    connect(gui, SIGNAL( readyToExitGame() ),               this, SLOT( exitGame() ),               Qt::QueuedConnection  );
    connect(gui, SIGNAL( leaveLobby() ),                this, SLOT( leaveLobby() ),         Qt::QueuedConnection  );

}
예제 #7
0
void RemoteControl::opponentConnectionState(ObserverData* param)
{
    _state.remoteConnectionEstablished = param->getPlayerIsConnected();
    
    if (!_state.remoteConnectionEstablished)
    {
        _state.isInitialized = false;
    }
    else
    {
        sgl_ConnectionManager.setRoomNumber(param->getRoom());
        setPlayerName(param->getRemotePlayerName());
    }
}
예제 #8
0
void RemoteControl::init()
{
	CCLog("IS multiplayer or what?");

    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(RemoteControl::startShooting), START_SHOOT, NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(RemoteControl::transferData), RESOLVE_SHOOT, NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(RemoteControl::opponentConnectionState), CONNECTION_STATE_CHANGED, NULL);
    
    _state.isInitialized = false;
    
    CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(RemoteControl::runConnection), this, 0.5f, false);
    
    setPlayerName("RemotePlayer");
}
예제 #9
0
// ////////////////////////////////////////////////////////////////////////////
// Host Campaign.
bool hostCampaign(char *sGame, char *sPlayer)
{
	PLAYERSTATS playerStats;
	UDWORD		i;

	debug(LOG_WZ, "Hosting campaign: '%s', player: '%s'", sGame, sPlayer);

	freeMessages();

	// If we had a single player (i.e. campaign) game before this value will
	// have been set to 0. So revert back to the default value.
	if (game.maxPlayers == 0)
	{
		game.maxPlayers = 4;
	}

	if (!NEThostGame(sGame, sPlayer, game.type, 0, 0, 0, game.maxPlayers))
	{
		return false;
	}

	for (i = 0; i < MAX_PLAYERS; i++)
	{
		if (NetPlay.bComms)
		{
			game.skDiff[i] = 0;     	// disable AI
		}
		setPlayerName(i, ""); //Clear custom names (use default ones instead)
	}

	NetPlay.players[selectedPlayer].ready = false;

	ingame.localJoiningInProgress = true;
	ingame.JoiningInProgress[selectedPlayer] = true;
	bMultiPlayer = true;
	bMultiMessages = true; // enable messages

	loadMultiStats(sPlayer, &playerStats);				// stats stuff
	setMultiStats(selectedPlayer, playerStats, false);
	setMultiStats(selectedPlayer, playerStats, true);

	if (!NetPlay.bComms)
	{
		sstrcpy(NetPlay.players[0].name, sPlayer);
	}

	return true;
}
예제 #10
0
void Message::messageParserTurn(string _message) {
    int messageConverted[2];
    string nameParsed;
    string s = _message;
    string delimiter = ",";

    size_t pos = 0;
    string token;
    int i = 0;

    while ((pos = s.find(delimiter)) != string::npos) {
        token = s.substr(0, pos);
        nameParsed = token;
        cout << nameParsed << endl;
        s.erase(0, pos + delimiter.length());
        i++;
    }

    messageConverted[i] = stoi(s);

    setPlayerName(nameParsed);
    setIsMyTurn(messageConverted[1]);
}
예제 #11
0
파일: Player.cpp 프로젝트: revantn/SOH
void Player::initPlayerPosition()
{
	cocos2d::Size size = cocos2d::Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
	int x = 0, y = 0;

	switch (m_id)
	{
	case PLAYER_POSITION::WEST:
			x = size.width/ 19;
			y = size.height / 3.2;
			for (int i = 0; i < MAX_IN_HAND_CARDS; i++)
			{
#ifdef DEBUG_AI
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setCardPosition(x, y + (i * PLAYER_CARD_OFFSET));
				card->setVisible(true);
				card->addEvents();
#else 
				auto cardCover = m_cardDeck->getCardCover(m_inHandCards[i]);
				cardCover->setVisible(true);
				cardCover->setPosition(x, y + (i * PLAYER_CARD_OFFSET));
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setPosition(x, y + (i * PLAYER_CARD_OFFSET));
				setPlayerName("West");

#endif
			}
			break;
		case PLAYER_POSITION::EAST:
			x = size.width/1.0538 ;
			y = size.height / 3.2;
			for (int i = 0; i < MAX_IN_HAND_CARDS; i++)
			{
#ifdef DEBUG_AI
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setCardPosition(x, y + (i * PLAYER_CARD_OFFSET));
				card->setVisible(true);
				card->addEvents();

#else 
				auto cardCover = m_cardDeck->getCardCover(m_inHandCards[i]);
				cardCover->setVisible(true);
				cardCover->setPosition(x, y + (i * PLAYER_CARD_OFFSET));
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setPosition(x, y + (i * PLAYER_CARD_OFFSET));
#endif
				setPlayerName("East");
			}
			break;
		case PLAYER_POSITION::NORTH:
			x = size.width / 2.5;
			y = size.height/1.08;
			for (int i = 0; i < MAX_IN_HAND_CARDS; i++)
			{
#ifdef DEBUG_AI
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setCardPosition(x + (i * PLAYER_CARD_OFFSET), y);
				card->setVisible(true);
				card->addEvents();

#else 
				auto cardCover = m_cardDeck->getCardCover(m_inHandCards[i]);
				cardCover->setVisible(true);
				cardCover->setPosition(x + (i * PLAYER_CARD_OFFSET), y);
				auto card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setPosition(x + (i * PLAYER_CARD_OFFSET), y);

#endif
				setPlayerName("North");
			}
			break;
		case PLAYER_POSITION::SOUTH:
			x = size.width / 2.5;
			y = size.height / 13;
			for (int i = 0; i < MAX_IN_HAND_CARDS; i++)
			{
				Card* card = m_cardDeck->getCard(m_inHandCards[i]);
				card->setCardPosition(x + (i * PLAYER_CARD_OFFSET), y);
				card->setVisible(true);
				card->enableTouch(true);
			}
			setPlayerName("Shakuni");
			break;
	}

}
예제 #12
0
파일: player.cpp 프로젝트: xbackupx/showeqx
void EQPlayer::backfill(const playerProfileStruct* player)
{
  QString messag;
  
  printf("EQPlayer::backfill():\n");
  
  messag.sprintf("Zone: Name='%s' Last='%s'\n", 
		 player->name, player->lastName);
  emit msgReceived(messag);
  
  messag.sprintf("Zone: Level: %d\n", player->level);
  emit msgReceived(messag);
  
  messag.sprintf("Zone: PlayerMoney: P=%d G=%d S=%d C=%d\n",
		 player->platinum, player->gold, 
		 player->silver, player->copper);
  emit msgReceived(messag);
  
  messag.sprintf("Zone: BankMoney: P=%d G=%d S=%d C=%d\n",
		 player->platinumBank, player->goldBank, 
		 player->silverBank, player->copperBank);
  emit msgReceived(messag);
  
  memcpy(&m_thePlayer, player, sizeof(playerProfileStruct));
  
  m_playerLevel = player->level;
  m_playerRace = player->race;
  m_playerClass = player->class_;
  
  setUseDefaults(false);
  setPlayerName(player->name);
  setPlayerLastName(player->lastName);
  setPlayerLevel(player->level);
  setPlayerRace(player->race);
  setPlayerClass(player->class_);
  
  messag = "Exp: " + Commanate(player->exp);
  
  // Due to the delayed decode, we must reset
  // maxplayer on zone and accumulate all totals.
  m_maxSTR += player->STR;
  m_maxSTA += player->STA;
  m_maxCHA += player->CHA;
  m_maxDEX += player->DEX;
  m_maxINT += player->INT;
  m_maxAGI += player->AGI;
  m_maxWIS += player->WIS;
  
  emit statChanged (LIST_STR, m_maxSTR, m_maxSTR);
  emit statChanged (LIST_STA, m_maxSTA, m_maxSTA);
  emit statChanged (LIST_CHA, m_maxCHA, m_maxCHA);
  emit statChanged (LIST_DEX, m_maxDEX, m_maxDEX);
  emit statChanged (LIST_INT, m_maxINT, m_maxINT);
  emit statChanged (LIST_AGI, m_maxAGI, m_maxAGI);
  emit statChanged (LIST_WIS, m_maxWIS, m_maxWIS);
  
  m_maxMana = calcMaxMana( m_maxINT,
			   m_maxWIS,
			   m_playerClass,
			   m_playerLevel
			   ) + m_plusMana;
  
  emit manaChanged(m_thePlayer.MANA, m_maxMana);  // need max mana

  uint32_t playerExp = player->exp;

  if (playerExp > m_currentExp)
    m_currentExp = playerExp;
  else
    playerExp = m_currentExp;
  
  m_maxExp = calc_exp(m_playerLevel,m_playerRace,m_playerClass);

  emit expChangedStr (messag);
  emit expChangedInt ( playerExp,
                       calc_exp(m_playerLevel-1, m_playerRace, m_playerClass),
                       calc_exp(m_playerLevel,   m_playerRace, m_playerClass)
		       );
  
  // Merge in our new skills...
  for (int a = 0; a < MAX_KNOWN_SKILLS; a++)
  {
    if ((m_playerSkills[a] == 255) || // not valid
	(player->skills[a] > m_playerSkills[a])) // or a higher value
      m_playerSkills[a] = player->skills[a];

    emit addSkill (a, m_playerSkills[a]);
  }

  // Merge in our new languages...
  for (int a = 0; a < MAX_KNOWN_LANGS; a++)
  {
    if ((m_playerLanguages[a] == 255) ||
	(player->languages[a] > m_playerLanguages[a]))
      m_playerLanguages[a] = player->languages[a];
    
    emit addLanguage (a, m_playerLanguages[a]);
  }

  m_validAttributes = true;
  m_validMana = true;
  m_validExp = true;

  // update the con table
  fillConTable();
}
예제 #13
0
void MainWindow::setCurrentGame(const TabData& gameData)
{
	if (gameData.game == m_game && m_game != nullptr)
		return;

	for (int i = 0; i < 2; i++)
	{
		ChessPlayer* player(m_players[i]);
		if (player != nullptr)
		{
			disconnect(player, nullptr, m_engineDebugLog, nullptr);
			disconnect(player, nullptr, m_chessClock[0], nullptr);
			disconnect(player, nullptr, m_chessClock[1], nullptr);
		}
	}

	if (m_game != nullptr)
	{
		m_game->pgn()->setTagReceiver(nullptr);
		m_gameViewer->disconnectGame();
		disconnect(m_game, nullptr, m_moveList, nullptr);

		ChessGame* tmp = m_game;
		m_game = nullptr;

		// QObject::disconnect() is not atomic, so we need to flush
		// all pending events from the previous game before switching
		// to the next one.
		tmp->lockThread();
		CuteChessApplication::processEvents();
		tmp->unlockThread();

		// If the call to CuteChessApplication::processEvents() caused
		// a new game to be selected as the current game, then our
		// work here is done.
		if (m_game != nullptr)
			return;
	}

	m_game = gameData.game;

	lockCurrentGame();

	m_engineDebugLog->clear();

	m_moveList->setGame(m_game, gameData.pgn);

	if (m_game == nullptr)
	{
		m_gameViewer->setGame(gameData.pgn);

		for (int i = 0; i < 2; i++)
		{
			ChessClock* clock(m_chessClock[i]);
			clock->stop();
			clock->setInfiniteTime(true);
			clock->setPlayerName(gameData.pgn->playerName(Chess::Side::Type(i)));
		}

		updateWindowTitle();

		return;
	}
	else
		m_gameViewer->setGame(m_game);

	m_tagsModel->setTags(gameData.pgn->tags());
	gameData.pgn->setTagReceiver(m_tagsModel);

	for (int i = 0; i < 2; i++)
	{
		ChessPlayer* player(m_game->player(Chess::Side::Type(i)));
		m_players[i] = player;

		connect(player, SIGNAL(debugMessage(QString)),
			m_engineDebugLog, SLOT(appendPlainText(QString)));

		ChessClock* clock(m_chessClock[i]);

		clock->stop();
		clock->setPlayerName(player->name());
		connect(player, SIGNAL(nameChanged(QString)),
			clock, SLOT(setPlayerName(QString)));

		clock->setInfiniteTime(player->timeControl()->isInfinite());

		if (player->state() == ChessPlayer::Thinking)
			clock->start(player->timeControl()->activeTimeLeft());
		else
			clock->setTime(player->timeControl()->timeLeft());

		connect(player, SIGNAL(startedThinking(int)),
			clock, SLOT(start(int)));
		connect(player, SIGNAL(stoppedThinking()),
			clock, SLOT(stop()));
	}

	updateWindowTitle();
	unlockCurrentGame();
}
예제 #14
0
//------------------------------------------------------------------------------
// playerState2Nib() -- Sets this NIB's player data
//------------------------------------------------------------------------------
void Nib::playerState2Nib()
{
   const models::Player* player = getPlayer();
   if (player != nullptr) {
      // Player name
      const char* cname = nullptr;
      const base::String* sname = player->getName();
      if (sname != nullptr) cname = *sname;
      if (cname != nullptr) setPlayerName(cname);
      else setPlayerName("OPENEAAGLES");

      freeze( player->isFrozen() );
      if (!isMode(models::Player::DELETE_REQUEST)) setMode( player->getMode() );
      setDamage( player->getDamage() );
      setSmoke( player->getSmoke() );
      setFlames( player->getFlames() );
      setCamouflageType( player->getCamouflageType() );
      setSide( player->getSide() );

      // Reset our dead reckoning with the current state data from the player
      //resetDeadReckoning(
      //   RVW_DRM,
      //   player->getGeocPosition(),
      //   player->getGeocVelocity(),
      //   player->getGeocAcceleration(),
      //   player->getGeocEulerAngles(),
      //   player->getGeocAngularVelocities()
      //);

      resetDeadReckoning(
         RVW_DRM,
         player->getSynchronizedState().getGeocPosition(),
         player->getSynchronizedState().getGeocVelocity(),
         player->getSynchronizedState().getGeocAcceleration(),
         player->getSynchronizedState().getGeocEulerAngles(),
         player->getSynchronizedState().getAngularVelocities()
      );

      // mark the current times
      //Simulation* sim = getNetIO()->getSimulation();
      //setTimeExec( static_cast<double>(sim->getExecTimeSec()) );
      setTimeExec( static_cast<double>(player->getSynchronizedState().getTimeExec()) );
      //setTimeUtc( static_cast<double>(sim->getSysTimeOfDay()) );
      setTimeUtc( static_cast<double>(player->getSynchronizedState().getTimeUtc()) );

      {
         //base::Vec3d pos = player->getGeocPosition();
         //base::Vec3d vec = player->getGeocVelocity();

         //std::cout << "playerState2Nib(): geoc pos: (";
         //std::cout << pos[0] << ", ";
         //std::cout << pos[1] << ", ";
         //std::cout << pos[2] << ") ";
         //std::cout << "geoc vel: (";
         //std::cout << vec[0] << ", ";
         //std::cout << vec[1] << ", ";
         //std::cout << vec[2] << ") ";
         //std::cout << std::endl;
      }
   }
}
예제 #15
0
bool GameScene::init(){
	if (!Layer::init())
	{
		return false;
	}


	//游戏数据初始化
	card_num = 0;
	debt_num = 0;



	//先添加桌面背景,在最下面
	auto * table = Sprite::create("table.png");
	this->addChild(table);
	auto screenSize = Director::getInstance()->getWinSize();//获取屏幕尺寸  
	table->setPosition(screenSize.width/2,screenSize.height/2-30);
	table->setScale(1.1);//设置缩放级别
	
	//add buttons
	//按钮上的文字后期用ps来制作

	auto giveUpMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_giveUp, this));
	giveUpMenuItem->setPosition(Point(60, 40));

	auto genZhuMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_xiaZhu, this));
	genZhuMenuItem->setPosition(Point(190, 40));

	auto yiLvMenuItem = MenuItemImage::create(
		"button01.png",
		"button02.png", CC_CALLBACK_1(GameScene::button_jiaZhu, this));
	yiLvMenuItem->setPosition(Point(320, 40));

	auto starMenu = Menu::create(giveUpMenuItem, genZhuMenuItem,yiLvMenuItem,NULL);
	starMenu->setPosition(Point::ZERO);
	
	this->addChild(starMenu, 1);

	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label01 = Label::createWithSystemFont("giveUp", "Arial", 17);
	button_label01->setPosition(Point(60, 40));
	this->addChild(button_label01,2);
	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label02 = Label::createWithSystemFont("xiaZhu", "Arial", 17);
	button_label02->setPosition(Point(190, 40));
	this->addChild(button_label02,2);
	//按钮上添加文字(暂时的功能,后期完善可以删掉)
	auto button_label03 = Label::createWithSystemFont("jiaZhu", "Arial", 17);
	button_label03->setPosition(Point(320, 40));
	this->addChild(button_label03,2);




	// your codes here 
	
	/*

	char str[] = "poker_pic/13.png";
	auto test_card = Sprite::create(str);
	this->addChild(test_card);
	test_card->setPosition(screenSize.width / 2, screenSize.height -400);
	test_card->setScale(0.6);

	auto my_testCard = Card::create("roomgirl.png");  // auto == Card
	my_testCard->setPosition(screenSize.width / 2, screenSize.height - 200);
	my_testCard->setScale(0.6);
	my_testCard->setCardID(23);
	this->addChild(my_testCard);
	CCLOG("my_testCard->ID = %d .", my_testCard->getCardID());//会得到log:my_testCard->ID = 23 .

	*/

	//test_end

	//显示玩家头像,玩家筹码等信息,荷官的片,
	auto roomgirl = Sprite::create("roomgirl.png");
	this->addChild(roomgirl);
	roomgirl->setPosition(screenSize.width/2, screenSize.height-70);
	roomgirl->setScale(1);

	
	player_num = 2;//设置为2名玩家

	//添加游戏玩家(other players)
	auto player01 = addNewPlayer("player01", 50000);

	int my_total = 50000;
	char *my_name = "player_me";
	//添加自己的游戏数据========
	player_me = Player::create("default_player.png");//创建纹理,并且显示在屏幕的正下方
	player_me->setPhoto("default_player.png");
	player_me->setPosition(screenSize.width/2,170);
	player_me->setDebt(0); //set to 0
	player_me->setTotal(my_total);
	player_me->setOnTable(true);
	this->addChild(player_me);
	player01->setPlayerName(my_name);
	player01->setTotal(my_total);

	//show player name
	auto player_me_name = Label::createWithSystemFont(my_name, "Arial", 17);
	player_me_name->setPosition(screenSize.width/2, 215);
	this->addChild(player_me_name);

	//show player total money
	char tmp[9];
	sprintf(tmp, "%d",my_total);
	auto player_me_total = Label::createWithSystemFont(tmp, "Arial", 17);
	player_me_total->setPosition(screenSize.width/2,120);
	this->addChild(player_me_total);


	

	//下底注(后期可以用ps来制作一张图来支持中文)
	//show tips
	auto tips = Sprite::create("show_tips.png");
	tips->setScale(0.3);
	tips->setPosition(screenSize.width / 2, screenSize.height / 2);
	tips->setOpacity(200);
	this->addChild(tips, 0, 100);// set tag 100
	auto tips_label = Label::createWithSystemFont("XiaDiZhu", "SimSun", 30);
	tips_label->setPosition(screenSize.width / 2, screenSize.height / 2);
	tips_label->setColor(ccc3(0, 0, 0));//color black
	this->addChild(tips_label, 0, 101);// set tag 101
	this->scheduleOnce(schedule_selector(GameScene::showTips), 1);//调用回调函数来删掉刚刚创建的tips 
	
	
	player01->addDebt(DIZHU);
	player_me->addDebt(DIZHU);

	debt_num = DIZHU * 2;
	//CCLOG为调试信息
	CCLOG("player01.debt = %d ,total = %d", player01->getDebt(), player01->getTotal());
	CCLOG("player_me.debt = %d ,total = %d", player_me->getDebt(), player_me->getTotal());


	//发底牌(2张底牌)保证不相同
	srand((unsigned)time(NULL)); //初始化随机数种子

	int t1 = getOneNumber();//两名玩家共4张底牌
	int t2 = getOneNumber();
	int t3 = getOneNumber();
	int t4 = getOneNumber();
	CCLOG("DIPAI  == %d %d %d %d",t1,t2,t3,t4);
	player01->setCards(t1,t2);
	player_me->setCards(t3,t4);

	//CCLOG("PLAYER01 c1 = %d, c2 = %d ,PLAYER_ME  c3 = %d, c4 =%d ", player01->getCard01(), player01->getCard02(), player_me->getCard01(), player_me->getCard02());


	//显示玩家得到的底牌(可以添加动画效果)
	char poker_file_name[20]="poker_pic/";
	char temp[9];
	sprintf(temp, "%d", player_me->getCard01());
	strcat(poker_file_name,temp);
	strcat(poker_file_name, ".png");
	//CCLOG("poker_file_name 1 = %s", poker_file_name);
	auto dipai01 = Card::create(poker_file_name);
	dipai01->setRotation(-13);//旋转角度 
	dipai01->setScale(0.5);
	dipai01->setPosition(320, 165);
	this->addChild(dipai01);

	//重新创建一个变量
	char poker_file_name2[20] = "poker_pic/";
	sprintf(temp, "%d", player_me->getCard02());
	strcat(poker_file_name2, temp);
	strcat(poker_file_name2, ".png");
	//CCLOG("poker_file_name 2 = %s", poker_file_name2);
	auto dipai02 = Card::create(poker_file_name2);
	dipai02->setRotation(9);//旋转角度 
	dipai02->setScale(0.5);
	dipai02->setPosition(340, 165);
	this->addChild(dipai02);

	//添加背面的牌:
	auto hand_card_R = Sprite::create("hand_card_back.png");
	hand_card_R->setScale(0.6);
	hand_card_R->setPosition(22, 470);
	this->addChild(hand_card_R);

	//刚发过底牌,设置一个标签,来定义玩到了什么进度
	game_round = 1;//刚发过底牌,设置为1
	
	//若不弃牌,则下注,下注之后可选加注


	//庄家下注,玩家跟注?加注?

	//发第一张公共牌

	//发第二张公共牌

	//...

	//...直到发最后一张公共牌,是否加注?判断游戏输赢
	
	//以上内容写在了按钮中,通过读取变量值来知道是第几个回合

	return true;//init函数执行成功,返回真
}
예제 #16
0
void GameWall::addGame(ChessGame* game)
{
	Q_ASSERT(game != nullptr);

	QWidget* widget = new QWidget(this);

	ChessClock* clock[2] = { new ChessClock(), new ChessClock() };
	QHBoxLayout* clockLayout = new QHBoxLayout();
	for (int i = 0; i < 2; i++)
	{
		clock[i] = new ChessClock();
		clockLayout->addWidget(clock[i]);

		Chess::Side side = Chess::Side::Type(i);
		clock[i]->setPlayerName(side.toString());
	}
	clockLayout->insertSpacing(1, 20);

	BoardScene* scene = new BoardScene();
	BoardView* view = new BoardView(scene);

	QVBoxLayout* mainLayout = new QVBoxLayout();
	mainLayout->addLayout(clockLayout);
	mainLayout->addWidget(view);
	mainLayout->setContentsMargins(0, 0, 0, 0);

	widget->setLayout(mainLayout);
	layout()->addWidget(widget);

	game->lockThread();
	connect(game, SIGNAL(fenChanged(QString)),
		scene, SLOT(setFenString(QString)));
	connect(game, SIGNAL(moveMade(Chess::GenericMove, QString, QString)),
		scene, SLOT(makeMove(Chess::GenericMove)));
	connect(game, SIGNAL(humanEnabled(bool)),
		view, SLOT(setEnabled(bool)));

	for (int i = 0; i < 2; i++)
	{
		ChessPlayer* player(game->player(Chess::Side::Type(i)));

		if (player->isHuman())
			connect(scene, SIGNAL(humanMove(Chess::GenericMove, Chess::Side)),
				player, SLOT(onHumanMove(Chess::GenericMove, Chess::Side)));

		clock[i]->setPlayerName(player->name());
		connect(player, SIGNAL(nameChanged(QString)),
			clock[i], SLOT(setPlayerName(QString)));

		clock[i]->setInfiniteTime(player->timeControl()->isInfinite());

		if (player->state() == ChessPlayer::Thinking)
			clock[i]->start(player->timeControl()->activeTimeLeft());
		else
			clock[i]->setTime(player->timeControl()->timeLeft());

		connect(player, SIGNAL(startedThinking(int)),
			clock[i], SLOT(start(int)));
		connect(player, SIGNAL(stoppedThinking()),
			clock[i], SLOT(stop()));
	}

	scene->setBoard(game->pgn()->createBoard());
	scene->populate();

	foreach (const Chess::Move& move, game->moves())
		scene->makeMove(move);

	game->unlockThread();

	view->setEnabled(!game->isFinished() &&
			 game->playerToMove()->isHuman());
	m_games[game] = widget;

	cleanupWidgets();
}