这篇文章主要介绍了PHP网页游戏Xnova(ogame)源码解读的建筑页面部分,需要的朋友可以参考下
十四、建筑页面(BatimentBuildingPage.php)
现在开始解析真正的建筑页面,里面用到的函数不少,不过都不难,我们一起来看。
一开始先检查星球的已使用空间并更新,使用函数CheckPlanetUsedFields,这个函数前面讲过,实现也不难。
接下来这个是我们前面重点讲过的结构,就是判断是否输入;所以我们先跳到这段代码的后面看,但是这里有几个函数是处理一些建筑队列的。
1. SetNextQueueElementOnTop:我们讲过,处理队列中的下一个建筑
2. ShowBuildingQueue:构造当前的队列,代码虽多,但简单,,有兴趣可以自己跟踪
3. BuildingSavePlanetRecord:保存前面代码构造的建筑队列到数据库
4.BuildingSaveUserRecord:保存资源积分(事务官)到数据库
然后要构造建筑页面,我做一个文字说明,大部分UI的构造不写:
1. 判断最大队列值
2. 计算出当前星球的最大空间
3. 判断当前的建筑是否可以建造
4. 如果可以造的话,要取得建造时间、所需资源
5. 如果建造的是研究所需要判断是否在研究
最后就是把前面准备好的各项内容构造出html页面,这个看看就应该能明白。接下来讲解我们跳过的有用户输入部分代码,结构很清晰:
1. 取得用户输入的各项参数(实际是点击的)
2. 判断要建造的建筑是星球上还是月球上
3. 还有对链接合法性的判断,如果是不合法的,用户将受到惩罚(嘿嘿)
4. 然后是根据用户的操作,进入不同的队列功能
5. CancelBuildingFromQueue:取消正在建造的建筑
6. RemoveBuildingFromQueue:从队列中移除一个建筑
7. AddBuildingToQueue(true):在队列中插入一个建造建筑
8. AddBuildingToQueue(false):在队列中插入一个取消建筑
9. ResetThisFuckingCheater:惩罚用户函数,大家自己看吧
上面几个函数具体功能可以自己看,都是对队列的操作,大同小异。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.