~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/tron/game.php

  • Committer: zodiacsohma1 at gmail
  • Date: 2014-03-02 08:09:55 UTC
  • Revision ID: zodiacsohma1@gmail.com-20140302080955-r5ot6eipfe0nlpww
Simplified all fields and code in all areas for better as they seem to repeat themselves.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    {
65
65
        foreach (Base::$base->PLAYERS as $p)
66
66
        {
67
 
            if (isset($p) && !is_null($p) && $p instanceof Player && isset($p->cycle) && !is_null($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
 
67
            if (isset($p) && $p instanceof Player && isset($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
68
68
                $p->cycle->Kill();
69
69
        }
70
70
 
196
196
    //  clear the data of the player's cycles data
197
197
    foreach (Base::$base->PLAYERS as  $p)
198
198
    {
199
 
        if (isset($p) && !is_null($p) && $p instanceof Player)
 
199
        if (isset($p) && $p instanceof Player)
200
200
            $p->ClearObject();
201
201
    }
202
202
 
239
239
{
240
240
    try
241
241
    {
242
 
        if (is_null($winner))
 
242
        if (!isset($winner))
243
243
        {
244
244
            $winners = array();
245
245
 
246
246
            foreach (Base::$base->PLAYERS as $p)
247
247
            {
248
 
                if (isset($p) && !is_null($p) && $p instanceof Player && $p->human)
 
248
                if (isset($p) && $p instanceof Player && $p->human)
249
249
                {
250
 
                    if (isset($p->cycle) && !is_null($p->cycle) && ($p->cycle instanceof Cycle) && $p->cycle->alive)
 
250
                    if (isset($p->cycle) && ($p->cycle instanceof Cycle) && $p->cycle->alive)
251
251
                    {
252
252
                        $winners[] = $p;
253
253
                    }
258
258
                $winner = $winners[0];
259
259
        }
260
260
 
261
 
        if (isset($winner) && !is_null($winner) && $winner instanceof Player)
 
261
        if (isset($winner) && $winner instanceof Player)
262
262
        {
263
263
            Base::$base->winner = $winner;
264
264
 
269
269
                centerMessage("Round Winner: ".$winner);
270
270
 
271
271
                $winner_record = getRecord($winner->log);
272
 
                if (isset($winner_record) && !is_null($winner_record) && $winner_record instanceof Record)
 
272
                if (isset($winner_record) && $winner_record instanceof Record)
273
273
                {
274
274
                    $win_gain_exp = getSetting("SCORE_EXP");
275
275
                    con("0xff99ff".$winner." 0xffff7freceived ".$win_gain_exp->value." exp for winning the round!");
289
289
function onRoundWinnerDeclared()
290
290
{
291
291
    Base::$base->winner = getTeam(Base::$base->pieces[1]);
292
 
    if (isset(Base::$base->winner) && !is_null(Base::$base->winner) && Base::$base->winner instanceof Team)
 
292
    if (isset(Base::$base->winner) && Base::$base->winner instanceof Team)
293
293
    {
294
294
        $win_gain_exp = getSetting("SCORE_EXP");
295
295
 
296
296
        if ((Base::$base->game_mode == 2) || (Base::$base->game_mode == 3))
297
297
        {
298
298
            $obj = Item::$items[rand(0, count(Item::$items) - 1)];
299
 
            if (isset($obj) && !is_null($obj) && $obj instanceof Item)
 
299
            if (isset($obj) && $obj instanceof Item)
300
300
                con("0xff99ffTeam ".Base::$base->winner." won the round 0xRESETT[ ".$win_gain_exp->value." exp, ".$obj." ]");
301
301
 
302
302
            if (count(Base::$base->winner->players) > 0)
303
303
            {
304
304
                foreach (Base::$base->winner->players as $p)
305
305
                {
306
 
                    if (isset($p) && !is_null($p) && $p instanceof Player && $p->human)
 
306
                    if (isset($p) && $p instanceof Player && $p->human)
307
307
                    {
308
308
                        $player_record = getRecord($p->log);
309
 
                        if (isset($player_record) && !is_null($player_record) && $player_record instanceof Record)
 
309
                        if (isset($player_record) && $player_record instanceof Record)
310
310
                        {
311
311
                            playerGainExp($p, $player_record, $win_gain_exp->value);
312
312
 
313
 
                            if (isset($obj) && !is_null($obj) && $obj instanceof Item)
 
313
                            if (isset($obj) && $obj instanceof Item)
314
314
                            {
315
315
                                if (!$player_record->bag->itemExists($obj))
316
316
                                {
319
319
                                else
320
320
                                {
321
321
                                    $item = $player_record->bag->getItem($obj);
322
 
                                    if (isset($item) && !is_null($item) && $item instanceof Item)
 
322
                                    if (isset($item) && $item instanceof Item)
323
323
                                    {
324
324
                                        if ($item->num < $item->max)
325
325
                                        {