Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 4.37 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //join ##HELLOKITTY2
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. #include "Game.h"
  6.  
  7. int validPath(path thePath);
  8. int rollDice();
  9.  
  10. int main(int argc, char* argv[]){
  11.    int curPlayer = 0;
  12.  
  13.    // Current move specified by the user.
  14.    int curMove;
  15.  
  16.    int curDice = 0;
  17.    
  18.    int disciplines[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
  19.    
  20.    // assigns a color to hexes  
  21.    int temCounter;
  22.    int counter = 1;
  23.  
  24.    while(counter < NUM_REGIONS){
  25.  
  26.       temCounter = 1;
  27.       while(temCounter <= 6 && counter + temCounter - 1 < NUM_REGIONS) {
  28.  
  29.          disciplines[counter+temCounter-1]=temCounter;
  30.          temCounter++;
  31.       }
  32.       counter += 5;
  33.    }
  34.  
  35.    int dice[] = {2,4,12,3,5,9,10,2,6,9,11,8,8,10,12,4,2,10,11};
  36.    Game curGame = newGame(disciplines,dice);
  37.  
  38.    int winFlag = FALSE;
  39.    int legitDice = FALSE;
  40.    int endTurn = FALSE;
  41.    int legitInput;
  42.    int diceRolled;
  43.    int resultDice;
  44.  
  45.    path pathBuffer;
  46.  
  47.    printf("Welcome to generic_team_name's Game!\n");
  48.    printf("Our game is cool\n");
  49.    printf("Instruction set:\n");
  50.    printf("To build an arc, type a followed by xx and yy\n");
  51.  
  52.  
  53.    while(winFlag == FALSE){
  54.       endTurn=FALSE;
  55.  
  56.       while(!legitDice){
  57.          diceRolled = rollDice();
  58.  
  59.          if(diceRolled>=2 && diceRolled <=12){
  60.             legitDice = TRUE;
  61.          } else {
  62.             printf("Dear friendly awesome dungeon master, please enter a valid roll (2-12)");
  63.          }
  64.  
  65.       }
  66.       throwDice(curGame,diceRolled);
  67.  
  68.       curPlayer=getWhoseTurn(curGame);
  69.  
  70.       while(!endTurn){
  71.          printf("What is your next intended move, sweet prince of ponies?: ");
  72.          legitInput=FALSE;
  73.          while(!legitInput){
  74.             /*scanf("%s",moveString);
  75.             if(moveString[0]>='A' && moveString[0]<='Z'){
  76.                moveString[0]+='a'-'A';
  77.             }
  78.             if(!(moveString[0]>='a' && moveString[0]<='z')){
  79.                printf("Please type in a valid move on pain of death\n");
  80.             } else{
  81.                legitInput=TRUE;
  82.             }*/
  83.             scanf("%d",&curMove);
  84.             if(curMove<8 && curMove>=0){
  85.  
  86.                if (curMove == PASS){
  87.  
  88.                   endTurn = TRUE;
  89.  
  90.                } else if(curMove==BUILD_CAMPUS){
  91.                   fgets(pathBuffer, PATH_LIMIT, stdin);
  92.  
  93.                   if (validPath(pathBuffer)) {
  94.                      makeAction(curGame,curMove);
  95.                   }
  96.  
  97.                } else if (curMove == BUILD_GO8){
  98.                   fgets(pathBuffer, PATH_LIMIT, stdin);
  99.  
  100.                      if ((validPath(pathBuffer)) && ((getGO8s(curGame,UNI_A) + getGO8s(curGame,UNI_B) + getGO8s(curGame,UNI_C)) < 8)){
  101.                      makeAction(curGame,curMove);
  102.                      }
  103.  
  104.                } else if (curMove == OBTAIN_ARC){
  105.                   fgets(pathBuffer, PATH_LIMIT, stdin);
  106.  
  107.                   if (validPath(pathBuffer)){
  108.                      if (getARC(curGame, pathBuffer) == VACANT_ARC){
  109.                         makeAction(curGame, curMove);
  110.                      }
  111.                   }
  112.                } else if (curMove == START_SPINOFF){
  113.                   double randomValue = (rand() % 100 + 1) / 3;
  114.                   if (randomValue <= 33.33){
  115.                      makeAction(curGame, OBTAIN_IP_PATENT);
  116.                   } else {
  117.                      makeAction(curGame, OBTAIN_PUBLICATION);
  118.                   }
  119.                }
  120.             } else {
  121.                printf("Please type in a valid move on pain of death\n");
  122.             }
  123.  
  124.          }
  125.  
  126.  
  127.  
  128.  
  129.       }
  130.    }
  131. }
  132.  
  133. int validPath(path thePath) {
  134.    int i = 0;
  135.    int isEnd = FALSE;
  136.    int isInvalid = FALSE;
  137.    while (i < PATH_LIMIT && !isEnd && !isInvalid) {
  138.       if (thePath[i] != 'B' &&
  139.           thePath[i] != 'R' &&
  140.           thePath[i] != 'L' &&
  141.           thePath[i] != 0) {
  142.  
  143.           isInvalid = TRUE;
  144.       } else if (thePath[i] == 0) {
  145.           isEnd = TRUE;
  146.       }
  147.       i++;
  148.    }
  149.  
  150.    return !isInvalid;
  151. }
  152.  
  153. /*
  154. void asciiGame(){
  155.  
  156.  int numTurns = getTurnNumber(curGame);
  157.  printf("%d  ", numTurns);
  158.  
  159.  int currentPlayer = getWhoseTurn();
  160.  printf("   %d   ", currentPlayer);
  161.  
  162.  int diceRoll = rollDice();
  163.  printf("   %d   ", diceroll);
  164.  
  165. }
  166. */
  167.  
  168. int rollDice(){
  169.  
  170.    int diceRoll;
  171.  
  172.    printf("Almighty SudoUser, what is le dice roll?: ");
  173.    scanf("%d",&diceRoll);
  174.  
  175.    return diceRoll;
  176.  
  177. }