14. Construction page (batimentbuildingpage.php)
Now start to parse the real building page, which uses a lot of functions, but it is not difficult, we look together.
First check the planet's already used space and update, using the function Checkplanetusedfields, this function has been said before, implementation is not difficult.
So here's the structure we talked about earlier, which is to decide whether to input, so let's jump to the back of the code, but here are a few of the functions that deal with building queues.
1. Setnextqueueelementontop: We talked about dealing with the next building in the queue
2. Showbuildingqueue: Constructs the current queue, although the code is many, but is simple, has the interest to be able to track itself
3. Buildingsaveplanetrecord: Save the building queues of the previous code constructs to the database
4. Buildingsaveuserrecord: Save resource points (transaction officer) to database
Then, to construct the architectural page, I'll make a text note that most of the UI constructs are not written:
1. Determine the maximum queue value
2. Calculate the maximum space of the current planet
3. Determine whether the current building can be built
4. Build time, resource requirements, if it can be made
5. If the institute is built to determine whether the study
The last thing to do is to construct the HTML page of all the things that are prepared in front of you. Next, we skip the user input part of the code, the structure is very clear:
1. Get the user input parameters (actually clicked)
2. Judge whether the building to be built is on the planet or on the moon
3. There is also a link to the legality of the judgment, if it is illegal, the user will be punished (hehe)
4. Then according to the user's operation, enter the different queue function
5. Cancelbuildingfromqueue: Cancellation of buildings under construction
6. Removebuildingfromqueue: Removal of a building from the queue
7 Addbuildingtoqueue (TRUE): Insert a building in the queue
8 Addbuildingtoqueue (FALSE): Insert a cancel building in the queue
9. Resetthisfuckingcheater: Punish the user function, let's see for ourselves.
The function of the above several functions can see for oneself, all is the operation of the queue, very similar.