~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/engine/team.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:
32
32
        {
33
33
            foreach ($this->players as $p)
34
34
            {
35
 
                if (isset($p) && !is_null($p) && $p instanceof Player)
 
35
                if (isset($p) && $p instanceof Player)
36
36
                {
37
37
                    $p->team = null;
38
38
                }
59
59
        {
60
60
            foreach ($this->players as $key => $p)
61
61
            {
62
 
                if (isset($p) && !is_null($p) && $p instanceof Player && ($p == $player))
 
62
                if (isset($p) && $p instanceof Player && ($p == $player))
63
63
                {
64
64
                    debugExecute("0xff9922Removed Player 0x00ffff".$player." 0xffdd00from 0xff9922Team 0x00ffff".$this);
65
65
 
78
78
    {
79
79
        foreach (Base::$base->TEAMS as $t)
80
80
        {
81
 
            if (isset($t) && !is_null($t) && $t instanceof Team && ($t->log == $log))
 
81
            if (isset($t) && $t instanceof Team && ($t->log == $log))
82
82
                return $t;
83
83
        }
84
84
    }
93
93
    {
94
94
        foreach (Base::$base->TEAMS as $t)
95
95
        {
96
 
            if (isset($t) && !is_null($t) && $t instanceof Team &&  ($t->log == $log))
 
96
            if (isset($t) && $t instanceof Team &&  ($t->log == $log))
97
97
                return true;
98
98
        }
99
99
    }
107
107
    {
108
108
        foreach (Base::$base->TEAMS as $key => $t)
109
109
        {
110
 
            if (isset($t) && !is_null($t) && $t instanceof Team && ($t == $team))
 
110
            if (isset($t) && $t instanceof Team && ($t == $team))
111
111
            {
112
112
                unset(Base::$base->TEAMS[$key]);
113
113
                unset($team);
141
141
    if (checkTeamExists(Base::$base->pieces[1]))
142
142
    {
143
143
        $team = getTeam(Base::$base->pieces[1]);
144
 
        if (isset($team) && !is_null($team) && $team instanceof Team)
 
144
        if (isset($team) && $team instanceof Team)
145
145
        {
146
146
            $oldLog  = $team->log;
147
147
            $oldName = $team->name;
158
158
function TeamDestroyed()
159
159
{
160
160
    $team = getTeam(Base::$base->pieces[1]);
161
 
    if (isset($team) && !is_null($team) && $team instanceof Team)
 
161
    if (isset($team) && $team instanceof Team)
162
162
    {
163
163
        debugExecute("0xff9922Destroyed Team... 0x00ffff".$team);
164
164
        removeTeam($team);
171
171
    $team   = getTeam(Base::$base->pieces[1]);
172
172
    $player = getPlayerByLog(Base::$base->pieces[2]);
173
173
 
174
 
    if ((isset($player) && !is_null($player) && $player instanceof Player) && (isset($team) && !is_null($team) && $team instanceof Team))
 
174
    if ((isset($player) && $player instanceof Player) && (isset($team) && $team instanceof Team))
175
175
    {
176
176
        //  make sure to remove team player from previous team before adding to the new one
177
 
        if (isset($player->team) && !is_null($player->team) && $player->team instanceof Team)
 
177
        if (isset($player->team) && $player->team instanceof Team)
178
178
            $player->team->removePlayer($player);
179
179
 
180
180
        $team->addPlayer($player);