Пример #1
0
    /*--------------------------------------------------------------------------------
        Function    : Level::fetchItemsAtLocation
        Description : Creates a vector of the items at a specified tile, REMOVES them
                      from the items vector, and returns this vector.  This is used
                      when characters pick up items from a location to add them to
                      their inventory.
        Inputs      : location to fetch items from
        Outputs     : None
        Return      : a vector of the items at the specified location
    --------------------------------------------------------------------------------*/
    vector<ItemPtr> Level::fetchItemsAtLocation(const Point& pt)
    {
        vector<ItemPtr> fetchedItems;
        vector<ItemPtr> otherItems;
        vector<ItemPtr>::iterator it, end;
        it = items.begin(); end = items.end();

        PositionEquals positionEquals(pt);
        for(; it!=end; ++it)
        {
            if(positionEquals(*it))
            {
                fetchedItems.push_back(*it);
            }
            else
            {
                otherItems.push_back(*it);
            }
        }

        items = otherItems;
        return fetchedItems;
    }
Пример #2
0
bool moveInList(MoveList* list, Move* moveToFind) {
	if(list == NULL)
		return false;
	MoveList* head = list;
	while(head){
		if(positionEquals(head->data->from, moveToFind->from) &&
			positionListEquals(head->data->to, moveToFind->to)){
			moveToFind->eatenAt = copyPositionList(head->data->eatenAt);
			moveToFind->eatCount = head->data->eatCount;
			return true;
		}
		head = head->next;
	}
	return false;
}