PHP web game learning-explanation of Xnova (ogame) source code (V)

Source: Internet
Author: User
This article mainly introduces the PHP webpage game Xnova (ogame) source code to interpret the main game interface. if you need a friend, refer to section 6. the main game interface (frames. php)

The frames. php file function is used to display the game's main interface. first look at the following code:

$InLogin = false;$XNova_Host  = $_SERVER['HTTP_HOST'];$XNova_Script = $_SERVER['SCRIPT_NAME'];$Uri_Array   = explode ('/', $XNova_Script);// On vire le scriptarray_pop($Uri_Array);$XNova_URI   = implode ('/', $Uri_Array);$XNovaRootURL = "http://". $XNova_Host ."/". $XNova_URI ."/"; 

The above code is mainly to spell out the server URL, which is relatively simple; the previous variable $ InLogin will not be mentioned for the time being, so we will focus on the explanation when talking about common. php.

Then we include two files we mentioned earlier, and finally output a large HTML code. Note that two frames are constructed in the HTML code, leftmenu. php and overview. php. I will analyze them below.

7. left navigation bar (leftmenu. php)

This file is actually very simple. apart from the common code above, only the ShowLeftMenu () function is declared, and the page is output using display. The ShowLeftMenu () function is not difficult. the code is nothing more than the gettemplate template file, get the parameters set by the server, and the logon user level, and then construct the page. Note that the user Level variable $ level is displayed. when the value of $ Level is greater than 0, the administrator link is displayed. The $ level value represents the level defined in the system.mo file. 0 is a common player, 1 is a game operator, 2 is a game administrator, and 3 is an administrator.

8. overview (overview. php)

In fact, this file is the "overview" link in the left navigation bar. The main function is to display the approximate information of the current planet and user information, including the current status of other planets. The amount of code is very large, in fact it is very clear, we slowly look at the previous lines of code we skipped.

$lunarow = doquery("SELECT * FROM {{table}} WHERE 'id_owner' = '" . $planetrow['id_owner'] . "' AND 'galaxy' = '" . $planetrow['galaxy'] . "' AND 'system' = '" . $planetrow['system'] . "' AND 'lunapos' = '" . $planetrow['planet'] . "';", 'lunas', true);CheckPlanetUsedFields ($lunarow); 

This code function is used to get the current planet's moon and check the space used to repair the lunar January ball. The CheckPlanetUsedFields function is used not only to check the moon, but also to check the planet. let's continue without looking at the code.

Next is a piece of security verification. you need to enable this function in the parameter settings. you can take a look at it on your own. There are a lot of such code that I will not analyze in the future, it has little to do with the game process. The next step is a switch with two branches. one is to rename the planet (discard the planet), and the other is not to be viewed for the moment. The other default branch is the process to be performed after login, as shown below:

1. check the user's message. if there is a new message, the message link will be displayed.
2. the process of the expert system is removed by myself, so I am not planning to analyze it.
3. check whether the user has a fleet activity. If yes, construct the fleet activity information table and use the BuildFleetEventTable function to construct the table.
4. if a user has another planet, a list of other planets is constructed and the current activity of each planet is displayed.
5. display interstellar missile activity information for self-launch and attacks from other players
6. display other information, such as announcements and google ads.
7. if there is a moon, the moon information will be displayed.
8. the following are some information about the planet name, Planet space, and user ranking, which are messy.

The codes of the above processes are annotated and it is not difficult to understand. we will introduce the following code.

If ($ planetrow ['B _ build']! = 0) {UpdatePlanetBatimentQueueList ($ planetrow, $ user); if ($ planetrow ['B _ build']! = 0) {$ BuildQueue = explode (";", $ planetrow ['B _ building_id']); $ CurrBuild = explode (",", $ BuildQueue [0]); $ RestTime = $ planetrow ['B _ build']-time (); $ PlanetID = $ planetrow ['id']; $ Build = InsertBuildListScript ("overview "); $ Build. = $ lang ['tech '] [$ CurrBuild [0]. '('. ($ CurrBuild [1]). ')'; $ Build. ="

". Pretty_time ($ RestTime )."

"; $ Build. =" \ n

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.