├── obj └── about.txt ├── .gitattributes ├── src ├── definitions.c ├── sysSpecific.h ├── maingame.h ├── game.h ├── player.h ├── sysSpecific.c ├── main.c ├── definitions.h ├── game.c ├── player.c └── maingame.c ├── .gitignore ├── Makefile ├── data └── locations.csv ├── README.md └── LICENSE /obj/about.txt: -------------------------------------------------------------------------------- 1 | This folder will contain .o files when make is run. -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /src/definitions.c: -------------------------------------------------------------------------------- 1 | #include "definitions.h" 2 | 3 | struct location Location[40]; 4 | struct card drawnCard; 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | 3 | #Testing Folders and Files 4 | test.* 5 | .Testing 6 | Testing 7 | 8 | # Object files 9 | *.o 10 | 11 | # Executables 12 | *.exe 13 | *.out 14 | -------------------------------------------------------------------------------- /src/sysSpecific.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSSPECIFIC_H_ 2 | #define SYSSPECIFIC_H_ 3 | #ifdef _WIN32 4 | void checkWindowSize(int screenWidth, int screenHeight); 5 | #elif defined __unix__ 6 | int _kbhit(); 7 | char getch_(int echo); 8 | char getch(void); 9 | char getche(void); 10 | void checkWindowSize(int screenWidth, int screenHeight); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/maingame.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINGAME_H_ 2 | #define MAINGAME_H_ 3 | 4 | #include "definitions.h" 5 | #include "game.h" 6 | #include "player.h" 7 | 8 | // Clears screen and displays intro screen "WELCOME TO MONOPOLY" 9 | // Returns EXIT_SUCCESS when displayed properly 10 | int Intro(); 11 | 12 | // Clears screen and displays rules of monopoly 13 | // Returns EXIT_SUCCESS when displayed properly 14 | int ShowRules(); 15 | 16 | // Clears screen and displays rules of monopoly 17 | // Returns EXIT_SUCCESS after game played successfully 18 | int mainGame(); 19 | 20 | // Clears screen and displays intro screen "THANKS FOR PLAYING" 21 | // Returns EXIT_SUCCESS when displayed properly 22 | int ThankYou(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/game.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_H_ 2 | #define GAME_H_ 3 | 4 | // Accepts game mode choice from user 5 | // Returns the choice NETWORTH/TURNS/ENDLESS/EXIT 6 | int SelectGamemode(); 7 | 8 | // Reads location informations from file and stores them in structures 9 | // Returns EXIT_SUCCESS if read properly 10 | int ReadLocations(); 11 | 12 | // Generates random card information from locations file based on card type and stores it in a structure 13 | // Returns EXIT_SUCCESS if read properly 14 | int GenerateCard(); 15 | 16 | // Clears screen and displays monopoly map 17 | // Returns EXIT_SUCCESS if displayed properly 18 | int DisplayMap(); 19 | 20 | // Displays Property information graphically 21 | // Returns EXIT_SUCCESS if displayed properly 22 | int GraphicalPropertyInfo(struct player Players[],int playerCount); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # make # Compile Monopoly executable along with object files 3 | # make Monopoly # Compile only Monopoly executable 4 | # make clean # Removes all binaries and objects 5 | 6 | .PHONY = all clean Monopoly 7 | CC := gcc 8 | SRCS := $(wildcard ./src/*.c) 9 | 10 | ifeq ($(OS), Windows_NT) 11 | RM := del /Q 12 | RMOFILES := del /Q ./obj/*.o 13 | else 14 | RM := rm 15 | RMOFILES := rm obj/*.o 16 | endif 17 | 18 | all: OFiles 19 | ${CC} ./obj/definitions.o ./obj/main.o ./obj/maingame.o ./obj/game.o ./obj/player.o ./obj/sysSpecific.o -o Monopoly 20 | @echo Make successful 21 | 22 | Monopoly: ${SRCS} 23 | ${CC} ${SRCS} -o Monopoly 24 | @echo Compiled Monopoly successfully 25 | 26 | OFiles: ./obj/definitions.o ./obj/main.o ./obj/maingame.o ./obj/game.o ./obj/player.o ./obj/sysSpecific.o 27 | @echo Files compiled successfully 28 | 29 | ./obj/definitions.o:./src/definitions.c 30 | ${CC} -c ./src/definitions.c -o ./obj/definitions.o 31 | 32 | ./obj/main.o: ./src/main.c 33 | ${CC} -c ./src/main.c -o ./obj/main.o 34 | 35 | ./obj/maingame.o: ./src/maingame.c 36 | ${CC} -c ./src/maingame.c -o ./obj/maingame.o 37 | 38 | ./obj/game.o: ./src/game.c 39 | ${CC} -c ./src/game.c -o ./obj/game.o 40 | 41 | ./obj/player.o: ./src/player.c 42 | ${CC} -c ./src/player.c -o ./obj/player.o 43 | 44 | ./obj/sysSpecific.o: ./src/sysSpecific.c 45 | ${CC} -c ./src/sysSpecific.c -o ./obj/sysSpecific.o 46 | 47 | clean: all 48 | $(RM) Monopoly* 49 | $(RMOFILES) 50 | @echo Clean successful 51 | -------------------------------------------------------------------------------- /data/locations.csv: -------------------------------------------------------------------------------- 1 | ID,TYPE,NAME,SET ID,COST,RENT,1 HOUSE,2 HOUSE,3 HOUSE,4 HOUSE,HOTEL,HOUSE COST 2 | 1,FREE,START,-,-,-,-,-,-,-,-,- 3 | 2,PROPERTY,MEDITTERRANEAN AVENUE,1,60,2,10,30,90,160,250,50 4 | 3,CHEST,COMMUNITY CHEST,-,-,-,-,-,-,-,-,- 5 | 4,PROPERTY,BALTIC AVENUE,1,60,4,20,60,180,320,450,50 6 | 5,TAX,INCOME TAX,-,-,200,-,-,-,-,-,- 7 | 6,RAIL,READING RAILROAD,-,200,25,-,-,-,-,-,- 8 | 7,PROPERTY,ORIENTAL AVENUE,2,100,6,30,90,270,400,550,50 9 | 8,CHANCE,CHANCE,-,-,-,-,-,-,-,-,- 10 | 9,PROPERTY,VERMONT AVENUE,2,100,6,30,90,270,400,550,50 11 | 10,PROPERTY,CONNECTICUT AVENUE,2,120,8,40,100,300,450,600,50 12 | 11,FREE,JUST VISITING JAIL,-,-,-,-,-,-,-,-,- 13 | 12,PROPERTY,ST. CHARLES PLACE,3,140,10,50,150,450,625,750,100 14 | 13,UTILITY,ELECTRIC COMPANY,-,150,25,-,-,-,-,-,- 15 | 14,PROPERTY,STATES AVENUE,3,140,10,50,150,450,625,750,100 16 | 15,PROPERTY,VIRGNIA AVENUE,3,160,12,60,180,500,700,900,100 17 | 16,RAIL,PENNSYLVANIA RAILROAD,-,200,25,-,-,-,-,-,- 18 | 17,PROPERTY,ST. JAMES PLACE,4,180,14,70,200,550,750,950,100 19 | 18,CHEST,COMMUNITY CHEST,-,-,-,-,-,-,-,-,- 20 | 19,PROPERTY,TENNESSEE AVENUE,4,180,14,70,200,550,750,950,100 21 | 20,PROPERTY,NEW YORK AVENUE,4,200,16,80,220,600,800,1000,100 22 | 21,FREE,FREE PARKING,-,-,-,-,-,-,-,-,- 23 | 22,PROPERTY,KENTUCKY AVENUE,5,220,18,90,250,700,875,1050,150 24 | 23,CHANCE,CHANCE,-,-,-,-,-,-,-,-,- 25 | 24,PROPERTY,INDIANA AVENUE,5,220,18,90,250,700,875,1050,150 26 | 25,PROPERTY,ILLINOIS AVENUE,5,240,20,100,300,750,925,1100,150 27 | 26,RAIL,B. & O. RAILROAD,-,200,25,-,-,-,-,-,- 28 | 27,PROPERTY,ATLANTIC AVENUE,6,260,22,110,330,800,925,1150,150 29 | 28,PROPERTY,VENTNOR AVENUE,6,260,22,110,330,800,925,1150,150 30 | 29,UTILITY,WATER WORKS,-,150,25,-,-,-,-,-,- 31 | 30,PROPERTY,MARVIN GARDENS,6,280,24,120,360,850,1025,1200,150 32 | 31,JAIL,GO TO JAIL,-,-,-,-,-,-,-,-,- 33 | 32,PROPERTY,PACIFIC AVENUE,7,300,26,130,390,900,1100,1275,200 34 | 33,PROPERTY,NORTH CAROLINA AVENUE,7,300,26,130,390,900,1100,1275,200 35 | 34,CHEST,COMMUNITY CHEST,-,-,-,-,-,-,-,-,- 36 | 35,PROPERTY,PENNSYLVANIA AVENUE,7,320,28,150,450,1000,1200,1400,200 37 | 36,RAIL,SHORT LINE,-,200,25,-,-,-,-,-,- 38 | 37,CHANCE,CHANCE,-,-,-,-,-,-,-,-,- 39 | 38,PROPERTY,PARK PLACE,8,350,35,175,500,1100,1300,1500,200 40 | 39,TAX,LUXURY TAX,-,-,100,-,-,-,-,-,- 41 | 40,PROPERTY,BOARDWALK,8,400,35,200,600,1400,1700,2000,200 42 | -------------------------------------------------------------------------------- /src/player.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYER_H_ 2 | #define PLAYER_H_ 3 | 4 | // Emulates player rolling a die 5 | // Returns a random integer from 1-6 6 | int PlayerRolls(); 7 | 8 | // Reads number of players and player names 9 | // Returns EXIT_SUCCESS if read properly 10 | int ReadPlayers(int *numberOfPlayers, char (*Names)[30]); 11 | 12 | // Each player rolls two dice and player order is set according to highest values 13 | // Returns EXIT_SUCCESS if set properly 14 | int SetPlayerOrder(int numberOfPlayers, char (*Names)[30]); 15 | 16 | // Initialise Player structure values 17 | // Returns EXIT_SUCCESS if set properly 18 | int InitialisePlayers(struct player Player[],int PlayerCount, char (*Names)[30]); 19 | 20 | // Places the player on the screen according to their current position and clears the previous one 21 | // Returns EXIT_SUCCESS if set properly 22 | int GraphicalMove(struct player *currentPlayer,int OldLocationID,int NewLocationID); 23 | 24 | // Accepts an integer input from the user within certain time 25 | // Returns the integer or else returns the Default value given when time elapses 26 | int TimedNumInput(int seconds,int Default); 27 | 28 | // Accepts a character input from the user within certain time 29 | // Returns the character or else returns the Default value given when time elapses 30 | char TimedCharInput(int seconds,char Default); 31 | 32 | // Clears right part of the screen form line given 33 | // Returns EXIT_SUCCESS if cleared properly 34 | int ClearRightScreen(int startLine); 35 | 36 | // Player Menu with timed input 37 | // Returns player choice: ROLL/BUY/SELL/GIVEUP 38 | int PlayerMainMenu(struct player *CurrentPlayer); 39 | 40 | // Calculates rent of location the player is currently on based on location type 41 | // Returns rent of the location 42 | int RentCalc(struct player *owner ,struct location *currentLocation, int rolled); 43 | 44 | // Sell Menu for current player based on locations they own 45 | // Returns EXIT_SUCCESS on success 46 | int SellMenu(struct player *CurrentPlayer); 47 | 48 | // Buy houses and hotels Menu for current player based on locations they own 49 | // Returns EXIT_SUCCESS on success 50 | int BuyHousesMenu(struct player *CurrentPlayer); 51 | 52 | // Buy Property Menu for location player lands on 53 | // Returns EXIT_SUCCESS on success 54 | int BuyMenu(struct player *CurrentPlayer,struct location *currentLocation); 55 | 56 | // Checks if player is bankrupt 57 | // Returns TRUE/FALSE 58 | int IsPlayerBankrupt(int cashInHand); 59 | 60 | // Shows leaderboards post game 61 | // Returns EXIT_SUCCESS on successful display 62 | int PlayerResults(struct player Player[],int PlayerCount); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/sysSpecific.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef _WIN32 5 | #include 6 | void checkWindowSize(int screenWidth, int screenHeight) 7 | { 8 | CONSOLE_SCREEN_BUFFER_INFO csbi; 9 | int width, height; 10 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); 11 | width = csbi.srWindow.Right - csbi.srWindow.Left + 1; 12 | height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; 13 | if (width < screenWidth || height < screenHeight) 14 | { 15 | printf("\nTerminal size is too small. Please resize terminal."); 16 | printf("\nSuggested size: %d X %d", screenWidth, screenHeight); 17 | printf("\nCurrent size : %d X %d", width, height); 18 | printf("\n\n"); 19 | exit(1); 20 | } 21 | } 22 | 23 | #elif defined __unix__ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int _kbhit(void) 31 | { 32 | struct termios oldt, newt; 33 | int ch; 34 | int oldf; 35 | 36 | tcgetattr(STDIN_FILENO, &oldt); 37 | newt = oldt; 38 | newt.c_lflag &= ~(ICANON | ECHO); 39 | tcsetattr(STDIN_FILENO, TCSANOW, &newt); 40 | oldf = fcntl(STDIN_FILENO, F_GETFL, 0); 41 | fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); 42 | 43 | ch = getchar(); 44 | 45 | tcsetattr(STDIN_FILENO, TCSANOW, &oldt); 46 | fcntl(STDIN_FILENO, F_SETFL, oldf); 47 | 48 | if(ch != EOF) 49 | { 50 | ungetc(ch, stdin); 51 | return 1; 52 | } 53 | 54 | return 0; 55 | } 56 | 57 | static struct termios old, current; 58 | 59 | char getch_(int echo) 60 | { 61 | char ch; 62 | tcgetattr(0, &old); 63 | current = old; 64 | current.c_lflag &= ~ICANON; 65 | if (echo) current.c_lflag |= ECHO; 66 | else current.c_lflag &= ~ECHO; 67 | tcsetattr(0, TCSANOW, ¤t); 68 | ch = getchar(); 69 | tcsetattr(0, TCSANOW, &old); 70 | return ch; 71 | } 72 | 73 | char getch(void) 74 | { 75 | return getch_(0); 76 | } 77 | 78 | char getche(void) 79 | { 80 | return getch_(1); 81 | } 82 | 83 | void checkWindowSize(int screenWidth, int screenHeight) 84 | { 85 | struct winsize w; 86 | ioctl(0, TIOCGWINSZ, &w); 87 | if (w.ws_col< screenWidth || w.ws_row < screenHeight) 88 | { 89 | printf("\nTerminal size is too small. Please resize terminal."); 90 | printf("\nSuggested size: %d X %d", screenWidth, screenHeight); 91 | printf("\nCurrent size : %d X %d", w.ws_col, w.ws_row); 92 | printf("\n\n"); 93 | exit(1); 94 | } 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include "maingame.h" 2 | 3 | int main() 4 | { 5 | checkWindowSize(SCREENSIZE_X, SCREENSIZE_Y); 6 | if (Intro()!=EXIT_SUCCESS){ 7 | printf("\nIntro Error\n"); 8 | return EXIT_FAILURE; 9 | } 10 | char choice; 11 | while(TRUE) 12 | { 13 | clearScreen(); 14 | printf("\n 888b d888 .d88888b. 888b 888 .d88888b. 8888888b. .d88888b. 888 Y88b d88P "); 15 | printf("\n 8888b d8888 d88P\" \"Y88b 8888b 888 d88P\" \"Y88b 888 Y88b d88P\" \"Y88b 888 Y88b d88P "); 16 | printf("\n 88888b.d88888 888 888 88888b 888 888 888 888 888 888 888 888 Y88o88P "); 17 | printf("\n 888Y88888P888 888 888 888Y88b 888 888 888 888 d88P 888 888 888 Y888P "); 18 | printf("\n 888 Y888P 888 888 888 888 Y88b888 888 888 8888888P\" 888 888 888 888 "); 19 | printf("\n 888 Y8P 888 888 888 888 Y88888 888 888 888 888 888 888 888 "); 20 | printf("\n 888 \" 888 Y88b. .d88P 888 Y8888 Y88b. .d88P 888 Y88b. .d88P 888 888 "); 21 | printf("\n 888 888 \"Y88888P\" 888 Y888 \"Y88888P\" 888 \"Y88888P\" 88888888 888 "); 22 | printf("\n\n\n\n\n"); 23 | printf("\n\t 1-Play Monopoly"); 24 | printf("\n\t 2-Read Rules"); 25 | printf("\n\t X-Exit\n\n"); 26 | hideCursor(); 27 | choice = getch(); 28 | showCursor(); 29 | if (choice == '1') 30 | { 31 | if (mainGame()!=EXIT_SUCCESS){ 32 | printf("\nError in main Game\n"); 33 | return EXIT_FAILURE; 34 | } 35 | } 36 | else if (choice == '2'){ 37 | if (ShowRules()!=EXIT_SUCCESS){ 38 | printf("\nError in showing rules\n"); 39 | return EXIT_FAILURE; 40 | } 41 | } 42 | else if (choice == 'X'|| choice == 'x') 43 | { 44 | clearScreen(); 45 | if (ThankYou()!=EXIT_SUCCESS){ 46 | printf("\nError in Thank You screen\n"); 47 | return EXIT_FAILURE; 48 | } 49 | clearScreen(); 50 | return EXIT_SUCCESS; 51 | } 52 | else 53 | { 54 | printf("\n\n\tYou entered an invalid choice \"%c\". Enter any key to try again.",choice); 55 | getch(); 56 | } 57 | } 58 | return EXIT_SUCCESS; 59 | } 60 | -------------------------------------------------------------------------------- /src/definitions.h: -------------------------------------------------------------------------------- 1 | #ifndef DEFINITIONS_H_ 2 | #define DEFINITIONS_H_ 3 | 4 | // System specific 5 | #define SCREENSIZE_X 172 6 | #define SCREENSIZE_Y 40 7 | 8 | // Can be changed according to game requirement 9 | #define INITIAL_AMT 1200 // Amount of money each player start with 10 | #define BANKRUPT_VALUE -500 // Min value of cash in hand to be not bankrupt 11 | #define MAX_DOUBLES 3 // Maximum die doubles a player can roll 12 | 13 | // Path location of csv file 14 | #define LOCATION_PATH "data/locations.csv" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "sysSpecific.h" 22 | 23 | #ifdef _WIN32 24 | #include 25 | #endif 26 | 27 | #define clearScreen() system("@cls||clear") 28 | #define goto_XY(X,Y) printf("%c[%d;%df",0x1B,Y,X) 29 | #define hideCursor() printf("\e[?25l") 30 | #define showCursor() printf("\e[?25h") 31 | #define colour(C1,C2) printf("\033[%d;%dm",C2,C1) 32 | 33 | enum Boolean {FALSE,TRUE}; 34 | enum colours {RESET,INCREASED_INTENSITY,BLACK=30,RED,GREEN,YELLOW,BLUE,PURPLE,CYAN,WHITE,\ 35 | RED_BG=41,GREEN_BG,YELLOW_BG,BLUE_BG,PURPLE_BG,CYAN_BG,WHITE_BG,\ 36 | LIGHTBLACK_BG=100,LIGHTRED_BG,LIGHTGREEN_BG,LIGHTYELLOW_BG,LIGHTBLUE_BG,LIGHTPURPLE_BG,LIGHTCYAN_BG,PUREWHITE_BG}; 37 | enum GameMode {NETWORTH,TURNS,ENDLESS,EXIT}; 38 | enum csvHead {ID_H,LocType_H,LocName_H,SetID_H,Cost_H,Rent_H,H1_H,H2_H,H3_H,H4_H,Hotel_H,BuildCost_H}; 39 | enum LocType {FREE,CHEST,CHANCE,JAIL,TAX,UTILITY,RAIL,PROPERTY}; 40 | enum CardType {BAD=-1,NEUTRAL,GOOD}; 41 | enum MainMenu {ROLL,BUY,SELL,GIVEUP}; 42 | 43 | // Structure containing location information 44 | extern struct location 45 | { 46 | unsigned int ID :6; // Uniquely identify location (1-40) 47 | unsigned int type:3; // Type of location: FREE/CHEST/CHANCE/JAIL/TAX/UTILITY/RAIL/PROPERTY 48 | unsigned int isOwnable:1; // If the location be owned currently by a player 49 | char name[30]; // Name of the location 50 | unsigned short int cost:10; // Cost to buy the location 51 | unsigned int setID:4; // Identify properties by set ID 52 | int setColour:8; // Colour associated with set 53 | unsigned short int initialRent:10; // Initial rent of the property 54 | unsigned short int house[4]; // Rents with 1-4 houses 55 | unsigned short int hotel:10; // Rents with 1 hotel 56 | unsigned short int buildCost:10; // Cost of building a house or hotel 57 | unsigned int ownerID:4; // If owned, current owner's ID else 0 58 | unsigned int isSetComplete:1; // If the set is complete 59 | unsigned int housesBuilt:3; // Amount of houses built on the property 60 | unsigned int hotelBuilt:1; // If a hotel is built on the property 61 | int rent; // Current rent of the property 62 | }\ 63 | Location[40]; // Locations read from csv file 64 | 65 | // Structure containing card information 66 | extern struct card 67 | { 68 | int type:3; // Type of card: BAD/NEUTRAL/GOOD 69 | unsigned int money; // Money associated with the card 70 | unsigned int locationID:6; // Location ID associated with card 71 | } drawnCard; 72 | 73 | // Structure containing player information 74 | struct player 75 | { 76 | unsigned int ID:4; // Uniquely identify player 77 | char name[30]; // Name of player 78 | unsigned int colour1:7,colour2:7; // Colour of player on screen 79 | short int netWorth; // The net worth of the player 80 | short int cashInHand; // Amount of cash player currently has 81 | unsigned int isOut:1; // If the player is out of the game 82 | unsigned int isBankrupt:1; // If the player is bankrupt 83 | unsigned int isInJail:1; // If the player is in jail 84 | unsigned int jailTurn:2; // Number of turns player left to leave jail 85 | struct location *currentLocation; // The current location of the player (structure) 86 | unsigned short int propertyOwnedCount:6;// Amount of properties the player owns 87 | unsigned short int propertyOwned[20]; // Lists of properties the player owns 88 | unsigned int position:4; // Position of the player post-game 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | C 3 | WINDOWS 4 | LINUX 5 |

