PHP Web Game Learning Xnova (ogame) Source code interpretation (10) _php instance

Source: Internet
Author: User

13. Construction Overview (buildings.php)

Starting from this article, the focus on the Xnova is on the process, which is actually a lot of functions; the structure of the page will not be explained carefully.

buildings.php documents not only deal with the construction of metal minerals, but includes construction, research, shipyards, defense four functions; by passing different parameters to decide which function to enter, so this file is actually a navigation file. Here's a brief explanation of this file.

Update the building queues of the current planet, more complex Updateplanetbatimentqueuelist ($planetrow, $user);
Handletechnologiebuild ($planetrow, $user) dealing with the current user's technology research;
Below are the parameters to enter the different function page/Shipyard page case ' fleet ': Fleetbuildingpage ($planetrow, $user);
Research page case ' study ': Researchbuildingpage ($planetrow, $user, $IsWorking [' onwork '], $IsWorking [' Workon ']);
Defense page case ' defense ': Defensesbuildingpage ($planetrow, $user); 
The remaining nature is the Architectural page default:batimentbuildingpage ($planetrow, $user); Now let's look at the building of the current planet. Function Updateplanetbatimentqueuelist (& $CurrentPlanet, & $CurrentUser) {$RetValue = False
 ; Determine if there is a building queue, field b_building_id save building Queue if ($CurrentPlanet [' b_building_id ']!= 0) {//Enter loop, start processing queue while ($CurrentPlanet [' B  _building_id ']!= 0 {//////////////////////////////////////////////////////
  {//update the resources of the planet below, and then parse the Planetresourceupdate ($CurrentUser, $CurrentPlanet, $CurrentPlanet [' b_building '], false); Dispose of the current building and empty the current construction field; The code is quite simple $IsDone = ChecKplanetbuildingqueue ($CurrentPlanet, $CurrentUser); 
  If the previous processing succeeds, the next building in the queue will be processed, including deducting the resource if ($IsDone = = True) {setnextqueueelementontop ($CurrentPlanet, $CurrentUser);
  } else {$RetValue = true;
  Break
}} return $RetValue; 

 }

We go on, tracking into the Checkplanetbuildingqueue function, this function code is very much, in fact, simple; I do not write a comment, the next process. First, the type of the building, the construction or demolition, the time of the construction, and so on, are updated from the field b_building_id, and then the grade, upgrade or demotion of the building is updated, the maximum space and space of the planet are renewed, the time of the current building is updated to 0 and the current remaining construction It's not difficult, hehe.

It is also not difficult to follow the next building in the queue to track the Setnextqueueelementontop function. First, the construction data are parsed from the queue, then the building is judged, and the construction resources can be calculated, if it is not possible to send messages, etc. As simple as the process above, take it.

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.