- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include "Game.h"
- int validPath(path thePath);
- int rollDice();
- int getNextMove)();
- int main(int argc, char* argv[]){
- srand(time(NULL));
- int curPlayer = 0;
- int curMove;
- int curDice = 0;
- int trainFrom, trainTo;
- action curAction;
- int disciplines[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
- disciplines[0] = STUDENT_THD;
- int counter = 1;
- int temCounter = 1;
- while(counter < NUM_REGIONS){
- temCounter = 1;
- while((temCounter <= 6) && (counter + temCounter - 1 < NUM_REGIONS)){
- disciplines[counter + temCounter - 1] = temCounter;
- temCounter++;
- }
- counter += 5;
- }
- char moveString[100];
- int dice[19] = {2,4,12,3,5,9,10,2,6,9,11,8,8,10,12,4,2,10,11};
- Game curGame = newGame(disciplines,dice);
- int winFlag = FALSE;
- int legitInput = FALSE;
- int legitDice = FALSE;
- int endTurn = FALSE;
- int diceRolled;
- int resultDice;
- path pathBuffer;
- printf("Welcome to generic_team_name's Game!");
- printf("Our game is cool\n");
- printf("Instruction set:\n");
- printf("To build an arc, type a followed by xx and yy");
- while(winFlag == FALSE){
- endTurn = FALSE;
- while(!legitDice){
- diceRolled = rollDice();
- if(diceRolled >= 2 && diceRolled <= 12){
- legitDice = TRUE;
- } else {
- printf("Dear friendly awesome dungeon master, please enter a valid roll (2-12)");
- }
- }
- throwDice(curGame, diceRolled);
- curPlayer = getWhoseTurn(curGame);
- while(!endTurn){
- printf("What is your next intended move, sweet prince of ponies?: ");
- legitInput = FALSE;
- curMove = getNextMove();
- if (curMove < 8 && curMove >= 0){
- legitInput = TRUE;
- curAction.actionCode = curMove;
- if (curMove == PASS){
- endTurn = TRUE;
- } else if(curMove == BUILD_CAMPUS){
- fgets(pathBuffer, PATH_LIMIT, stdin);
- if (validPath(pathBuffer)){
- strncpy(curAction.destination,pathBuffer,PATH_LIMIT);
- makeAction(curGame,curAction);
- }
- } else if (curMove == BUILD_GO8){
- fgets(pathBuffer, PATH_LIMIT, stdin);
- if ((validPath(pathBuffer)) && ((getGO8s(curGame,UNI_A) + getGO8s(curGame,UNI_B) + getGO8s(curGame,UNI_C)) < 8 )){
- strncpy(curAction.destination,pathBuffer,PATH_LIMIT);
- makeAction(curGame,curAction);
- }
- } else if (curMove == OBTAIN_ARC){
- fgets(pathBuffer, PATH_LIMIT, stdin);
- if (validPath(pathBuffer)){
- if (getARC(curGame, pathBuffer) == VACANT_ARC){
- strncpy(curAction.destination,pathBuffer,PATH_LIMIT);
- makeAction(curGame, curAction);
- }
- }
- } else if (curMove == START_SPINOFF){
- /*
- randomValue = (rand() % 100 + 1) / 3.0;
- if (randomValue <= 33.33){
- curAction.actionCode = OBTAIN_IP_PATENT;
- makeAction(curGame, curAction);
- } else {
- curAction.actionCode = OBTAIN_PUBLICATION;
- makeAction(curGame, curAction);
- }
- */
- } else if (curMove == OBTAIN_PUBLICATION){
- makeAction(curGame,curAction);
- } else if (curMove == OBTAIN_IP_PATENT){
- makeAction(curGame,curAction);
- } else if (curMove == RETRAIN_STUDENTS){
- scanf("%d %d",&trainFrom,&trainTo);
- curAction.disciplineFrom = trainFrom;
- curAction.disciplineTo = trainTo;
- if(!isLegitAction(curGame,curAction)){
- legitInput = FALSE;
- printf("WE REQUIRE MORE VESPENE GAS\n");
- } else {
- makeAction(curGame,curAction);
- }
- }
- if(!legitInput){
- printf("Please type in a valid move on pain of death\n");
- }
- }
- }
- if (getKPIpoints(curGame,curPlayer) >= 150){
- printf("%d Wins\n",curPlayer);
- winFlag=TRUE;
- }
- }
- return EXIT_SUCCESS;
- }
- int validPath(path thePath) {
- int i = 0;
- int isEnd = FALSE;
- int isInvalid = FALSE;
- while (i < PATH_LIMIT && !isEnd && !isInvalid) {
- if (thePath[i] != 'B' &&
- thePath[i] != 'R' &&
- thePath[i] != 'L' &&
- thePath[i] != 0) {
- isInvalid = TRUE;
- } else if (thePath[i] == 0) {
- isEnd = TRUE;
- }
- i++;
- }
- return !isInvalid;
- }
- int rollDice(){
- int diceRoll;
- printf("Almighty SudoUser, what is le dice roll?: ");
- scanf("%d",&diceRoll);
- return diceRoll;
- }
- int getNextMove() {
- int move;
- while(!legitInput) {
- scanf("%d",&move);
- if((move < 8) && (move >= 0)) {
- legitInput = TRUE;
- } else {
- printf("Please type in a valid move on pain of death\n");
- }
- }
- return move;
- }