Pipe Placement Logic
The Game space
In our i10 Pipe game, two players will share a same game space but each has their own pipe system. Therefore, it is important to maintain the consistency in the Pipe system. So that pipe of each player can’t be connected to the other.The implementation There are two steps in the pipe placement checking. Pre-condition:
- For each cube that player can place a pipe, the program will check what kind of pipe can be placed in. The check is done by getting the information about which face of the cube is available for a pipe connection. A face is considered available if it is not connected to any pipe in current cube and it is not a connection in the neighbour cube.
- Once the available faces are determined, possible pipe is considered as following:
- Closed pipe is always an option
- If the opposite face of the connection is available, straight, flexi, reservoir are the options
- If any of the face that is perpendicular with the connection is available, the curved pipe is the option
- If the opposite face and any of the perpendicular face are available, the three-way pipe is the option
- Final condition: After selecting the pipe, the user will perform the transformation to connect his new pipe to the current pipe system. Again at this step, we need to check if the pipe is correctly placed. The pipe is accepted only if it does not share the any connecting face with any other pipe and it does not connect with the other player’s pipe system.