PHP webpage game learning-Explanation of Xnova (ogame) source code (14th) _ php instance

Source: Internet
Author: User
This article mainly introduces the resource Update page of the PHP web game Xnova (ogame) Source Code. For more information, see section 17. Resource Update (PlanetResourceUpdate. php page)

The previous sections have basically explained the important functions. This chapter analyzes an important function, PlanetResourceUpdate, which is mainly used to update resources, create ships, and Defense units. The code is organized, the following is a detailed description:

1. Calculate the largest storage space of the planet, including the floating value set by the System
2. Calculate the total output and energy consumption of the three types of resources on the planet, including the addition of experts
3. If the planet is a moon, the output and energy calculated above are directly 0.
4. Calculate the time from the last resource update to the present
5. Calculate the output change caused by the energy ratio. When the energy is 0, only the basic output is used.
6. Next, determine whether the holiday is over or not. If it is not off, calculate the output during this period based on the data prepared earlier and add it to the existing resources.
7. Obtain the number of ships and defense measures that should be completed during this period. The function is HandleElementBuildingQueue.
8. Construct an SQL statement and submit it to the server. The resource update is complete.

This function is executed every time a player clicks each function.It makes players feel like resources are computed early. However, in some versions, when a player does not log on for a long time, the player's resources cannot be updated. In this case, the player's resources must be updated, the specific update method can be used at will. I use the update method for every spyware probe.

The following describes the HandleElementBuildingQueue function, which is easy to understand because the logic is not complex.
Remember:B _hangar_id is the string to be constructed, and B _hangar is the build time that was last maintained..

Note:

1. first determine whether a construction queue exists
2. The obtained time plus the remaining time
3. parse and build the queue and save it in the array for backup
4. The foreach is constructed one by one.
5. At last, if there are unfinished parts to be maintained, the next build will be returned.

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.