PHP Web Game Learning Xnova (ogame) Source code interpretation (11) _php Instance

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.