6 | 7 | # Monopoly In C 8 | This is an implementation of the board game Monopoly in C for windows and linux systems. 9 | 10 | [![demo](https://asciinema.org/a/8cv6Z66rvO4yutmeDleUXnuIJ.svg)](https://asciinema.org/a/8cv6Z66rvO4yutmeDleUXnuIJ?autoplay=1) 11 | 12 | ## THE GAME 13 | 14 | ### Welcome screen 15 | The game starts off at the welcome screen. 16 | 17 |

18 | WelcomeScreen 19 |

20 | 21 | ### Main Menu 22 | The player has the options to play Monopoly or view the rules of the game. 23 | 24 |

25 | MainMenu 26 |

27 | 28 | ### Game Mode Menu 29 | Player can select the game mode they wish to play with. 30 | 31 |

32 | GameMode 33 |

34 | 35 | ### Player Details 36 | Players enter number of players and their names. The program emulates the players rolling a die to the player order based on the highest rolls. 37 | 38 | A maximum number of 8 players can play. 39 | 40 |

41 | PlayerDetails 42 | PlayerOrders 43 |

44 | 45 | ### Main Game Starts 46 | This is where the actual gameplay starts. All players are assigned a colour and starting positions are set at START. 47 | 48 |

49 | MainGame 50 |

51 | 52 | Each turn, each player who isn't in jail and bankrupt/given up is given options to roll, buy houses and hotels, sell properties they own or to give up. 53 | 54 | #### PLAYER ROLLS 55 | Player rolls two dice each of 1-6 thus with a total possibility of 2-12. 56 | If the player gets doubles (the same number on both dice) the player gets to play again. 57 | If the player gets too many doubles, they are sent to jail for overspeeding. 58 | 59 |

60 | PlayerRolls 61 |

62 | 63 | After rolling, if the player lands on a purchasable tile, they are given the option to buy the property. 64 | 65 |

66 | BuyProperty 67 |

68 | 69 | If the player has a sufficient balance of cash in hand, they can buy the property and a X of their colour is shown in the map. 70 | 71 | #### BUY HOUSES AND HOTELS 72 | If the player has completed a set, they are now allowed to buy a max of 4 Houses or a hotel if they have a sufficient balance. 73 | The player can build houses in only property type locations whose sets are completed. 74 | The player can only build a hotel if 4 houses have been built. 75 | 76 |

77 | BuyHotelHouse 78 |

79 | 80 | If the player owns x houses, xH of their colour is shown next to the property. 81 | If the player owns a hotel, HL of their colour is shown next to the property. 82 | 83 |

84 | HousesHotels 85 |

86 | 87 | 88 | #### SELL MENU 89 | A list of properties the player owns is listed. On selection the property is sold and the player recieves the property value. 90 | 91 |

92 | SellMenu 93 |

94 | 95 | #### GIVE UP 96 | If a player gives up, they are automatically set to last and all their properties are available for other players to buy. 97 | 98 | ### Jail 99 | A player can be sent to jail when they land on "GO TO JAIL" or roll a certain number of doubles. 100 | 101 | The player is given the option to pay a certain amount to get out or can stay for a certain number of turns. 102 | 103 | If the player stays, at each turn, the number of turns to wait is displayed. The player cannot sell properties or buy houses/hotels when in jail. 104 | 105 |

106 | Jail 107 |

108 | 109 | ### Bankrupt 110 | Once the player has a value of less than -500 in cash in hand, they are set to bankrupted and can no longer play. 111 | 112 |

113 | Bankrupt 114 |

115 | 116 | ### GAME MODE BASED ENDINGS 117 | Based on the game mode chosen, the game ends. 118 | 119 | If the game mode was NETWORTH, once a player reaches a certain amount, the game ends. 120 | 121 | If the game mode was TURNS, once certain number of turns have passed, the game ends. 122 | 123 | If the game mode was ENDLESS, once all players except one become bankrupt, the game ends. 124 | 125 |

126 | TurnsPassed 127 |

128 | 129 | ### RESULTS 130 | After the game ends, a result screen of the game is shown. 131 | Players are arranges on their networth. 132 | Players who give up are at the bottom of the list disregarding their networths. 133 | 134 |

135 | Results 136 |

137 | 138 | ### THANK YOU SCREEN 139 | After the game ends, a thank you screen is shown. 140 | 141 |

142 | ThankYou 143 |

144 | 145 | 146 | 147 | ## Running the Program: 148 | To run the program, clone the repo and make the [Makefile](./Makefile). 149 | 150 | > `mingw32-make all` if using mingw32 151 | 152 | Run on command prompt. 153 | 154 | > `Monopoly.exe` 155 | 156 | NOTES: 157 | Before running the program, make sure command prompt is maximised and in full screen for best experience. 158 | Failure to do so can result undesirable outputs. 159 | Some screen resolutions are not supported. 160 | 161 | ## Makefile Targets: 162 | 163 | ### all 164 | Compiles all necessary files and creates .o files and places them in a folder called obj and makes Monopoly.exe 165 | 166 | ### Monopoly 167 | Directly compiles necessary files and creates Monopoly.exe 168 | 169 | ### OFiles 170 | Compiles all necessary files and creates .o files and places them in a folder called obj. 171 | 172 | ### clean 173 | Removes all .o and .exe files created during make `all`. 174 | 175 | 176 | ## Future Plans 177 | - Might add terminal resizing. 178 | 179 | -------------------------------------------------------------------------------- /src/game.c: -------------------------------------------------------------------------------- 1 | #include "definitions.h" 2 | #include "game.h" 3 | 4 | int SelectGamemode() 5 | { 6 | char choice; 7 | while(TRUE) 8 | { 9 | clearScreen(); 10 | printf("\n .d8888b. 8888888888 888 8888888888 .d8888b. 88888888888 .d8888b. d8888 888b d888 8888888888 888b d888 .d88888b. 8888888b. 8888888888 "); 11 | printf("\n d88P Y88b 888 888 888 d88P Y88b 888 d88P Y88b d88888 8888b d8888 888 8888b d8888 d88P\" \"Y88b 888 \"Y88b 888 "); 12 | printf("\n Y88b. 888 888 888 888 888 888 888 888 d88P888 88888b.d88888 888 88888b.d88888 888 888 888 888 888 "); 13 | printf("\n \"Y888b. 8888888 888 8888888 888 888 888 d88P 888 888Y88888P888 8888888 888Y88888P888 888 888 888 888 8888888 "); 14 | printf("\n \"Y88b. 888 888 888 888 888 888 88888 d88P 888 888 Y888P 888 888 888 Y888P 888 888 888 888 888 888 "); 15 | printf("\n \"888 888 888 888 888 888 888 888 888 d88P 888 888 Y8P 888 888 888 Y8P 888 888 888 888 888 888 "); 16 | printf("\n Y88b d88P 888 888 888 Y88b d88P 888 Y88b d88P d8888888888 888 \" 888 888 888 \" 888 Y88b. .d88P 888 .d88P 888 "); 17 | printf("\n \"Y8888P\" 8888888888 88888888 8888888888 \"Y8888P\" 888 \"Y8888P88 d88P 888 888 888 8888888888 888 888 \"Y88888P\" 8888888P\" 8888888888 "); 18 | printf("\n\n\n\n\n"); 19 | printf("\n\tChoose a game mode:"); 20 | printf("\n\t 1-Net Worth : First player to reach a certain amount wins"); 21 | printf("\n\t 2-Turns : Game ends after ceratin number of turns/rounds are over"); 22 | printf("\n\t 3-Endless : Game goes on untill everyone except one player gets bankrupt"); 23 | printf("\n\t X-Exit\n\n"); 24 | choice = getch(); 25 | if (choice == '1') 26 | return NETWORTH; 27 | else if (choice == '2') 28 | return TURNS; 29 | else if (choice == '3') 30 | return ENDLESS; 31 | else if (choice == 'X'|| choice == 'x') 32 | return EXIT; 33 | else 34 | { 35 | printf("\n\n\tYou entered an invalid choice \"%c\". Enter any key to try again.",choice); 36 | getch(); 37 | } 38 | } 39 | } 40 | 41 | int ReadLocations() 42 | { 43 | FILE *file = fopen(LOCATION_PATH, "r"); 44 | if (!file) 45 | return EXIT_FAILURE; 46 | else 47 | { 48 | char buffer[1024]; 49 | int row = 0, column = 0; 50 | while (fgets(buffer,1024, file)) { 51 | column = 0; 52 | char* value = strtok(buffer, ","); 53 | while (value) { 54 | if (row == 0) 55 | break; 56 | if (strcmp(value,"-")!=0){ 57 | switch(column){ 58 | case ID_H: 59 | Location[row-1].ID = atoi(value); 60 | break; 61 | case LocType_H: 62 | if (strcmp(value,"FREE")==0){ 63 | Location[row-1].type = FREE; 64 | Location[row-1].isOwnable = FALSE; 65 | } 66 | else if (strcmp(value,"CHEST")==0){ 67 | Location[row-1].type = CHEST; 68 | Location[row-1].isOwnable = FALSE; 69 | } 70 | else if (strcmp(value,"CHANCE")==0){ 71 | Location[row-1].type = CHANCE; 72 | Location[row-1].isOwnable = FALSE; 73 | } 74 | else if (strcmp(value,"JAIL")==0){ 75 | Location[row-1].type = JAIL; 76 | Location[row-1].isOwnable = FALSE; 77 | } 78 | else if (strcmp(value,"TAX")==0){ 79 | Location[row-1].type = TAX; 80 | Location[row-1].isOwnable = FALSE; 81 | } 82 | else if (strcmp(value,"UTILITY")==0){ 83 | Location[row-1].type = UTILITY; 84 | Location[row-1].isOwnable = TRUE; 85 | } 86 | else if (strcmp(value,"RAIL")==0){ 87 | Location[row-1].type = RAIL; 88 | Location[row-1].isOwnable = TRUE; 89 | } 90 | else if (strcmp(value,"PROPERTY")==0){ 91 | Location[row-1].type = PROPERTY; 92 | Location[row-1].isOwnable = TRUE; 93 | Location[row-1].isSetComplete = FALSE; 94 | Location[row-1].housesBuilt = 0; 95 | Location[row-1].hotelBuilt = 0; 96 | } 97 | break; 98 | case LocName_H: 99 | strcpy(Location[row-1].name,value); 100 | break; 101 | } 102 | if (column==Cost_H && Location[row-1].type >= 5){ 103 | Location[row-1].cost = atoi(value); 104 | } 105 | if (column==Rent_H && Location[row-1].type >= 4){ 106 | Location[row-1].initialRent = atoi(value); 107 | Location[row-1].rent = atoi(value); 108 | } 109 | if (Location[row-1].type == PROPERTY){ 110 | switch(column){ 111 | case SetID_H: 112 | Location[row-1].setID=atoi(value); 113 | switch(Location[row-1].setID) 114 | { 115 | case 1 : Location[row-1].setColour=LIGHTBLACK_BG; break; 116 | case 2 : Location[row-1].setColour=LIGHTCYAN_BG; break; 117 | case 3 : Location[row-1].setColour=LIGHTPURPLE_BG;break; 118 | case 4 : Location[row-1].setColour=YELLOW_BG; break; 119 | case 5 : Location[row-1].setColour=LIGHTRED_BG; break; 120 | case 6 : Location[row-1].setColour=LIGHTYELLOW_BG;break; 121 | case 7 : Location[row-1].setColour=LIGHTGREEN_BG; break; 122 | case 8 : Location[row-1].setColour=LIGHTBLUE_BG; break; 123 | } 124 | break; 125 | case H1_H: 126 | Location[row-1].house[0]=atoi(value); 127 | break; 128 | case H2_H: 129 | Location[row-1].house[1]=atoi(value); 130 | break; 131 | case H3_H: 132 | Location[row-1].house[2]=atoi(value); 133 | break; 134 | case H4_H: 135 | Location[row-1].house[3]=atoi(value); 136 | break; 137 | case Hotel_H: 138 | Location[row-1].hotel=atoi(value); 139 | break; 140 | case BuildCost_H: 141 | Location[row-1].buildCost=atoi(value); 142 | break; 143 | } 144 | } 145 | } 146 | value = strtok(NULL, ","); 147 | column++; 148 | } 149 | row++; 150 | } 151 | fclose(file); 152 | } 153 | return EXIT_SUCCESS; 154 | } 155 | 156 | int GenerateCard() 157 | { 158 | srand(time(0)); 159 | switch((rand()%(3))-1) 160 | { 161 | case -1: 162 | drawnCard.type =BAD; 163 | drawnCard.money=((rand()%(20))+1)*10; 164 | break; 165 | case 0: 166 | drawnCard.type=NEUTRAL; 167 | drawnCard.locationID=rand()%(40); 168 | break; 169 | case 1: 170 | drawnCard.type=GOOD; 171 | drawnCard.money=((rand()%(30))+1)*10; 172 | break; 173 | default:return EXIT_FAILURE; 174 | } 175 | return EXIT_SUCCESS; 176 | } 177 | 178 | int DisplayMap() 179 | { 180 | colour(BLACK,INCREASED_INTENSITY); 181 | clearScreen(); 182 | printf("\n"); 183 | printf("\n ST.CH ELCT STATES VRGNIA PNSLVA ST.JA COM TEN NY FREE "); 184 | printf("\n AVE COMP AVE AVE RAIL AVE CHEST AVE AVE PARK "); 185 | printf("\n ____________________________________________________________________________ "); 186 | printf("\n VISIT | | | | | | | | | | | | "); 187 | printf("\n JAIL | | | | | | | | | | | | "); 188 | printf("\n |______|______|______|______|______|______|______|______|______|______|______| "); 189 | printf("\n CNNCT | | | | KNTCY "); 190 | printf("\n AVE | | | | AVE "); 191 | printf("\n |______| |______| "); 192 | printf("\n VERMNT| | | | "); 193 | printf("\n AVE | | | |CHANCE "); 194 | printf("\n |______| |______| "); 195 | printf("\n | | | | IND "); 196 | printf("\n CHANCE| | | | AVE "); 197 | printf("\n |______| |______| "); 198 | printf("\n ORNTL | | | | ILL "); 199 | printf("\n AVE | | | | AVE "); 200 | printf("\n |______| |______| "); 201 | printf("\n READ | | | | B&O. "); 202 | printf("\n RAIL | | | | RAIL "); 203 | printf("\n |______| |______| "); 204 | printf("\n | | | |ATLNTC "); 205 | printf("\n TAX | | | | AVE "); 206 | printf("\n |______| |______| "); 207 | printf("\n BALTIC| | | | VNTNR "); 208 | printf("\n AVE | | | | AVE "); 209 | printf("\n |______| |______| "); 210 | printf("\n COM | | | | WATER "); 211 | printf("\n CHEST | | | | WORKS "); 212 | printf("\n |______| |______| "); 213 | printf("\n MEDTRN| | | | MRVN "); 214 | printf("\n AVE | | | | GRDNS "); 215 | printf("\n |______|______________________________________________________________|______| "); 216 | printf("\n | | | | | | | | | | | | GO TO "); 217 | printf("\n START | | | | | | | | | | | | JAIL "); 218 | printf("\n |______|______|______|______|______|______|______|______|______|______|______| "); 219 | printf("\n BRDWK LUXURY PARK CHANCE SHORT PNSLVA COM NC PCFC "); 220 | printf("\n TAX PLACE LINE AVE CHEST AVE AVE "); 221 | colour(RESET,0); 222 | return EXIT_SUCCESS; 223 | } 224 | 225 | int GraphicalPropertyInfo(struct player Players[],int playerCount) 226 | { 227 | int map[40][2]={{ 9,36},{ 9,33},{ 9,30},{ 9,27},{ 9,24},{ 9,21},{ 9,18},{ 9,15},{ 9,12},{ 9, 9},\ 228 | { 9, 6},{16, 6},{23, 6},{30, 6},{37, 6},{44, 6},{51, 6},{58, 6},{65, 6},{72, 6},\ 229 | {79, 6},{79, 9},{79,12},{79,15},{79,18},{79,21},{79,24},{79,27},{79,30},{79,33},\ 230 | {79,36},{72,36},{65,36},{58,36},{51,36},{44,36},{37,36},{30,36},{23,36},{16,36}}; 231 | 232 | for (int i=0;i<40;i++) 233 | { 234 | int ID = Location[i].ID; 235 | if (Location[i].type==PROPERTY||Location[i].type==RAIL||Location[i].type==UTILITY) 236 | { 237 | if (Location[i].type==PROPERTY) 238 | { 239 | goto_XY(map[ID-1][0]+5,map[ID-1][1]); 240 | colour(Location[i].setColour,0); 241 | printf(" "); 242 | colour(RESET,RESET); 243 | } 244 | if(Location[i].isOwnable) 245 | { 246 | colour(RESET,RESET); 247 | goto_XY(map[ID-1][0]+4,map[ID-1][1]+1); 248 | printf(" "); 249 | } 250 | else 251 | { 252 | for(int j=0;j0) 261 | printf("%dH",Location[i].housesBuilt); 262 | else 263 | printf(" X"); 264 | colour(RESET,RESET); 265 | } 266 | } 267 | } 268 | 269 | } 270 | } 271 | colour(RESET,RESET); 272 | return EXIT_SUCCESS; 273 | } 274 | -------------------------------------------------------------------------------- /src/player.c: -------------------------------------------------------------------------------- 1 | #include "definitions.h" 2 | #include "player.h" 3 | 4 | int PlayerRolls() 5 | { 6 | return (rand()%6)+1; 7 | } 8 | 9 | int ReadPlayers(int *numberOfPlayers, char (*Names)[30]) 10 | { 11 | char inp[1]; 12 | while(TRUE) 13 | { 14 | clearScreen(); 15 | printf("\n 8888888b. 888 d8888 Y88b d88P 8888888888 8888888b. 8888888b. 8888888888 88888888888 d8888 8888888 888 .d8888b. "); 16 | printf("\n 888 Y88b 888 d88888 Y88b d88P 888 888 Y88b 888 \"Y88b 888 888 d88888 888 888 d88P Y88b "); 17 | printf("\n 888 888 888 d88P888 Y88o88P 888 888 888 888 888 888 888 d88P888 888 888 Y88b. "); 18 | printf("\n 888 d88P 888 d88P 888 Y888P 8888888 888 d88P 888 888 8888888 888 d88P 888 888 888 \"Y888b. "); 19 | printf("\n 8888888P\" 888 d88P 888 888 888 8888888P\" 888 888 888 888 d88P 888 888 888 \"Y88b. "); 20 | printf("\n 888 888 d88P 888 888 888 888 T88b 888 888 888 888 d88P 888 888 888 \"888 "); 21 | printf("\n 888 888 d8888888888 888 888 888 T88b 888 .d88P 888 888 d8888888888 888 888 Y88b d88P "); 22 | printf("\n 888 88888888 d88P 888 888 8888888888 888 T88b 8888888P\" 8888888888 888 d88P 888 8888888 88888888 \"Y8888P\" "); 23 | printf("\n\n\n\n"); 24 | showCursor(); 25 | printf("\n\tEnter the number of players: "); 26 | scanf("%s",&inp); 27 | if (atoi(inp) >= 2 && atoi(inp) <= 8){ 28 | *numberOfPlayers=atoi(inp); 29 | break; 30 | } 31 | else if ((inp[0] == 'X')||(inp[0] == 'x')){ 32 | exit(0); 33 | break; 34 | } 35 | printf("\n\n\tInvalid Input (Enter a number from 2-8 or X to exit game) \n\tEntered: %s\n",inp); 36 | goto_XY(0,SCREENSIZE_Y);printf("\tEnter any key to retry..."); 37 | getch(); 38 | } 39 | for (int i=0;i<*numberOfPlayers;i++){ 40 | printf("\n\tPlayer %d enter name: ",i+1); 41 | fflush(stdin); 42 | scanf("%s",&Names[i]); 43 | } 44 | return EXIT_SUCCESS; 45 | } 46 | 47 | int SetPlayerOrder(int numberOfPlayers, char (*Names)[30]) 48 | { 49 | clearScreen(); 50 | printf("\n 8888888b. 888 d8888 Y88b d88P 8888888888 8888888b. .d88888b. 8888888b. 8888888b. 8888888888 8888888b. "); 51 | printf("\n 888 Y88b 888 d88888 Y88b d88P 888 888 Y88b d88P\" \"Y88b 888 Y88b 888 \"Y88b 888 888 Y88b "); 52 | printf("\n 888 888 888 d88P888 Y88o88P 888 888 888 888 888 888 888 888 888 888 888 888 "); 53 | printf("\n 888 d88P 888 d88P 888 Y888P 8888888 888 d88P 888 888 888 d88P 888 888 8888888 888 d88P "); 54 | printf("\n 8888888P\" 888 d88P 888 888 888 8888888P\" 888 888 8888888P\" 888 888 888 8888888P\" "); 55 | printf("\n 888 888 d88P 888 888 888 888 T88b 888 888 888 T88b 888 888 888 888 T88b "); 56 | printf("\n 888 888 d8888888888 888 888 888 T88b Y88b. .d88P 888 T88b 888 .d88P 888 888 T88b "); 57 | printf("\n 888 88888888 d88P 888 888 8888888888 888 T88b \"Y88888P\" 888 T88b 8888888P\" 8888888888 888 T88b "); 58 | printf("\n\n\n\n"); 59 | srand(time(0)); 60 | int die1, die2, order[10], len=strlen(Names[0]); 61 | for (int i=0;iID; 131 | goto_XY(map[OldLocationID-1][0]+(playerID-1)%4,map[OldLocationID-1][1]+(playerID-1)/4); 132 | printf(" "); 133 | colour(currentPlayer->colour1,currentPlayer->colour2); 134 | goto_XY(map[NewLocationID-1][0]+(playerID-1)%4,map[NewLocationID-1][1]+(playerID-1)/4); 135 | printf("o"); 136 | colour(RESET,RESET); 137 | return EXIT_SUCCESS; 138 | } 139 | 140 | int TimedNumInput(int seconds,int Default) 141 | { 142 | int numInput; 143 | clock_t start = clock(); 144 | while ( ! _kbhit() ) 145 | if (((clock () - start)/ CLOCKS_PER_SEC ) >= seconds) 146 | return Default; 147 | scanf("%d",&numInput); 148 | return numInput; 149 | } 150 | 151 | char TimedCharInput(int seconds,char Default) 152 | { 153 | int charInput; 154 | clock_t start = clock(); 155 | while ( ! _kbhit() ) 156 | if (((clock () - start)/ CLOCKS_PER_SEC ) >= seconds) 157 | return Default; 158 | charInput = getch(); 159 | return charInput; 160 | } 161 | 162 | int ClearRightScreen(int startLine) 163 | { 164 | for (int i=startLine;icolour1,CurrentPlayer->colour2); 183 | printf("%s ",CurrentPlayer->name); 184 | colour(RESET,RESET); 185 | printf("CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 186 | 187 | goto_XY(95,5); 188 | printf("MENU FOR "); 189 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 190 | printf("%s ",CurrentPlayer->name); 191 | colour(RESET,RESET); 192 | 193 | goto_XY(95,6); printf("Choose an option:"); 194 | goto_XY(95,7); printf(" 1-ROLL"); 195 | goto_XY(95,8); printf(" 2-BUY HOUSES AND HOTELS"); 196 | goto_XY(95,9); printf(" 3-SELL PROPERTIES"); 197 | goto_XY(95,10);printf(" X-GIVE UP"); 198 | goto_XY(95,12);printf("PS: ROLL will be selected after selection of 2/3"); 199 | goto_XY(95,13);printf("You have 10 seconds or 1 will be chosen by default..."); 200 | Choice = TimedCharInput(10,0); 201 | if(Choice == 0) 202 | { 203 | goto_XY(95,15);printf("YOU TOOK TOO LONG TO CHOOSE, ROLL WAS CHOSEN BY DEFAULT"); 204 | return ROLL; 205 | } 206 | else if(Choice =='1') 207 | { 208 | goto_XY(95,15);printf("YOU CHOSE TO ROLL"); 209 | return ROLL; 210 | } 211 | else if(Choice =='2') 212 | { 213 | goto_XY(95,15);printf("YOU CHOSE TO BUY HOUSES AND HOTELS"); 214 | return BUY; 215 | } 216 | else if(Choice =='3') 217 | { 218 | goto_XY(95,15);printf("YOU CHOSE TO SELL PROPERTIES"); 219 | return SELL; 220 | } 221 | else if(Choice =='X'||Choice =='x') 222 | { 223 | goto_XY(95,15);printf("YOU CHOSE TO GIVE UP"); 224 | return GIVEUP; 225 | } 226 | else 227 | { 228 | if(i==0) 229 | { 230 | goto_XY(95,15);printf("YOU CHOSE AN INVALID OPTION. YOU CAN TRY ONCE AGAIN."); 231 | goto_XY(95,16);printf("PRESS ANY KEY TO CONTINUE..."); 232 | TimedCharInput(5,0); 233 | } 234 | else 235 | { 236 | goto_XY(95,15);printf("YOU CHOSE TO ROLL BY DEFAULT"); 237 | return ROLL; 238 | } 239 | } 240 | } 241 | } 242 | 243 | int RentCalc(struct player *owner ,struct location *currentLocation, int rolled) 244 | { 245 | if(currentLocation->type==RAIL) 246 | { 247 | int RailsOwned; 248 | for(int i=0;i<40;i++){ 249 | if(Location[i].type==RAIL && Location->ownerID==owner->ID){ 250 | RailsOwned++; 251 | } 252 | } 253 | for(int i=0;i<40;i++){ 254 | if(Location[i].type==RAIL && Location->ownerID==owner->ID){ 255 | Location[i].rent=25*RailsOwned; 256 | } 257 | } 258 | } 259 | else if(currentLocation->type==UTILITY) 260 | { 261 | int UtilitiesOwned; 262 | for(int i=0;i<40;i++){ 263 | if(Location[i].type==UTILITY && Location->ownerID==owner->ID){ 264 | UtilitiesOwned++; 265 | } 266 | } 267 | for(int i=0;i<40;i++){ 268 | if(Location[i].type==UTILITY && Location->ownerID==owner->ID){ 269 | if (UtilitiesOwned==1) 270 | Location[i].rent=4*rolled; 271 | else if (UtilitiesOwned==2) 272 | Location[i].rent=10*rolled; 273 | } 274 | } 275 | } 276 | return currentLocation->rent; 277 | } 278 | 279 | int SellMenu(struct player *CurrentPlayer) 280 | { 281 | int ChoiceInt; 282 | for (int i=0;i<2;i++) 283 | { 284 | int j=0; 285 | ClearRightScreen(0); 286 | 287 | goto_XY(95,3); 288 | printf("PLAYER: "); 289 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 290 | printf("%s ",CurrentPlayer->name); 291 | colour(RESET,RESET); 292 | printf("CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 293 | 294 | goto_XY(95,5); printf("SELL MENU FOR "); 295 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 296 | printf("%s ",CurrentPlayer->name); 297 | colour(RESET,RESET); 298 | 299 | goto_XY(95,6); printf("Choose a property to sell:"); 300 | if(CurrentPlayer->propertyOwnedCount>0) 301 | { 302 | for(j=0;jpropertyOwnedCount;j++) 303 | { 304 | goto_XY(95,7+j); printf(" %2d-SELL %s",j+1,Location[ CurrentPlayer->propertyOwned[j]-1 ].name); 305 | } 306 | } 307 | else 308 | { 309 | goto_XY(95,8); printf("YOU OWN NO PROPERTIES!"); 310 | goto_XY(95,11);printf("ROLLING BY DEFAULT"); 311 | return EXIT_SUCCESS; 312 | } 313 | goto_XY(95,7+j);printf(" %2d-CONTINUE AND ROLL",j+1); 314 | goto_XY(95,9+j);printf("You have 15 seconds or X will be chosen by default..."); 315 | ChoiceInt = TimedNumInput(15,0); 316 | if(ChoiceInt == 0) 317 | { 318 | goto_XY(95,11+j);printf("YOU TOOK TOO LONG TO CHOOSE, CONTINUE AND ROLL WAS CHOSEN BY DEFAULT"); 319 | return EXIT_SUCCESS; 320 | } 321 | else if(ChoiceInt == j+1) 322 | { 323 | goto_XY(95,11+j);printf("YOU CHOSE TO CONTINUE AND ROLL"); 324 | return EXIT_SUCCESS; 325 | } 326 | else 327 | { 328 | if (1<=ChoiceInt && ChoiceInt<=CurrentPlayer->propertyOwnedCount) 329 | { 330 | int ID = CurrentPlayer->propertyOwned[ChoiceInt-1] -1; 331 | int cost; 332 | if (Location[ID].type==PROPERTY) 333 | cost=Location[ID].cost + (Location[ID].housesBuilt + Location[ID].hotelBuilt)*Location[ID].buildCost; 334 | else 335 | cost=Location[ID].cost; 336 | goto_XY(95,11+j); printf("SOLD %s FOR $%d",Location[ID].name,cost); 337 | CurrentPlayer->cashInHand += cost; 338 | CurrentPlayer->propertyOwnedCount--; 339 | Location[ID].isOwnable=TRUE; 340 | Location[ID].ownerID=0; 341 | Location[ID].housesBuilt=0; 342 | Location[ID].hotelBuilt=FALSE; 343 | Location[ID].isSetComplete=FALSE; 344 | Location[ID].rent=Location[ID].initialRent; 345 | for(int s1=ChoiceInt-1; s1<19; s1++){ 346 | CurrentPlayer->propertyOwned[s1]=CurrentPlayer->propertyOwned[s1+1]; 347 | } 348 | CurrentPlayer->propertyOwned[19]=0; 349 | for(int s2=0;s2<40;s2++){ 350 | if(Location[ID].setID==Location[s2].setID) 351 | Location[s2].isSetComplete=FALSE; 352 | } 353 | 354 | return EXIT_SUCCESS; 355 | } 356 | else 357 | { 358 | if(i==0) 359 | { 360 | goto_XY(95,11+j);printf("YOU CHOSE AN INVALID OPTION. YOU CAN TRY ONCE AGAIN."); 361 | goto_XY(95,12+j);printf("PRESS ANY KEY TO CONTINUE..."); 362 | TimedCharInput(5,0); 363 | } 364 | else 365 | { 366 | goto_XY(95,11+j);printf("YOU CHOSE TO CONTINUE AND ROLL BY DEFAULT"); 367 | return EXIT_SUCCESS; 368 | } 369 | } 370 | } 371 | } 372 | } 373 | 374 | int BuyHousesMenu(struct player *CurrentPlayer) 375 | { 376 | int ChoiceInt; 377 | for (int i=0;i<2;i++) 378 | { 379 | int j=0; 380 | ClearRightScreen(0); 381 | 382 | goto_XY(95,3); 383 | printf("PLAYER: "); 384 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 385 | printf("%s ",CurrentPlayer->name); 386 | colour(RESET,RESET); 387 | printf("CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 388 | 389 | goto_XY(95,5); 390 | printf("BUY HOUSES AND HOTELS MENU FOR "); 391 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 392 | printf("%s ",CurrentPlayer->name); 393 | colour(RESET,RESET); 394 | 395 | goto_XY(95,6); printf("Choose an option for your properties:"); 396 | if(CurrentPlayer->propertyOwnedCount>0) 397 | { 398 | for(j=0;jpropertyOwnedCount;j++) 399 | { 400 | goto_XY(95,7+j); 401 | printf(" %2d-BUY HOUSES/HOTEL FOR %s",j+1,Location[ CurrentPlayer->propertyOwned[j]-1 ].name); 402 | } 403 | } 404 | else 405 | { 406 | goto_XY(95,8); printf("YOU OWN NO PROPERTIES!"); 407 | goto_XY(95,11);printf("YOU CHOSE TO CONTINUE AND ROLL BY DEFAULT"); 408 | return EXIT_SUCCESS; 409 | } 410 | goto_XY(95,7+j);printf(" %2d-CONTINUE AND ROLL",j+1); 411 | goto_XY(95,9+j);printf("You have 15 seconds or X will be chosen by default..."); 412 | ChoiceInt = TimedNumInput(15,0); 413 | if(ChoiceInt == 0) 414 | { 415 | goto_XY(95,11+j);printf("YOU TOOK TOO LONG TO CHOOSE, CONTINUE AND ROLL WAS CHOSEN BY DEFAULT"); 416 | return EXIT_SUCCESS; 417 | } 418 | else if(ChoiceInt ==j+1) 419 | { 420 | goto_XY(95,11+j);printf("YOU CHOSE TO CONTINUE AND ROLL"); 421 | return EXIT_SUCCESS; 422 | } 423 | else 424 | { 425 | if (1<=ChoiceInt && ChoiceInt<=CurrentPlayer->propertyOwnedCount) 426 | { 427 | int ID = CurrentPlayer->propertyOwned[ChoiceInt-1]-1; 428 | if(Location[ID].type==PROPERTY) 429 | { 430 | int flag=TRUE; 431 | for(int id=0;id<40;id++) 432 | { 433 | if(Location[id].setID!=0 && Location[id].type==PROPERTY && Location[ID].setID==Location[id].setID) 434 | { 435 | if(Location[id].ownerID!=CurrentPlayer->ID) 436 | { 437 | flag=FALSE; 438 | } 439 | } 440 | } 441 | for(int id=0;id<40;id++){ 442 | if(Location[ID].setID!=0 && Location[ID].setID==Location[id].setID && Location[ID].ownerID==Location[id].ownerID){ 443 | Location[id].isSetComplete=flag; 444 | } 445 | } 446 | if (Location[ID].isSetComplete) 447 | { 448 | char buildChoice; 449 | goto_XY(95,11+j); printf("Do you want to build houses or a hotel?"); 450 | goto_XY(95,12+j); printf(" 1-HOUSES"); 451 | goto_XY(95,13+j); printf(" 2-HOTELS"); 452 | goto_XY(95,14+j); printf(" X-NONE"); 453 | hideCursor(); 454 | buildChoice=getch(); 455 | showCursor(); 456 | if (buildChoice=='1') 457 | { 458 | int count; 459 | goto_XY(95,15+j); printf("HOW MANY HOUSES WOULD YOU LIKE TO BUILD (1-4):"); 460 | scanf("%d",&count); 461 | if((count+Location[ID].housesBuilt)>4) 462 | { 463 | goto_XY(95,16+j); 464 | printf("CANNOT BUILD %d MORE HOUSES! %d HOUSES ALREADY PRESENT!",count,Location[ID].housesBuilt); 465 | } 466 | else 467 | { 468 | if(CurrentPlayer->cashInHand>=(count*Location[ID].buildCost)) 469 | { 470 | CurrentPlayer->cashInHand-=count*Location[ID].buildCost; 471 | Location[ID].housesBuilt+=count; 472 | Location[ID].rent=Location[ID].house[Location[ID].housesBuilt]; 473 | goto_XY(95,16+j); 474 | printf("PROPERTY \"%s\" NOW HAS %d HOUSES!",Location[ID].name,Location[ID].housesBuilt); 475 | } 476 | else 477 | { 478 | goto_XY(95,16+j); 479 | printf("INSUFFICIENT BALANCE!"); 480 | } 481 | } 482 | return EXIT_SUCCESS; 483 | } 484 | else if (buildChoice=='2') 485 | { 486 | if(Location[ID].housesBuilt==TRUE) 487 | { 488 | goto_XY(95,15+j); 489 | printf("PROPERTY ALREADY HAS A HOTEL!"); 490 | } 491 | else 492 | { if(Location[ID].housesBuilt<4) 493 | { 494 | goto_XY(95,15+j); 495 | printf("PROPERTY NEEDS %d MORE HOUSES TO BUILD A HOTEL ",4-Location[ID].housesBuilt); 496 | } 497 | else if(CurrentPlayer->cashInHand>=(Location[ID].buildCost)) 498 | { 499 | CurrentPlayer->cashInHand-=Location[ID].buildCost; 500 | Location[ID].hotelBuilt=TRUE; 501 | Location[ID].rent=Location[ID].hotel; 502 | goto_XY(95,15+j); 503 | printf("PROPERTY \"%s\" NOW HAS A HOTEL!",Location[ID].name); 504 | } 505 | else 506 | { 507 | goto_XY(95,16+j); 508 | printf("INSUFFICIENT BALANCE!"); 509 | } 510 | return EXIT_SUCCESS; 511 | } 512 | } 513 | else 514 | return EXIT_SUCCESS; 515 | 516 | } 517 | else 518 | { 519 | goto_XY(95,11+j); 520 | printf("SET NOT COMPLETED!"); 521 | } 522 | goto_XY(95,12+j);printf("PRESS ANY KEY TO CONTINUE..."); 523 | TimedCharInput(2,0); 524 | } 525 | else 526 | { 527 | goto_XY(95,11+j); 528 | printf("HOUSES AND HOTELS CANNOT BE BUILT AT THIS LOCATION!"); 529 | goto_XY(95,12+j);printf("PRESS ANY KEY TO CONTINUE..."); 530 | TimedCharInput(2,0); 531 | } 532 | } 533 | else 534 | { 535 | if(i==0) 536 | { 537 | goto_XY(95,11+j);printf("YOU CHOSE AN INVALID OPTION . YOU CAN TRY ONCE AGAIN."); 538 | goto_XY(95,12+j);printf("PRESS ANY KEY TO CONTINUE..."); 539 | TimedCharInput(5,0); 540 | } 541 | else 542 | { 543 | goto_XY(95,11+j);printf("YOU CHOSE TO CONTINUE AND ROLL BY DEFAULT"); 544 | return EXIT_SUCCESS; 545 | } 546 | } 547 | } 548 | } 549 | } 550 | 551 | int BuyMenu(struct player *CurrentPlayer,struct location *currentLocation) 552 | { 553 | char Choice; 554 | for (int i=0;i<2;i++) 555 | { 556 | ClearRightScreen(0); 557 | 558 | goto_XY(95,3); 559 | printf("PLAYER: "); 560 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 561 | printf("%s ",CurrentPlayer->name); 562 | colour(RESET,RESET); 563 | printf("CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 564 | 565 | goto_XY(95,5); printf("MENU FOR "); 566 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 567 | printf("%s ",CurrentPlayer->name); 568 | colour(RESET,RESET); 569 | 570 | goto_XY(95,6); printf("Would you like to buy %s for $%d ?",currentLocation->name,currentLocation->cost); 571 | goto_XY(95,7); printf(" 1-YES"); 572 | goto_XY(95,8); printf(" 2-NO"); 573 | goto_XY(95,10);printf("You have 10 seconds or 2 will be chosen by default..."); 574 | Choice = TimedCharInput(10,0); 575 | if(Choice == 0) 576 | { 577 | goto_XY(95,15);printf("YOU TOOK TOO LONG TO CHOOSE, NO WAS CHOSEN BY DEFAULT"); 578 | return EXIT_SUCCESS; 579 | } 580 | else if(Choice =='1') 581 | { 582 | if(currentLocation->isOwnable) 583 | { 584 | if (currentLocation->cost>CurrentPlayer->cashInHand) 585 | { 586 | goto_XY(95,15); 587 | printf("INSUFFICIENT BALANCE"); 588 | } 589 | else 590 | { 591 | goto_XY(95,15);printf("BOUGHT %s!",currentLocation->name); 592 | currentLocation->isOwnable=FALSE; 593 | currentLocation->ownerID=CurrentPlayer->ID; 594 | CurrentPlayer->cashInHand -= currentLocation->cost; 595 | CurrentPlayer->propertyOwned[CurrentPlayer->propertyOwnedCount]=currentLocation->ID; 596 | CurrentPlayer->propertyOwnedCount++; 597 | } 598 | } 599 | else 600 | { 601 | goto_XY(95,15); 602 | printf("THIS PROPERTY CANNOT BE BOUGHT!"); 603 | } 604 | return EXIT_SUCCESS; 605 | } 606 | else if(Choice =='2') 607 | { 608 | goto_XY(95,15);printf("YOU CHOSE NO"); 609 | return EXIT_SUCCESS; 610 | } 611 | else 612 | { 613 | if(i==0) 614 | { 615 | goto_XY(95,15);printf("YOU CHOSE AN INVALID OPTION. YOU CAN TRY ONCE AGAIN."); 616 | goto_XY(95,16);printf("PRESS ANY KEY TO CONTINUE..."); 617 | TimedCharInput(5,0); 618 | } 619 | else 620 | { 621 | goto_XY(95,15);printf("YOU CHOSE TO ROLL BY DEFAULT"); 622 | return EXIT_SUCCESS; 623 | } 624 | } 625 | } 626 | } 627 | 628 | int IsPlayerBankrupt(int cashInHand) 629 | { 630 | if(cashInHand>BANKRUPT_VALUE) 631 | return FALSE; 632 | else 633 | return TRUE; 634 | } 635 | 636 | int PlayerResults(struct player Player[],int PlayerCount) 637 | { 638 | printf("\n"); 639 | printf("\n 8888888b. 8888888888 .d8888b. 888 888 888 88888888888 .d8888b. "); 640 | printf("\n 888 Y88b 888 d88P Y88b 888 888 888 888 d88P Y88b "); 641 | printf("\n 888 888 888 Y88b. 888 888 888 888 Y88b. "); 642 | printf("\n 888 d88P 8888888 \"Y888b. 888 888 888 888 \"Y888b. "); 643 | printf("\n 8888888P\" 888 \"Y88b. 888 888 888 888 \"Y88b. "); 644 | printf("\n 888 T88b 888 \"888 888 888 888 888 \"888 "); 645 | printf("\n 888 T88b 888 Y88b d88P Y88b. .d88P 888 888 Y88b d88P "); 646 | printf("\n 888 T88b 8888888888 \"Y8888P\" \"Y88888P\" 88888888 888 \"Y8888P\" "); 647 | printf("\n\n\n\n\n"); 648 | int len=12,array[10]; 649 | for (int i=0;iHighestNetworth) 668 | { 669 | HighestNetworth=Player[j].netWorth; 670 | array[i]=j+1; 671 | } 672 | else if(Player[j].netWorth==HighestNetworth) 673 | { 674 | int HighestCashInHand=0; 675 | for (int j=0;jHighestCashInHand) 680 | { 681 | HighestCashInHand=Player[j].cashInHand; 682 | array[i]=j+1; 683 | } 684 | } 685 | } 686 | } 687 | } 688 | } 689 | Player[array[i]-1].position=i+1; 690 | } 691 | } 692 | printf("\n\t\t%9s %*s %13s %9s","POSITION",len,"PLAYER NAME","CASH IN HAND","NET WORTH"); 693 | for (int i=0; i= 1400){ 102 | maxNetworth=atoi(inp); 103 | break; 104 | } 105 | printf("\n\n\tInvalid Input (Enter a number from greater than 1400) \n\tEntered: %s\n",inp); 106 | } 107 | while (GamemodeChoice == TURNS) 108 | { 109 | char inp[1]; 110 | printf("\n\n\tEnter maximum turns after which game is to end: "); 111 | scanf("%s",&inp); 112 | if (atoi(inp) >= 1){ 113 | maxTurns=atoi(inp); 114 | break; 115 | } 116 | printf("\n\n\tInvalid Input (Enter a number greater than 0) \n\tEntered: %s\n",inp); 117 | } 118 | clearScreen(); 119 | 120 | if (GamemodeChoice!=EXIT) 121 | { 122 | int PlayerCount; 123 | char Names[9][30]; 124 | struct player Players[9], *CurrentPlayer; 125 | if (ReadLocations()!=EXIT_SUCCESS){ 126 | printf("\nFile could not be opened\n"); 127 | return EXIT_FAILURE; 128 | } 129 | else if (ReadPlayers(&PlayerCount,Names)!=EXIT_SUCCESS){ 130 | printf("\nPlayers not read properly\n"); 131 | return EXIT_FAILURE; 132 | } 133 | else if (SetPlayerOrder(PlayerCount,Names)!=EXIT_SUCCESS){ 134 | printf("\nPlayers random order could not be set properly\n"); 135 | return EXIT_FAILURE; 136 | } 137 | else if (InitialisePlayers(Players,PlayerCount,Names)!=EXIT_SUCCESS){ 138 | printf("\nPlayer values could not be set properly\n"); 139 | return EXIT_FAILURE; 140 | } 141 | goto_XY(95,SCREENSIZE_Y-1); 142 | printf("\n\n\tEnter any key to continue..."); 143 | getch(); 144 | clearScreen(); 145 | 146 | DisplayMap(); 147 | for(int i=0;iisOut) 164 | { 165 | if (CurrentPlayer->isInJail) 166 | { 167 | ClearRightScreen(0); 168 | goto_XY(95,3); printf("PLAYER: %s CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->name,CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 169 | int stay=TRUE; 170 | if (CurrentPlayer->jailTurn==2) 171 | { 172 | goto_XY(95,5);printf("%s, do you want to pay to get out of jail or stay for %d more turns?",CurrentPlayer->name,CurrentPlayer->jailTurn+1); 173 | goto_XY(95,6);printf(" 1: Pay to leave"); 174 | goto_XY(95,7);printf(" 2: Stay in Jail"); 175 | hideCursor(); 176 | char JailOpt=getch(); 177 | showCursor(); 178 | while(!(JailOpt=='1'||JailOpt=='2')) 179 | { 180 | goto_XY(95,8);printf("Invalid option!You entered: %c ",JailOpt); 181 | goto_XY(95,9);printf("Re-enter your choice!"); 182 | JailOpt=getch(); 183 | } 184 | switch(JailOpt) 185 | { 186 | case'1':stay = FALSE; 187 | CurrentPlayer->cashInHand-=100; 188 | CurrentPlayer->netWorth-=100; //Pay to leave 189 | CurrentPlayer->jailTurn=0; 190 | CurrentPlayer->isInJail=FALSE; 191 | goto_XY(95,11);printf("You can play next turn."); 192 | break; 193 | 194 | default:stay = TRUE; 195 | } 196 | } 197 | if (stay==TRUE) 198 | { 199 | goto_XY(95,13);printf(" %s is in Jail, wait for %d turn(s) to play.",CurrentPlayer->name,CurrentPlayer->jailTurn+1); 200 | if(CurrentPlayer->jailTurn>0) 201 | CurrentPlayer->jailTurn-=1; 202 | else 203 | { 204 | CurrentPlayer->jailTurn=0; 205 | CurrentPlayer->isInJail=FALSE; 206 | } 207 | } 208 | } 209 | else 210 | { 211 | 212 | goto_XY(95,3); 213 | printf("PLAYER: "); 214 | colour(CurrentPlayer->colour1,CurrentPlayer->colour2); 215 | printf("%s ",CurrentPlayer->name); 216 | colour(RESET,RESET); 217 | printf("CASH IN HAND: $%d NET WORTH: $%d ",CurrentPlayer->cashInHand,CurrentPlayer->netWorth); 218 | 219 | ClearRightScreen(16); 220 | int Choice=0; 221 | if (wasDouble==0) 222 | Choice=PlayerMainMenu(CurrentPlayer); 223 | 224 | if (Choice!=GIVEUP) 225 | { 226 | if (Choice==BUY) 227 | BuyHousesMenu(CurrentPlayer); 228 | else if (Choice==SELL) 229 | SellMenu(CurrentPlayer); 230 | 231 | Choice=ROLL; 232 | die1=PlayerRolls();die2=PlayerRolls();dieTotal=die1+die2; 233 | goto_XY(95,20);printf("%s rolls a %d and %d with a total of %d.",CurrentPlayer->name,die1,die2,dieTotal); 234 | if (die1==die2) 235 | { 236 | goto_XY(95,21);printf("%s got a double!",CurrentPlayer->name); 237 | wasDouble+=1; 238 | } 239 | else 240 | wasDouble=0; 241 | int Teleported; 242 | if (wasDouble==MAX_DOUBLES) 243 | { 244 | //Sending player to jail for MAX_DOUBLES sets of doubles in a row 245 | int OldLocationID = CurrentPlayer->currentLocation->ID; 246 | CurrentPlayer->currentLocation=&Location[30]; 247 | goto_XY(95,23);printf("Since %s rolled a double again, they are sent to JAIL for overspeeding.",CurrentPlayer->name); 248 | GraphicalMove(CurrentPlayer,OldLocationID,CurrentPlayer->currentLocation->ID); 249 | wasDouble=0; 250 | } 251 | else 252 | { 253 | //Moving current players's current location and checking if they passed START 254 | 255 | //Reaches here when player draws a NEUTRAL card 256 | LocationTeleporter: ; 257 | int OldLocationID = CurrentPlayer->currentLocation->ID; 258 | if ((CurrentPlayer->currentLocation->ID)+dieTotal > 40) 259 | { 260 | goto_XY(95,23);printf("%s passed %s and collects $200!",CurrentPlayer->name,Location[0].name); 261 | CurrentPlayer->cashInHand += 200; 262 | CurrentPlayer->netWorth += 200; 263 | CurrentPlayer->currentLocation=&Location[((CurrentPlayer->currentLocation->ID)+dieTotal)-39]; 264 | GraphicalMove(CurrentPlayer,OldLocationID,CurrentPlayer->currentLocation->ID); 265 | } 266 | else 267 | { 268 | CurrentPlayer->currentLocation=&Location[(CurrentPlayer->currentLocation->ID)+dieTotal-1]; 269 | } 270 | if (Teleported) 271 | goto_XY(95,28); 272 | else 273 | goto_XY(95,24); 274 | Teleported=FALSE; 275 | printf("%s landed on %s. ",CurrentPlayer->name,CurrentPlayer->currentLocation->name); 276 | GraphicalMove(CurrentPlayer,OldLocationID,CurrentPlayer->currentLocation->ID); 277 | } 278 | 279 | switch(CurrentPlayer->currentLocation->type) 280 | { 281 | //Performing actions based on location type 282 | case FREE: 283 | { 284 | break; 285 | } 286 | case CHEST: 287 | case CHANCE: 288 | { 289 | if (GenerateCard()!=EXIT_SUCCESS) 290 | { 291 | goto_XY(95,SCREENSIZE_Y-1); 292 | printf("\nCard generation Error at Location Record %d",ID+1); 293 | return EXIT_FAILURE; 294 | } 295 | else 296 | { 297 | goto_XY(95,25);printf("%s draws a card.",CurrentPlayer->name); 298 | switch(drawnCard.type) 299 | { 300 | case BAD: 301 | { 302 | goto_XY(95,26);printf("OH NO! %s pays %d ",CurrentPlayer->name,drawnCard.money); 303 | switch((rand()%(5))) 304 | { 305 | case 0 : printf("to the MAYOR!");break; 306 | case 1 : printf("for car insurance!");break; 307 | case 2 : printf("for health insurance!");break; 308 | case 3 : printf("to Monopoly man!");break; 309 | default: printf("to the BANK!");break; 310 | } 311 | CurrentPlayer->cashInHand-=drawnCard.money; 312 | CurrentPlayer->netWorth -=drawnCard.money; 313 | break; 314 | } 315 | case NEUTRAL: 316 | { 317 | int OldLocationID = CurrentPlayer->currentLocation->ID; 318 | goto_XY(95,26);printf("%s teleports!",CurrentPlayer->name,Location[drawnCard.locationID].name); 319 | CurrentPlayer->currentLocation = &Location[drawnCard.locationID]; 320 | GraphicalMove(CurrentPlayer,OldLocationID,CurrentPlayer->currentLocation->ID); 321 | Teleported=TRUE; 322 | goto LocationTeleporter; 323 | break; 324 | } 325 | case GOOD: 326 | { 327 | goto_XY(95,26);printf("OOOH! %s gets %d ",CurrentPlayer->name,drawnCard.money); 328 | switch((rand()%(5))) 329 | { 330 | case 0 : printf("from the MAYOR!");break; 331 | case 1 : printf("from the lottery!");break; 332 | case 2 : printf("for good luck!");break; 333 | case 3 : printf("from Monopoly man!");break; 334 | default: printf("from the BANK!");break; 335 | } 336 | CurrentPlayer->cashInHand+=drawnCard.money; 337 | CurrentPlayer->netWorth +=drawnCard.money; 338 | break; 339 | } 340 | default: 341 | { 342 | goto_XY(95,SCREENSIZE_Y-1); 343 | printf("\nCard generation Error at Location Record %d",ID+1); 344 | return EXIT_FAILURE; 345 | } 346 | } 347 | } 348 | break; 349 | } 350 | case JAIL: 351 | { 352 | int OldLocationID = CurrentPlayer->currentLocation->ID; 353 | goto_XY(95,25);printf("%s, have fun in Jail. :)",CurrentPlayer->name); 354 | wasDouble=0; 355 | CurrentPlayer->currentLocation=&Location[10]; 356 | CurrentPlayer->isInJail=TRUE; 357 | CurrentPlayer->jailTurn=2; 358 | GraphicalMove(CurrentPlayer,OldLocationID,CurrentPlayer->currentLocation->ID); 359 | break; 360 | } 361 | case TAX: 362 | { 363 | goto_XY(95,25);printf("%s pays %d as tax!",CurrentPlayer->name,CurrentPlayer->currentLocation->rent); 364 | CurrentPlayer->cashInHand -= CurrentPlayer->currentLocation->rent; 365 | CurrentPlayer->netWorth -= CurrentPlayer->currentLocation->rent; 366 | break; 367 | } 368 | case UTILITY: 369 | case RAIL: 370 | case PROPERTY: 371 | { 372 | goto_XY(95,37);printf("Press any key to continue...");getch(); 373 | if(CurrentPlayer->currentLocation->isOwnable) 374 | { 375 | BuyMenu(CurrentPlayer,CurrentPlayer->currentLocation); 376 | } 377 | else 378 | { 379 | if(CurrentPlayer->currentLocation->ownerID==CurrentPlayer->ID){ 380 | goto_XY(95,25);printf("%s landed on their own property!",CurrentPlayer->name); 381 | } 382 | else 383 | { 384 | goto_XY(95,25);printf("%s landed on %s's property!",CurrentPlayer->name,Players[ CurrentPlayer->currentLocation->ownerID-1 ].name); 385 | int Rent = RentCalc(&Players[ CurrentPlayer->currentLocation->ownerID-1 ],CurrentPlayer->currentLocation,dieTotal); 386 | 387 | goto_XY(95,26);printf("%s paid %s $%d!",CurrentPlayer->name,Players[CurrentPlayer->currentLocation->ownerID -1].name,Rent); 388 | 389 | CurrentPlayer->cashInHand -= Rent; 390 | CurrentPlayer->netWorth -= Rent; 391 | Players[CurrentPlayer->currentLocation->ownerID -1].cashInHand += Rent; 392 | Players[CurrentPlayer->currentLocation->ownerID -1].netWorth += Rent; 393 | } 394 | } 395 | break; 396 | } 397 | default: 398 | { 399 | goto_XY(95,SCREENSIZE_Y-1); 400 | printf("\nFile Value Error at Location Record %d",ID+1); 401 | return EXIT_FAILURE; 402 | } 403 | } 404 | 405 | CurrentPlayer->isBankrupt=IsPlayerBankrupt(CurrentPlayer->cashInHand); 406 | if(CurrentPlayer->isBankrupt) 407 | { 408 | goto_XY(95,30);printf("%s IS BANKRUPT !!!",CurrentPlayer->name); 409 | CurrentPlayer->isOut=TRUE; 410 | CurrentPlayer->position=PlayerCount-PlayersOut; 411 | PlayersOut++; 412 | CurrentPlayer->propertyOwnedCount=0; 413 | for(int i=0;i<20;i++){ 414 | CurrentPlayer->propertyOwned[i]=0; 415 | } 416 | for(int i=0;i<40;i++){ 417 | if(Location[i].ownerID==CurrentPlayer->ID) 418 | { 419 | Location[i].isOwnable=TRUE; 420 | Location[i].ownerID=0; 421 | Location[i].housesBuilt=0; 422 | Location[i].hotelBuilt=FALSE; 423 | Location[i].isSetComplete=FALSE; 424 | Location[i].rent=Location[i].initialRent; 425 | } 426 | } 427 | } 428 | } 429 | else 430 | { 431 | CurrentPlayer->isOut=TRUE; 432 | CurrentPlayer->position=PlayerCount-PlayersOut; 433 | PlayersOut++; 434 | CurrentPlayer->propertyOwnedCount=0; 435 | for(int i=0;i<20;i++){ 436 | CurrentPlayer->propertyOwned[i]=0; 437 | } 438 | for(int i=0;i<40;i++){ 439 | if(Location[i].ownerID==CurrentPlayer->ID) 440 | { 441 | Location[i].isOwnable=TRUE; 442 | Location[i].ownerID=0; 443 | Location[i].housesBuilt=0; 444 | Location[i].hotelBuilt=FALSE; 445 | Location[i].isSetComplete=FALSE; 446 | Location[i].rent=Location[i].initialRent; 447 | } 448 | } 449 | } 450 | } 451 | 452 | } 453 | 454 | //Next player plays if current player did not get doubles 455 | if (wasDouble!=0){ 456 | goto_XY(95,28);printf("%s plays again!",CurrentPlayer->name); 457 | } 458 | else if (ID+1>=PlayerCount){ 459 | ID=0; 460 | currentTurns++; 461 | } 462 | else ID++; 463 | 464 | goto_XY(95,37);printf("Press any key to continue..."); 465 | if (getch()=='x') 466 | { 467 | ClearRightScreen(0); 468 | goto_XY(95,5);printf("Game interrupt"); 469 | GamemodeChoice=EXIT; 470 | } 471 | 472 | if (GamemodeChoice==NETWORTH) 473 | { 474 | for(int i=0;i=maxNetworth) 477 | { 478 | ClearRightScreen(0); 479 | goto_XY(95,5);printf("%s HAS ATTAINED A NET WORTH OF %d !", Players[i].name, Players[i].netWorth); 480 | Players[i].position=1; 481 | GamemodeChoice=EXIT; 482 | } 483 | } 484 | } 485 | else if (GamemodeChoice==TURNS) 486 | { 487 | if (currentTurns>=maxTurns) 488 | { 489 | ClearRightScreen(0); 490 | goto_XY(95,5);printf("%d TURNS HAVE PASSED!",maxTurns); 491 | GamemodeChoice=EXIT; 492 | } 493 | } 494 | if(!(PlayerCount-PlayersOut>1)) 495 | { 496 | ClearRightScreen(0); 497 | for(int i=0;i 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------