PHP Web Game Learning Xnova (Ogame) source Interpretation (13) _php Tutorial

Source: Internet
Author: User
16. Shipbuilding and defense (fleetbuildingpage.php and defensesbuildingpage.php pages)

First of all, the shipyard page, in fact, there is no real shipbuilding in this page, but to build the ship and the quantity to be saved to the database; The code that generates the ship is in another function. Below we begin to analyze this page, and also follow the previous idea, first explain the code that constructs the page.

First of all to determine whether the planet has a shipyard, not sure to hint.

The following uses the Loop statement, constructs each kind of ship the construction page, this code I think does not need to explain in detail.

The next step is to show the list of ships that are being manufactured, and to animate the script, which is actually false, even if it shows that the ship is built, and if it is not refreshed, it will not be in the database. Note that there are two important fields: B_HANGAR_ID holds the list of ships to be built, and B_hangar saves the time remaining after the last update, in seconds.

Using the function Elementbuildlistbox (), constructs a shipbuilding the script, the function code everybody sees, is not difficult, as long as understands the front I said two fields to be possible.

Finally output the shipyard page.

Now we go back to the front and the player enters this code by entering the number of ships to be made.

1. Obtain the ship code and quantity to be manufactured
2. Determine whether the number of manufacturing exceeds the maximum allowable value, whichever is greater
3. If the manufacturing quantity is not zero, determine whether to allow manufacturing
4. Then get the maximum value that the current resource can produce
5. Set resource consumption and time consumption
6. Final update of the planet data, including the reduction of resources and the construction of the ship's field b_hangar_id, posted code as follows:

if ($Count >= 1) {$CurrentPlanet [' metal ']-= $Ressource [' Metal ']; $CurrentPlanet [' crystal ']-= $Ressource [' Crystal '] ; $CurrentPlanet [' deuterium ']-= $Ressource [' deuterium ']; $CurrentPlanet [' b_hangar_id '].= "". $Element. ",". $Count. ";";}

The shipyard page is complete, so let's take a look at the defense page. The basic logic of this page is the same as the shipyard, which is not written here. The difference is that there are more logical constraints, listed as follows:

1. In the Construction of Defense Unit page, code 407 and 408 is the size of Defense shield, note that there can only be one
2. In the manufacturing code after the player has entered the number, code 502 and 503 are interceptor missiles and interstellar missiles, pay attention to the number of two missiles and the number of missiles in the manufacturing list
3. Also use field b_hangar_id to save

Shipbuilding and defense pages simply explained, the most important manufacturing code in another function, the next chapter analysis.

http://www.bkjia.com/PHPjc/824767.html www.bkjia.com true http://www.bkjia.com/PHPjc/824767.html techarticle 16, Shipbuilding and defense (fleetbuildingpage.php and defensesbuildingpage.php page) First said the shipyard page, in fact, this page is not really shipbuilding, just to build the boat and several ...

  • Related Article

    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.