Exemple #1
0
void movePlayer(PLAYER (*ppp)[], int i, int dir) {
	PLAYER *p = &(*ppp)[i];
	POSITION oldPosition = (*p).obj.pos;
	POSITION newPosition = getNewPosition(oldPosition, dir);
	if (isPositionValid(newPosition, dir)) {
		// save move if not yet finished:
		if ((*p).finished != 1) {
			saveMove(p, dir);
		}
		// if player crossed the line, finished flag is set to true:
		if (crossedTheLine(oldPosition, dir)) {
			(*p).finished = 1;
		}
		int symbol = getSymbolOnTheTrack(oldPosition);
		erasePlayer(p); 
		// if player was on the finish line, draw finish line:
		if (symbol == '|') { 
			printChar('|', oldPosition);
		}
		(*p).obj.pos = newPosition;
		// so that if two were on the same spot both get printed:
		printAllPlayers(ppp);
		// so that it if two are on the same spot the last that arrived gets printed:
		printPlayer(p); 
	}
}
Exemple #2
0
void moveC(int currentPosition)
{
    #define POSSIBLE_DIR_C 4
    #define MLIOD 9 // Max Location In One Direction, possibly
    int overFlag = FALSE;

    int direction[POSSIBLE_DIR_C] = {-0x01, -0x10, +0x01, +0x10}

    int nextPosition = 0;
    int d = 0;
    int i = 0;
    for(d = 0; d < POSSIBLE_DIR_C; d++)
    {
        overFlag = FALSE;
        for(i = 1; i < POSSIBLE_DIR_C; i++)
        {
            nextPosition = currentPosition + i * direction[d];

            if(LegalPosition[nextPosition] == FALSE)
            {
                break;
            }

            if(hasChess(nextPosition) == FALSE)
            {
                saveMove(currentPosition, nextPosition);
            }
            else
            {
                if(overFlag == FALSE)
                {
                    overFlag = TRUE
                }
                else
                {
                    if(isSelfChess(Board[nextPosition]) == FALSE)
                    {
                        saveMove(currentPosition, nextPosition);
                    }
                    break;
                }
            }
        }
    }
}
Exemple #3
0
void saveMove(std::unique_ptr<Move> move, std::ostream& stream)
{
	if(!move)
	{
		stream << DIR_END << " ";
	}
	else if(move->isMyTurn())
	{
        MyMove* myMove = (MyMove*) move.get();
		stream << myMove->getDirection() << " ";
		saveMove(myMove->advance(), stream);
	}
	else
	{
		stream << DIR_HUBBA_BUBBA << " ";
		for(Direction dir = DIR_BEGIN; dir < DIR_END; ++dir)
			saveMove(((YourMove*) move.get())->advance(dir), stream);
	}
}
/*!
    Completes either saving or sharing of access point by 
    making the move in commsdat.
 */
void CpIapItem::queryDialogClosed()
{
    OstTraceFunctionEntry0(CPIAPITEM_QUERYDIALOGCLOSED_ENTRY);
    if (mMoveOngoing) {
        saveMove(mDestinationList[mList->selected()]);
    } else {
        saveShare(mDestinationList[mList->selected()]);
    }
    OstTraceFunctionExit0(CPIAPITEM_QUERYDIALOGCLOSED_EXIT);
}