Page MenuHomePhabricator (Chris)

command.cpp
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

command.cpp

#include "game.h"
#include "command.h"
//Command::Command()
//{
//}
Command::Command(efc::Game &currentGame) :
game(currentGame)
{
// this->game = currentGame;
}
void Command::removeDiamond(int playerNumber)
{
/*! This should works as following:
* - iterate over BoardDiamondSeq
* - find diamonds belonging to the playerNumber
* - create an array from the aboves
* - get a random element
* - remove from the board - set not active
*/
std::cout << "removing diamond number " << playerNumber << std::endl;
std::vector<int> diamonds;
for (auto&& i: game.boardDiamonds.diamonds)
{
int fieldNumber = i.playerNumber;
if ((fieldNumber==playerNumber) && (i.boardPosition>-1)
&& (i.idNumber==4))
{
std::cout << "pushing found " << fieldNumber << std::endl;
diamonds.push_back(i.boardPosition);
}
}
int numberDiamonds = diamonds.size();
std::cout << "found elements " << numberDiamonds << std::endl;
if (numberDiamonds>=0)
{
// std::cout << "pushing found " << fieldNumber << std::endl;
int elemToRemove = rand() % numberDiamonds;
std::cout << "random found " << elemToRemove << " " << diamonds[elemToRemove] << std::endl;
game.boardDiamonds.collectField(diamonds[elemToRemove]);
}
}

File Metadata

Mime Type
text/x-c
Expires
Sun, Nov 15, 8:53 AM (6 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
149320
Default Alt Text
command.cpp (1 KB)

Event Timeline