PHP web game learning-Xnova (ogame) source code explanation (10) _ PHP Tutorial

Source: Internet
Author: User
PHP web game learning-Xnova (ogame) source code explanation (10 ). 13. construction overview (buildings. php) from the beginning of this article, xnova's focus on the process, in fact, is a lot of functions; as for the construction of the page, we will not carefully explain the 13, build overview (buildings. php)

From this article, xnova's research focuses on the process, which is actually a large number of functions. As for the page structure, we will not explain it carefully.

Buildings. the PHP file not only deals with building metal minerals, but also includes four functions: construction, research, shipbuilding, and defense. different parameters are passed to determine which function to enter, therefore, this file is actually a navigation file. Next we will briefly explain this file.

// Update the construction queue of the current planet, more complex UpdatePlanetBatimentQueueList ($ planetrow, $ user); // process the current user's technical research handleincluiebuild ($ planetrow, $ user ); // The following is a page for entering different functions based on parameters // shipyard page case 'Fleet ': FleetBuildingPage ($ planetrow, $ user); // The study page case 'project ': researchBuildingPage ($ planetrow, $ user, $ IsWorking ['onwork'], $ IsWorking ['workon']); // defense Page case 'defence': DefensesBuildingPage ($ planetrow, $ user); // The rest is naturally the building page default: Ba TimentBuildingPage ($ planetrow, $ user); next we will look at updating the building queue function of the current planet UpdatePlanetBatimentQueueList (& $ CurrentPlanet, & $ CurrentUser) {$ RetValue = false; // determine whether a building queue exists. The field B _building_id is used to save the building queue if ($ CurrentPlanet ['B _ building_id']! = 0) {// enter the loop and start processing the queue while ($ CurrentPlanet ['B _ building_id']! = 0) {// if the current building time is less than time, handle it, field B _building: save the building expiration time if ($ CurrentPlanet ['B _ building'] <= time () {// first update the resources of the planet, then parse PlanetResourceUpdate ($ CurrentUser, $ CurrentPlanet, $ CurrentPlanet ['B _ build'], false); // process the current building and clear the current building field; there are a lot of code, in fact, it is relatively simple $ IsDone = CheckPlanetBuildingQueue ($ CurrentPlanet, $ CurrentUser); // if the previous processing is successful, here we need to process the next building in the queue, include deducting resources if ($ IsDone = true) {SetNextQueueElementOnTop ($ CurrentPlanet, $ CurrentUser) ;}} else {$ RetValue = true; break ;}} return $ RetValue ;}

Let's continue and track the CheckPlanetBuildingQueue function. this function has a lot of code, which is actually simple. I will not write comments, but I will explain the process below. First, the field B _building_id is used to parse the type of the building, the building or the time of demolition, and the end of the building. then, the level of the building is updated, upgraded or downgraded, and the maximum space and space used by the planet are updated; update the current building Time to 0 and update the current remaining building queue. It's not hard, huh, huh.

Next we will process the next building in the queue and track the SetNextQueueElementOnTop function, which is not difficult. Parse the building data from the queue first, and then determine whether construction can be performed. if construction resources can be calculated, send messages if not; finally, update the building completion time, remaining building queues and resources. It is as simple as the above process.

13th. construction overview (buildings. php) from the beginning of this article, xnova's focus on the process, in fact, is a lot of functions; as for the page structure, I will not explain it carefully...

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.