Example #1
0
int getRank(HunterView h, int player, int round)
{
	int rank = 0;
	
	if (round == 0) {
		if(player == PLAYER_LORD_GODALMING) {rank = -1;}
		else if(player == PLAYER_DR_SEWARD) {rank = 0;}
		else if(player == PLAYER_VAN_HELSING) {rank = 1;}
		else if(player == PLAYER_MINA_HARKER) {rank = 2;}
		else printf("I am noone..\n");		
	} else if (round == 1 && player == PLAYER_LORD_GODALMING) {
		rank = 3;
	} else {
		int turn = giveMeTurnNum(h);

		IntList l = newIntList();
	
		int foundDrac = FALSE;
		LocationID dracTrail[TRAIL_SIZE];
		giveMeTheTrail(h,PLAYER_DRACULA,dracTrail);

		int currLoc;	
		if (player == PLAYER_LORD_GODALMING) currLoc = whereIs(h,PLAYER_MINA_HARKER);
		else currLoc = whereIs(h,player-1);
	
		int j;
		for(j=0;j<TRAIL_SIZE;j++) {
			if (currLoc == dracTrail[j]) {
				foundDrac = TRUE;
				break;
			}
		}
	
		int score;
		int ignore1;
		char ignore2;
		int playertmp = 2;
		int insertPlayer;
	
		int i;
		for (i=1;i<6;i++) {
			if (i != player+1) { //skips drac
				//printf("scanning message %s\n",messages[turn-i]);
				//printf("inserting into list player: %d score: %d\n",(player+5-playertmp)%5,tmp);
				if (playertmp==4 && foundDrac) score = j;
				else sscanf(messages[turn-i],"%d %c %d",&ignore1,&ignore2,&score);
				insertPlayer = (player+4-playertmp)%4;
				IntListInsertInOrder(l,score,insertPlayer);
				playertmp++;
			}
		}
	
		//showList(l);
	
		current_leader = getFirstPlayer(l);
		rank = playerPos(l,player);
	}
	
	return rank;
}
Example #2
0
// make a sorted physical copy of a list
IntList IntListSortedCopy(IntList L)
{
	struct IntListRep *Lnew;
	struct IntListNode *curr;

	Lnew = newIntList();
	for (curr = L->first; curr != NULL; curr = curr->next)
		IntListInsertInOrder(Lnew, curr->data);
	return Lnew;
}
Example #3
0
// create an IntList by reading values from a file
// assume that the file is open for reading
IntList getIntList(FILE *inf)
{
	IntList L;
	int v;

	L = newIntList();
	while (fscanf(inf,"%d",&v) != EOF)
		IntListInsert(L,v);
	return L;
}
Example #4
0
// make a physical copy of a list
// new list looks identical to original list
IntList IntListCopy(IntList L)
{
	struct IntListRep *Lnew;
	struct IntListNode *curr;

	Lnew = newIntList();
	for (curr = L->first; curr != NULL; curr = curr->next)
		IntListInsert(Lnew, curr->data, curr->player);
	return Lnew;
}