Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void
- getHistory (GameView gv, PlayerID player, LocationID trail[TRAIL_SIZE])
- {
- //Check if its the beginning of the game
- if (gv->roundNumber == 0) {
- int trailC = 0;
- while(trailC < TRAIL_SIZE){//add UNKNOWN_LOCATION to entire trail
- trail[trailC] = UNKNOWN_LOCATION;
- trailC++;
- }
- } else {
- //find latest play index in pastP
- int lastPlay = latestPlay(gv);
- while(gv->pastP[lastPlay] != player){
- lastPlay = lastPlay - PLAY_LEN;
- }//latest play by player
- //Dracula case:---------------
- if(player == PLAYER_DRACULA){
- int count = 0;
- while(count < TRAIL_SIZE){
- char tempLoc[2];
- tempLoc[0] = gv->pastP[lastPlay+1];
- tempLoc[1] = gv->pastP[lastPlay+2];
- int trailAdd;
- if(tempLoc[0]=='C' && tempLoc[1]=='?'){//if unknown city location
- trailAdd = CITY_UNKNOWN;
- } else if(tempLoc[0]=='S' && tempLoc[1]=='?'){//if unknown sea location
- trailAdd = SEA_UNKNOWN;
- } else if(tempLoc[0]=='H' && tempLoc[1]=='I'){
- trailAdd = HIDE;
- } else if(tempLoc[0]=='T' && tempLoc[1]=='P'){
- trailAdd = TELEPORT;
- }
- else if(tempLoc[0]=='D' && tempLoc[1]=='1'){
- trailAdd = DOUBLE_BACK_1;
- } else if(tempLoc[0]=='D' && tempLoc[1]=='2'){
- trailAdd = DOUBLE_BACK_2;
- } else if(tempLoc[0]=='D' && tempLoc[1]=='3'){
- trailAdd = DOUBLE_BACK_3;
- } else if(tempLoc[0]=='D' && tempLoc[1]=='4'){
- trailAdd = DOUBLE_BACK_4;
- } else /*tempLoc[0]=='D' && tempLoc[1]=='5'*/{
- trailAdd = DOUBLE_BACK_5;
- }
- pushToTrail(trail, trailAdd);//add to trail
- lastPlay = lastPlay - LINE_LEN;
- count++;
- }
- }//-----------------
- else {
- //hunter case:
- //now we fill in the trail, finally.
- int countr = 0;
- while(countr < TRAIL_SIZE){
- char currLoc[2];//current location
- //extract location abbreviation
- currLoc[0] = gv->pastP[lastPlay+1];
- currLoc[1] = gv->pastP[lastPlay+2];
- //turn location abbreviation to locationID using places.c
- LocationID currLocation = abbrevToID(currLoc);
- //finally, add locationID to trail
- pushToTrail(trail, currLocation);
- lastPlay = lastPlay - LINE_LEN;//go back to the previous round
- countr++;//will only go to 6 to ensure trail is at most last 6 plays.
- }
- //after all of this the trail array should be updated for
- //whichever player was parsed into the function.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement