{"id":22704990,"url":"https://github.com/benji377/tug-oop1-01","last_synced_at":"2025-03-29T20:23:12.133Z","repository":{"id":264506780,"uuid":"784727248","full_name":"Benji377/TUG-OOP1-01","owner":"Benji377","description":"A simple tactical round-based game in C++ | Lecture exercise","archived":false,"fork":false,"pushed_at":"2024-04-10T12:43:34.000Z","size":1821,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:12:35.180Z","etag":null,"topics":["cpp","game"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Benji377.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-10T12:42:32.000Z","updated_at":"2024-10-02T13:46:05.000Z","dependencies_parsed_at":"2024-11-24T23:45:31.186Z","dependency_job_id":null,"html_url":"https://github.com/Benji377/TUG-OOP1-01","commit_stats":null,"previous_names":["benji377/tug-oop1-01"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-OOP1-01","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-OOP1-01/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-OOP1-01/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-OOP1-01/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Benji377","download_url":"https://codeload.github.com/Benji377/TUG-OOP1-01/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246238724,"owners_count":20745587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","game"],"created_at":"2024-12-10T09:08:38.611Z","updated_at":"2025-03-29T20:23:12.113Z","avatar_url":"https://github.com/Benji377.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assignment 1 - OOPtimal Tactics\n\n## Introduction\n\nIn Assignment 1 (A1) of the OOP1 practicals (KU) you will implement a simple tactical round-based game where two players\ncompete in claiming the most amount of tiles on a grid-based map.\n\nThis document describes the structure of the assignment and the expected functionality of the program.\n\n## Learning Goals\n\n- Foundations of classes:\n    - attributes, methods\n    - constructor, copy constructor, destructor\n- Strings \u0026 streams:\n    - `std::string`\n    - files\n- Some data structures of the standard library:\n    - e.g. `std::vector`\n\n## Specification\n\nSome general specifications must be followed for every assignment in this course. A list of these specifications can be\nfound\nhere: [Assessment of Assignments - Deductions](https://www.notion.so/coding-tugraz/Assessment-of-Assignments-How-do-you-get-your-points-work-in-progress-00d2624846f4491391b389e6a48fa180?pvs=4#0af0c923deff4c4bb8740f5698aca451)\n\nPlease follow these specifications to avoid point deductions.\n\nAdditionally, the following specifications must be followed for this assignment (A1) as well:\n\n- You **must** implement and use all described classes in your assignment. The required classes are described in detail in\n  the [description folder](./description). \n- The provided `main.cpp` **must not** be changed and is replaced with the original version in our test system. The existing functionalities in `Utils.hpp/cpp` and `CommandLine.hpp/cpp` should not be changed, however, you are allowed to extend these classes.\n- In this assignment (but only in this one), you do not have to check if memory was allocated successfully.\n- Your implementation needs to follow the so-called \"Rule of 3\". That means that for every class, the constructor, \ncopy constructor and destructor needs to be implemented, explicitly set to default, or deleted.\n\nIf any of these specifications are not followed, this may result in a deduction of up to -25 % per specification.\n\n## Grading\n\nAssignment 1 is worth **16 points**.\n\n**Attention:** To receive a positive grade on the OOP1 KU **at least half of the public test cases for A1 have to be\npassed**\n(among other conditions).\n\nInformation on how your assignment submission will be assessed can be found\nhere: [Assessment of Assignments](https://www.notion.so/coding-tugraz/Assessment-of-Assignments-How-do-you-get-your-points-work-in-progress-00d2624846f4491391b389e6a48fa180)\n\nHere you can find an overview of how your total grade for the KU will be\ncalculated: [Procedure and Grading](https://www.notion.so/coding-tugraz/Practicals-structure-grading-and-plagiarism-work-in-progress-76127221ed43451abc7ffba7852595e3)\n\nThere will not be any assignment interviews for A1.\n\n## Submission\n\n- Push to your repository\n- The last commit on the main branch before the deadline will be graded\n- Deliverables: all .cpp and .hpp files needed to run your program\n- **Deadline: 10.04.2024, 23:59 (GMT+1)**\n- **Assignment 1 is solo work!** See\n  our [Guidelines on Plagiarism](https://www.notion.so/coding-tugraz/Practicals-structure-grading-and-plagiarism-work-in-progress-76127221ed43451abc7ffba7852595e3?pvs=4#93a62cfe219949929fa2fc41f2f1ff37)\n\n## General Notes\n\nThe notes given in this section are important for the whole assignment description.\n\n\u003e **Note:** Any changes made to the upstream repository will be announced on our Discord server. Please make sure to\n\u003e [join the server](https://discord.gg/73EeHV6eDn) and then join the OOP1 group in the #role channel.\n\n- `\\n` shouldn't be printed as separate characters, instead it represents the newline character.\n- Note the leading and trailing whitespaces in the text fields! You can make them visible by selecting the text field.\n- Words in sharp brackets (like `\u003cPLAYER_ID\u003e`) should be replaced by calculated or given data. They are *not* part of\n  the output itself! For a better understanding you can look at the example output at the end of this document.\n- The user input is **case-insensitive**. This means that `move`, `MoVe` and `MOVE` would all be valid inputs.\n- All additional whitespaces (leading, trailing, or additional whitespaces between command and parameters or between two\n  parameters) in the input should be ignored.\n- The program needs to be able to handle arbitrary input in any form (e.g. strings when integers are expected).\n\n## Framework\n\nWe provide to you a `main.cpp` which must be used as the starting point of your program. This file must not be changed, as it will be replaced by the test system with the original version, so your program must be compatible with it.\n\nAdditionally, we provide the class Utils (`Utils.hpp/Utils.cpp`), which contains a function to safely convert a string to an integer,\nand the class CommandLine (`CommandLine.hpp/cpp`), which should be used to convert user input into Command objects. \nThe existing functionality should not be changed, but you can extend those classes if needed.\n\n## Custom Data Types\n\nAfter reading the Assignment Description below, it is recommended to start with the definition of the custom data types\nused in this program. Descriptions for all of\nthese data types can be found in the [description folder](./description). In this first step, it is not required to actually implement\nany of the described methods in detail, but they should be declared at least. Keep in mind that all data members (member\nvariables) of all classes should be declared as `private`. You are allowed to add further member variables and methods to all classes.\n\n## Assignment Description\n\nIn this assignment you will implement a simple tactical round-based game where two players compete in claiming the\nmost fields on a grid-based map. The two competing players will be called `Player A` and `Player B`.\n\nEach round the players will get some chips that they can strategically place in the `Placement Phase` of the round on \nowned fields to protect them. In the following `Movement Phase` of the round they can move chips \n to claim empty fields or fields that the other player currently owns. Each field can hold multiple chips, but only from one player at a time.\n\nThe game ends when one player does not own any more fields or the specified maximum round number has been reached.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eStarting the Game\u003c/h3\u003e\u003c/summary\u003e\n\nThe program is called with two command line parameters. The first parameter is the maximum number of rounds to be played\nand the second parameter is the path to a config file that contains the layout of the map and the starting positions of\neach player.\n\nFor example:\n\n```\n./a1 10 configs/config_01.txt\n```\n\nIf the program is called\n\n- with the wrong number of parameters\n- with an invalid maximum round number (valid is only an integer greater or equal to 1)\n- with a config file that cannot be opened\n- with a config file that does not start with the\n  correct [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)) (`OOP\\n`)\n\nthe corresponding error message should be printed and the program should terminate with the correct return\nvalue (see [Return Values and Error Messages](#return-values-and-error-messages)).\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eParsing the Config File\u003c/h4\u003e\u003c/summary\u003e\n\nThe config file should then be parsed.\n\nEvery config file contains a [magic number](https://de.wikipedia.org/wiki/Magische_Zahl_(Informatik)) in the first line\n(`OOP\\n`). This string has to be checked for its correctness. If the magic number is correct you can assume that the\nfile is correctly formatted and no further checks of the file's content are needed.\n\nIn the second line, the dimension of the game map is represented in the format `\u003cWIDTH\u003e_\u003cHEIGHT\u003e`. Example: `4_5`\n\nAfter that, the map data itself will span over the remaining lines. Each line represents a single row of the map, with:\n\n- the character `a` being a start field of `Player A`\n- the character `b` being a start field of `Player B`\n- the character `0` being an empty field\n- the character `-` being a water field\n\nA valid config file could for example look like this:\n\n```txt\nOOP\\n\n4_5\\n\naaa0\\n\n0000\\n\n00--\\n\n00--\\n\n0bbb\\n\n```\n\nA start field means the player currently claims this field and has one `chip` on it at the start.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\u003ch4\u003eWelcome Message\u003c/h4\u003e\u003c/summary\u003e\n\nAfter parsing the config file, the game should start by greeting the players with the output:\n\n```\nWelcome to OOPtimal Tactics!\nPlaying maximum of \u003cROUNDS\u003e round(s)!\n```\n\n`\u003cROUNDS\u003e` should be replaced by the supplied command line parameter for the maximum rounds.\nAfter that the first round starts.\n\n\u003c/details\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eMap Output\u003c/h3\u003e\u003c/summary\u003e\n\nDuring the game, the current map status that has resulted from parsing the config file and the players' moves will be\nprinted multiple times.\nThe map should always be printed in the following format:\n\n- A singular claimed field will always be printed in the format: `\u003cPLAYER_ID\u003e \u003cCHIPS_ON_FIELD\u003e`. For simplicity, you do not \nneed to handle the case that the amount of chips on a field exceeds 9, so the number will always be a single digit.\n- If the field is empty (no player currently claims that field) it should be printed as three spaces\n\u003ccode\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/code\u003e. \n- If the field is a water field it should be printed as \u003ccode\u003e\u0026nbsp;~\u0026nbsp;\u003c/code\u003e.\n\nExample field claimed by `Player A` with 2 chips on it:\n\n```\nA 2\n```\n\nExample water field (pay attention to the spaces):\n\n```\n ~ \n```\n\nThe map should be printed by combining all fields and using `|` as a separator between horizontally connected fields.\nThe axes should be indexed by numbers starting with 1. For simplicity, you do not need to handle the case where the height or the width of the map exceeds 9, so the index will always be a single digit.\nThe map is always followed by an empty line.\nIf the map output was deactivated (see Playing the Game \u003e General Commands \u003e Command map) the empty line should also not be printed.\n\nUsing the example config from above, at the beginning of the game the map would look like this:\n\n```\n  | 1 | 2 | 3 | 4 \\n\n1 |A 1|A 1|A 1|   \\n\n2 |   |   |   |   \\n\n3 |   |   | ~ | ~ \\n\n4 |   |   | ~ | ~ \\n\n5 |   |B 1|B 1|B 1\\n\n\\n\n```\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eRound Overview\u003c/h3\u003e\u003c/summary\u003e\n\nAt the start of each round the following message should be printed:\n\n```\n\\n\n------------------\\n\nRound \u003cCURRENT_ROUND\u003e/\u003cMAX_ROUNDS\u003e starts!\\n\n------------------\\n\n\\n\n```\n\nwhere\n\n- `\u003cCURRENT_ROUND\u003e` should be replaced by the current round\n- `\u003cMAX_ROUNDS\u003e` should be replaced by the maximum number of rounds to be played\n\nThen both players receive chips that they can place down in the `Placement Phase`.\nThe number of chips gained is calculated by dividing the number of fields currently claimed by the player by three and rounding up.\n\n$`\\textrm{\u003cCHIPS\\_GAINED\u003e = }\\left \\lceil{\\frac{\\textrm{\u003cNUMBER\\_OF\\_FIELDS\\_CLAIMED\\_BY\\_THAT\\_PLAYER\u003e}}{3.0}}\\right \\rceil`$\n\nNext follows the `Placement Phase`, where the players can place the chips they just received and any previously\nunplaced chips on the map.\n\nAfter that, in the `Movement Phase`, the players can move their chips on the map between adjacent fields and/or try to\nclaim additional fields for themselves.\n\nThe `Placement Phase` and the `Movement Phase` are described in more detail below.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003ePlaying the Game\u003c/h3\u003e\u003c/summary\u003e\n\nThe players control the game by typing commands in the command line interface. Depending on if the game is currently in the \n`Placement Phase` or the `Movement Phase`, a different question is asked to prompt the player for input. The question is followed\nby the command prompt \u003ccode\u003e\u0026nbsp;\u003e\u0026nbsp;\u003c/code\u003e (Note the leading and trailing space!).\n\nUnknown commands or commands that are not valid in the current phase should cause an error. All commands should be checked for the errors\nspecified in their description. If there is an error while parsing a command, print the correct error message\n(see [Return Values and Error Messages](#return-values-and-error-messages)) and proceed by prompting the player for\ninput again with the question and the command prompt.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eGeneral Commands\u003c/h4\u003e\u003c/summary\u003e\n\nThe following commands should work in both the `Placement Phase` and the `Movement Phase` of the game.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand quit\u003c/h5\u003e\u003c/summary\u003e\n\nSyntax: `quit`\n\nThis command stops the game. The program should release all its resources\nand terminate with the return value `0`.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand info\u003c/h5\u003e\u003c/summary\u003e\n\nSyntax: `info`\n\nThis command shows some information about the current player:\n\n```\nPlayer \u003cPLAYER_ID\u003e:\\n\nYou have \u003cCHIPS\u003e chip(s) saved!\\n\nYou own \u003cNUMBER_OF_CLAIMED_FIELDS\u003e field(s)!\\n\n\\n\n```\n\nwhere\n\n- `\u003cPLAYER_ID\u003e` should be replaced by the player id (the capital letter `A` or `B`)\n- `\u003cCHIPS\u003e` should be replaced by the amount of available chips left for that player\n- `\u003cNUMBER_OF_CLAIMED_FIELDS\u003e` should be replaced by the number of fields claimed by that player\n\nThis command does not end the player's turn.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand map\u003c/h5\u003e\u003c/summary\u003e\n\nSyntax: `map`\n\nThis command activates or deactivates the output of the map.\n\nInitially the output of the map is active.\nIf the output of the map is active and the command `map` is entered, the output is deactivated.\nFor all further turns, the map is not printed anymore.\nIf the output of the map is not active and the command `map` is entered, the output is activated.\nThe map is printed once immediately. The output of the map then stays active for the following turns.\n\nThis command does not end the player's turn.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand pass\u003c/h5\u003e\u003c/summary\u003e\n\nSyntax: `pass`\n\nIf a player does not want to play any more commands in the current phase they can use the `pass` command.\n**The player will then not be prompted for any further commands in this phase.** The other player will continue playing \nin the current phase. If both players have passed in a phase, \nthe phase ends.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n\n\u003c/details\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003ePlacement Phase\u003c/h4\u003e\u003c/summary\u003e\n\nIn this phase the players can place their received chips and any chips they have leftover from previous rounds. This phase continues until both players are finished with this\nphase, either by having no chips left or by using a `pass` command. Afterwards the `Movement Phase` starts.\n\nUnplaced chips will be carried over to the next round.\n\nFirst print the following header:\n\n```\n------------------\\n\nPlacement Phase\\n\n------------------\\n\n\u003cMAP\u003e\n```\n\nwhere\n\n- `\u003cMAP\u003e` should be replaced by the current status of the map (see Map Output). If the map output is\n  deactivated, the header should be printed without the map.\n\nThen the players take turns placing their chips on fields previously claimed by themselves, starting in odd rounds\nwith `Player A` and in even\nrounds with `Player B`.\n\nThe following prompt should be printed every time a player is asked to input a command in this phase:\n\n```\nPlayer \u003cPLAYER_ID\u003e, you have \u003cCHIPS\u003e chip(s) left, where and how do you want to place your chips?\\n\n \u003e \n```\n\nwhere\n\n- `\u003cPLAYER_ID\u003e` should be replaced by the player id\n- `\u003cCHIPS\u003e` should be replaced by the amount of unplaced chips left for that player.\n\nThe players can use one additional command in the `Placement Phase`:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand place\u003c/h5\u003e\u003c/summary\u003e\n\nThe players can place their chips on claimed fields (meaning fields that already have some of their own chips on them)\nwith the `place` command.\n\nSyntax: `place \u003cAMOUNT\u003e \u003cFIELD_COLUMN\u003e \u003cFIELD_ROW\u003e`\n\nwhere\n\n- `\u003cAMOUNT\u003e` is the amount of chips the player wants to place\n- `\u003cFIELD_COLUMN\u003e` is the column coordinate of the field where the player wants to place the chips\n- `\u003cFIELD_ROW\u003e` is the row coordinate of the field where the player wants to place the chips\n\nIf the command was successful the amount of chips specified should be added to the selected field, the\ncurrent player's turn ends and the map should be printed. If the map output is deactivated, nothing should be printed.\nThen the other player's turn starts, or the `Placement Phase` ends if both players are finished in this phase.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n- The command cannot be used in this phase\n- The supplied amount is invalid. Must be an integer and \u003e 0\n- The supplied amount is invalid. Must be an integer and \u003c= amount of available chips\n- The supplied field is invalid, out of range or not claimed by the executing player\n\n\u003c/details\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eMovement Phase\u003c/h4\u003e\u003c/summary\u003e\n\nIn this phase the players can move their chips between adjacent fields and/or try to claim additional fields for\nthemselves. This phase continues until both players have passed. Afterwards the next round starts or the game ends if\nno more rounds are left.\n\nFirst print the following header:\n\n```\n------------------\\n\nMovement Phase\\n\n------------------\\n\n\u003cMAP\u003e\n```\n\nwhere\n\n- `\u003cMAP\u003e` should be replaced by the current status of the map (see Map Output). If the map output is\n  deactivated, the header should be printed without the map.\n\nThen the players take turns, starting in odd rounds with `Player B` and in even rounds with `Player A`.\nThis is the exact opposite as in the `Placement Phase`!\n\nThe following prompt should be printed every time a player is asked to input a command in this phase:\n\n```\nPlayer \u003cPLAYER_ID\u003e, what do you want to do?\\n\n \u003e \n```\n\nwhere\n\n- `\u003cPLAYER_ID\u003e` should be replaced by the player id\n\nThe players can use one extra command in the `Movement Phase`:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eCommand move\u003c/h5\u003e\u003c/summary\u003e\n\nWith the command `move` the players can move a specific amount of chips from one field to another one.\n\nSyntax: `move \u003cAMOUNT\u003e \u003cFROM_FIELD_COLUMN\u003e \u003cFROM_FIELD_ROW\u003e \u003cTO_FIELD_COLUMN\u003e \u003cTO_FIELD_ROW\u003e`\n\nwhere\n\n- `\u003cAMOUNT\u003e` is the amount of chips the player wants to move (valid numbers can be between inclusive 1 and inclusive the number of chips on the origin field)\n- `\u003cFROM_FIELD_COLUMN\u003e` is the column coordinate of the origin field\n- `\u003cFROM_FIELD_ROW\u003e` is the row coordinate of the origin field\n- `\u003cTO_FIELD_COLUMN\u003e` is the column coordinate of the destination field\n- `\u003cTO_FIELD_ROW\u003e` is the row coordinate of the destination field\n\nChips can only move to directly adjacent fields (including diagonals), so the up to 8 fields around the origin field.\nThere is no movement allowed outside the map borders.\n\nIf the destination field is unclaimed, the executing player will claim the destination field and the selected\namount of chips will be removed from the origin field and added to the destination field.\n\nIf the destination field is claimed by the executing player, the selected amount of chips will be\nremoved from the origin field and added to the destination field.\n\nIf the destination field is claimed by the other player, the following formula should be used to calculate the new\namount of chips on that field: \n\n`\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e = \u003cDESTINATION_FIELD_AMOUNT\u003e + 1 - \u003cCHIPS_TO_BE_MOVED\u003e`  \n\n- If the `\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e` is zero the field will become unclaimed.   \n- If the `\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e` is a negative number the field will be claimed by the executing player and\nthe chip amount on that field should be `\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e * (-1)`.\n- If the `\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e` is a positive number the field stays claimed by the other player and the chip\namount on that field should be `\u003cNEW_DESTINATION_FIELD_AMOUNT\u003e`.\n\nIf the command was successful the turn for the current player ends and the map should be printed. If the map output is\ndeactivated, nothing should be printed.\nIf either player now has zero claimed fields the game should go into the end phase (see End Phase).\nOtherwise the next round starts.\n\n**Error Handling**  \nThe following errors must be handled (see [Return Values and Error Messages](#return-values-and-error-messages)):\n- The command was called with too many or too few parameters\n- The command cannot be used in this phase\n- The supplied amount is invalid. Must be an integer and \u003e 0\n- The supplied origin field is invalid, out of bounds or not claimed by the executing player\n- The supplied amount is invalid. Must be an integer and \u003c= chips on origin field\n- The supplied destination field is invalid, out of bounds, out of range or is a water field\n\n\u003c/details\u003e\n\u003c/details\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eEnd Phase\u003c/h3\u003e\u003c/summary\u003e\n\nThe game ends if no more rounds are left at the end of a `Movement Phase`, or immediately if a player does not have any\nclaimed fields left.\n\nFirst print the following header:\n\n```\n------------------\\n\nGAME END!\\n\n\\n\n```\n\nAfter that the following information message should be printed first for `Player A` and then for `Player B`:\n\n```\nPlayer \u003cPLAYER_ID\u003e claimed \u003cNUMBER_OF_CLAIMED_FIELDS\u003e field(s)!\\n\n```\n\nwhere\n\n- `\u003cPLAYER_ID\u003e` should be replaced by the player id\n- `\u003cNUMBER_OF_CLAIMED_FIELDS\u003e` should be replaced by the number of fields currently claimed by that player\n\nThe player with the most claimed fields wins the game and should be congratulated with the message:\n\n```\n\\n\nCongratulations, Player \u003cPLAYER_ID\u003e! You won!\\n\n```\n\nwhere\n\n- `\u003cPLAYER_ID\u003e` should be replaced by the player id.\n\nIf there is a tie no congratulations message should be printed.\n\nAfter that the program should end with the return value `0`.\n\n\u003c/details\u003e\n\n## Return Values and Error Messages\n\nThe program has to react to errors during the game and print the corresponding error messages and/or return the correct\nreturn values. You can find all error messages that should be printed and all return values in the table below.\n\nOnly one error should be printed at once. If multiple errors occur at the same time,\nonly the highest message in the below table should be printed.\n\n| Return Value | Error Message                                                              | Meaning                                                                                    | Program Phase               |\n|--------------|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|-----------------------------|\n| 0            | -                                                                          | The program terminated successfully                                                        | -                           |\n| 1            | `[ERROR] Wrong number of parameters!\\n`                                    | The wrong number of command line parameters was entered                                    | Starting the Game           |\n| 2            | `[ERROR] Invalid maximum round number!\\n`                                  | The entered maximum round number is invalid                                                | Starting the Game           |\n| 3            | `[ERROR] Invalid file!\\n`                                                  | The config file could not be opened or is invalid                                          | Starting the Game           |\n|              | `[ERROR] Entered command not found!\\n`                                     | The entered command was not found                                                          | All Commands                |\n|              | `[ERROR] Wrong number of parameters for this command!\\n`                   | The wrong number of parameters was entered for the specific command                        | All Commands                |\n|              | `[ERROR] Entered command is not valid in this phase!\\n`                    | The entered command cannot be used in this phase                                           | Command place, Command move |\n|              | `[ERROR] Invalid amount! Must be a number \u003e 0!\\n`                          | The supplied amount is invalid. Must be an integer and \u003e 0                                 | Command place, Command move |\n|              | `[ERROR] Invalid amount! Must be a number \u003c= chips in player inventory!\\n` | The supplied amount is invalid. Must be an integer and \u003c= amount of available chips        | Command place               |\n|              | `[ERROR] Invalid field!\\n`                                                 | The supplied field is invalid, out of range or not claimed by the executing player         | Command place               |\n|              | `[ERROR] Invalid origin!\\n`                                                | The supplied origin field is invalid, out of bounds or not claimed by the executing player | Command move                |\n|              | `[ERROR] Invalid amount! Must be a number \u003c= chips on origin field!\\n`     | The supplied amount is invalid. Must be an integer and \u003c= chips on origin field            | Command move                |\n|              | `[ERROR] Invalid destination!\\n`                                           | The supplied destination field is invalid, out of bounds, out of range or is a water field | Command move                |\n\n\n## Example Outputs\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eExample Output 1\u003c/h3\u003e\u003c/summary\u003e\n\nThe following example output was created using `./a1 2 configs/config_01.txt` to start the program.\n\n```\nWelcome to OOPtimal Tactics!\nPlaying maximum of 2 round(s)!\n\n------------------\nRound 1/2 starts!\n------------------\n\n------------------\nPlacement Phase\n------------------\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 1|B 1|B 1\n\nPlayer A, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e place 1 1 1\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 1|B 1|B 1\n\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e place 1 2 5\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 2|B 1|B 1\n\n------------------\nMovement Phase\n------------------\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 2|B 1|B 1\n\nPlayer B, what do you want to do?\n \u003e move 1 2 5 1 5\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 1|B 1|B 1|B 1\n\nPlayer A, what do you want to do?\n \u003e move 1 1 1 1 2\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |A 1|   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 1|B 1|B 1|B 1\n\nPlayer B, what do you want to do?\n \u003e pass\nPlayer A, what do you want to do?\n \u003e pass\n\n------------------\nRound 2/2 starts!\n------------------\n\n------------------\nPlacement Phase\n------------------\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |A 1|   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 1|B 1|B 1|B 1\n\nPlayer B, you have 2 chip(s) left, where and how do you want to place your chips?\n \u003e place 2 1 5\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |A 1|   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 3|B 1|B 1|B 1\n\nPlayer A, you have 2 chip(s) left, where and how do you want to place your chips?\n \u003e place 2 1 2\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |A 3|   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 3|B 1|B 1|B 1\n\n------------------\nMovement Phase\n------------------\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |A 3|   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |B 3|B 1|B 1|B 1\n\nPlayer A, what do you want to do?\n \u003e help\n[ERROR] Entered command not found!\nPlayer A, what do you want to do?\n \u003e pass\nPlayer B, what do you want to do?\n \u003e pass\n------------------\nGAME END!\n\nPlayer A claimed 4 field(s)!\nPlayer B claimed 4 field(s)!\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eExample Output 2\u003c/h3\u003e\u003c/summary\u003e\n\nThe following example output was created using `./a1 1 configs/config_01.txt` to start the program.\n\n```\nWelcome to OOPtimal Tactics!\nPlaying maximum of 1 round(s)!\n\n------------------\nRound 1/1 starts!\n------------------\n\n------------------\nPlacement Phase\n------------------\n  | 1 | 2 | 3 | 4 \n1 |A 1|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 1|B 1|B 1\n\nPlayer A, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e place 1 1 1\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 1|B 1|B 1\n\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e what\n[ERROR] Entered command not found!\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e info\nPlayer B:\nYou have 1 chip(s) saved!\nYou own 3 field(s)!\n\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e map\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e info\nPlayer B:\nYou have 1 chip(s) saved!\nYou own 3 field(s)!\n\nPlayer B, you have 1 chip(s) left, where and how do you want to place your chips?\n \u003e place 1 2 5\n------------------\nMovement Phase\n------------------\nPlayer B, what do you want to do?\n \u003e map\n  | 1 | 2 | 3 | 4 \n1 |A 2|A 1|A 1|   \n2 |   |   |   |   \n3 |   |   | ~ | ~ \n4 |   |   | ~ | ~ \n5 |   |B 2|B 1|B 1\n\nPlayer B, what do you want to do?\n \u003e quit\n```\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenji377%2Ftug-oop1-01","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenji377%2Ftug-oop1-01","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenji377%2Ftug-oop1-01/lists"}