Esempio n. 1
0
void Purchased::doTurn(Player* player[], int playerNum, queue<int> &q1, queue<int> &q2, int numOfPlayers) {
	if (player[playerNum]->checkQuit() == true) {
		mOwner = -1;
		return;
	}
	if (mOwner == playerNum) {
		cout << player[playerNum]->getName() << " попадает на своЄ поле <" << this->getName()<<">" << endl;
		cout << player[playerNum]->getName() << " отдохни " << endl;
	}
	if (mOwner < 0) {
		cout << player[playerNum]->getName() << " попадает на поле <" << this->getName()<<">" << endl;
		int answer = askPlayer(player, playerNum);
		switch (answer) {
		case 1:
			if (player[playerNum]->getBalance() >= mCost) {
				player[playerNum]->decBalance(mCost);
				cout << player[playerNum]->getName() << " покупает <" << this->getName() << "> за " << mCost << " – " << endl;
				mOwner = playerNum;
				this->setOwned(player, playerNum);
			}
			else
			{
				player[playerNum]->decBalance(mCost);
				mOwner = playerNum;
				cout << player[playerNum]->getName() << " покупает <" << this->getName() << "> и имеет отрицательный баланс" << player[playerNum]->getBalance() << endl;
				this->setOwned(player, playerNum);
			}
			break;
		case 2:
			return;
			break;
		}
	}

	else if (mOwner != playerNum) {
		cout << player[playerNum]->getName() << " попадает на поле <" << this->getName()<<">" << endl;
		if (isMortgage == false) {
			int toPay = this->getRent(player, mOwner);
			player[playerNum]->decBalance(toPay);
			player[playerNum]->addBalance(toPay);
			cout << player[playerNum]->getName() << " платит " << toPay << " – за аренду " << endl;
		}
		else {
			cout << "данное поле заложенно" << endl;
		}
	}
}
Esempio n. 2
0
E_playStatus playOneTurn(S_game* aGame, E_playerNum playerNum, E_boolean no_gui, E_boolean logfile, FILE* logpath)
{
  short i, col;
  E_boolean emptyCell;

  col = askPlayer(aGame->players[playerNum]);
  if(col == -1)
    return QUIT_GAME;
  emptyCell = TRUE;
  i=0;
  while(i<6 && emptyCell)
  {
    if(aGame->grid[i][col] == NP)
       ++i;
    else
      emptyCell = FALSE;
  }
  if(i == 0)
  {
    if(logfile)
      log_print(logpath, "%s tried to play in column %d\nImpossible action: column is full\n\n", aGame->players[playerNum]->name, col+1);
    return FULL_NOT_PLAYED;
  }
  if(i > 0)
  {
    aGame->grid[i-1][col] = aGame->players[playerNum]->pawnType;

    if(playerNum == P1)
      aGame->whoMustPlay = P2;
    else
      aGame->whoMustPlay = P1;
    
    if(no_gui)
      printf("%s played in column %d\n", aGame->players[playerNum]->name, col+1);
    if(logfile)
      log_print(logpath, "%s played in column %d\n\n", aGame->players[playerNum]->name, col+1);

    if(i == 1)
      return PLAYED_FULLED;
    else
      return PLAYED_NOT_FULLED;
  }
}