本文整理汇总了C++中SgNode::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ SgNode::Add方法的具体用法?C++ SgNode::Add怎么用?C++ SgNode::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgNode
的用法示例。
在下文中一共展示了SgNode::Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePosition
SgNode* GoNodeUtil::CreatePosition(int boardSize, SgBlackWhite toPlay,
const SgVector<SgPoint>& bPoints,
const SgVector<SgPoint>& wPoints)
{
SgNode* node = new SgNode();
node->Add(new SgPropInt(SG_PROP_SIZE, boardSize));
node->Add(new SgPropPlayer(SG_PROP_PLAYER, toPlay));
node->Add(new SgPropAddStone(SG_PROP_ADD_BLACK, bPoints));
node->Add(new SgPropAddStone(SG_PROP_ADD_WHITE, wPoints));
return node;
}
示例2: PlaceHandicap
void GoGame::PlaceHandicap(const SgVector<SgPoint>& stones)
{
SG_ASSERT(GoBoardUtil::IsBoardEmpty(m_board));
SgNode* node = m_current;
if (node->HasSon())
node = node->NewRightMostSon();
SgPropAddStone* addBlack = new SgPropAddStone(SG_PROP_ADD_BLACK);
for (SgVectorIterator<SgPoint> it(stones); it; ++it)
addBlack->PushBack(*it);
node->Add(addBlack);
SgPropInt* handicap = new SgPropInt(SG_PROP_HANDICAP, stones.Length());
node->Add(handicap);
node->Add(new SgPropPlayer(SG_PROP_PLAYER, SG_WHITE));
m_board.Rules().SetHandicap(stones.Length());
GoToNode(node);
}
示例3: WriteGame
void SgGameWriter::WriteGame(SgNode& root, bool allProps, int fileFormat,
const string& application, int gameNumber,
int defaultSize)
{
if (! m_out)
throw SgException("SgGameWriter: write error");
// Add file format property to root. If file format not specified,
// default to file format read in, or FF[4] for new files.
if (fileFormat != 0)
m_fileFormat = fileFormat;
else if (root.HasProp(SG_PROP_FORMAT))
m_fileFormat = root.GetIntProp(SG_PROP_FORMAT);
root.Add(new SgPropInt(SG_PROP_FORMAT, m_fileFormat));
if (application != "")
root.Add(new SgPropText(SG_PROP_APPLIC, application));
root.Add(new SgPropInt(SG_PROP_GAME, gameNumber));
// Reorder the main root properties in a fixed order to make games more
// human-readable and to avoid unnecessary diffs. Note that they'll end
// up in the opposite sequence.
SgPropList& props = root.Props();
props.MoveToFront(SG_PROP_PLAYER);
props.MoveToFront(SG_PROP_ADD_EMPTY);
props.MoveToFront(SG_PROP_ADD_WHITE);
props.MoveToFront(SG_PROP_ADD_BLACK);
props.MoveToFront(SG_PROP_USER);
props.MoveToFront(SG_PROP_SOURCE);
props.MoveToFront(SG_PROP_ROUND);
props.MoveToFront(SG_PROP_EVENT);
props.MoveToFront(SG_PROP_PLACE);
props.MoveToFront(SG_PROP_DATE);
props.MoveToFront(SG_PROP_RESULT);
props.MoveToFront(SG_PROP_PLAYER_BLACK);
props.MoveToFront(SG_PROP_RANK_BLACK);
props.MoveToFront(SG_PROP_TEAM_BLACK);
props.MoveToFront(SG_PROP_PLAYER_WHITE);
props.MoveToFront(SG_PROP_RANK_WHITE);
props.MoveToFront(SG_PROP_TEAM_WHITE);
props.MoveToFront(SG_PROP_GAME_NAME);
props.MoveToFront(SG_PROP_APPLIC);
props.MoveToFront(SG_PROP_SIZE);
props.MoveToFront(SG_PROP_FORMAT);
props.MoveToFront(SG_PROP_GAME);
SgPropPointFmt fmt = GetPointFmt(gameNumber);
WriteSubtree(root, allProps, defaultSize, fmt);
m_out.put('\n');
}
示例4: SetupPosition
void GoGame::SetupPosition(const SgBWArray<SgPointSet>& stones)
{
SgPropAddStone* addBlack = new SgPropAddStone(SG_PROP_ADD_BLACK);
SgPropAddStone* addWhite = new SgPropAddStone(SG_PROP_ADD_WHITE);
for (SgSetIterator it(stones[SG_BLACK]); it; ++it)
if (m_board.GetColor(*it) != SG_BLACK)
addBlack->PushBack(*it);
for (SgSetIterator it(stones[SG_WHITE]); it; ++it)
if (m_board.GetColor(*it) != SG_WHITE)
addWhite->PushBack(*it);
SgNode* node = m_current->NewRightMostSon();
node->Add(addBlack);
node->Add(addWhite);
GoToNode(node);
}