~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/special/attack/attacks.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:
61
61
    {
62
62
        $attacker_level = 1;
63
63
        $attacker_record = getRecord($attacker->log);
64
 
        if (isset($attacker_record) && !is_null($attacker_record) && $attacker_record instanceof Record)
 
64
        if (isset($attacker_record) && $attacker_record instanceof Record)
65
65
            $attacker_level = $attacker_record->experience->level;
66
66
 
67
67
        $p_factor = 1;
81
81
    {
82
82
        foreach (Attack::$attacks as $attack)
83
83
        {
84
 
            if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
 
84
            if (isset($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
85
85
                return true;
86
86
        }
87
87
    }
95
95
    {
96
96
        foreach (Attack::$attacks as $attack)
97
97
        {
98
 
            if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
 
98
            if (isset($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
99
99
                return $attack;
100
100
        }
101
101
    }
110
110
    {
111
111
        foreach (Base::$base->PLAYERS as $p)
112
112
        {
113
 
            if (isset($p) && !is_null($p) && $p instanceof Player && $p->human && isset($p->cycle) && !is_null($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
 
113
            if (isset($p) && $p instanceof Player && $p->human && isset($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
114
114
            {
115
115
                $record = getRecord($p->log);
116
 
                if (isset($record) && !is_null($record) && $record instanceof Record && (count($record->bag->attacks) > 0))
 
116
                if (isset($record) && $record instanceof Record && (count($record->bag->attacks) > 0))
117
117
                    $record->bag->attackTimestep($p, $time);
118
118
            }
119
119
        }
126
126
    {
127
127
        foreach (Base::$base->PLAYERS as $p)
128
128
        {
129
 
            if (isset($p) && !is_null($p) && $p instanceof Player && $p->human && isset($p->cycle) && !is_null($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
 
129
            if (isset($p) && $p instanceof Player && $p->human && isset($p->cycle) && $p->cycle instanceof Cycle && $p->cycle->alive)
130
130
            {
131
131
                $record = getRecord($p->log);
132
 
                if (isset($record) && !is_null($record) && $record instanceof Record && (count($record->bag->attacks) > 0))
 
132
                if (isset($record) && $record instanceof Record && (count($record->bag->attacks) > 0))
133
133
                    $record->bag->ResetAttackTimers();
134
134
            }
135
135
        }
147
147
 
148
148
    $attack_name = BridgePieces(5, " ");
149
149
 
150
 
    if ((isset($player->cycle) && !is_null($player->cycle) && $player->cycle instanceof Cycle) && $player->cycle->alive && (Filter($attack_name) != "") && !Base::$base->roundFinished)
 
150
    if ((isset($player->cycle) && $player->cycle instanceof Cycle) && $player->cycle->alive && (Filter($attack_name) != "") && !Base::$base->roundFinished)
151
151
    {
152
152
        $record = getRecord($player->log);
153
 
        if (isset($record) && !is_null($record) && $record instanceof Record)
 
153
        if (isset($record) && $record instanceof Record)
154
154
        {
155
155
            if ($record->bag->attackExists($attack_name))
156
156
            {
157
157
                $attack = $record->bag->getAttack($attack_name);
158
 
                if (isset($attack) && !is_null($attack) && $attack instanceof Attack)
 
158
                if (isset($attack) && $attack instanceof Attack)
159
159
                {
160
160
                    if ($attack->activate)
161
161
                    {
190
190
    {
191
191
        foreach (Attack::$attacks as $attack)
192
192
        {
193
 
            if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($record->experience->level == $attack->level) && !$record->bag->attackExists($attack->log))
 
193
            if (isset($attack) && $attack instanceof Attack && ($record->experience->level == $attack->level) && !$record->bag->attackExists($attack->log))
194
194
            {
195
195
                $attacks_limit = getSetting("ATTACKS_LIMIT");
196
196
                if (count($record->bag->attacks) < $attacks_limit->value)
200
200
                }
201
201
                else
202
202
                {
203
 
                    if (isset($player) && !is_null($player) && $player instanceof Player)
 
203
                    if (isset($player) && $player instanceof Player)
204
204
                        con("0xf7f700".$player." 0x77ff99wants to learn 0xaa88ff".$attack." 0x77ff99but doesn't have room to learn it.");
205
205
                }
206
206
            }
217
217
{
218
218
    foreach ($record->bag->attacks as $key => $attack)
219
219
    {
220
 
        if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($record->experience->level < $attack->level))
 
220
        if (isset($attack) && $attack instanceof Attack && ($record->experience->level < $attack->level))
221
221
        {
222
222
            $attacks[] = getAttack($attack->log);
223
223
            unset($record->bag->attacks[$key]);
235
235
    $type = $name = "";
236
236
 
237
237
    $record = getRecord($player->log);
238
 
    if (isset($record) && !is_null($record) && $record instanceof Record)
 
238
    if (isset($record) && $record instanceof Record)
239
239
    {
240
240
        if (isset(Base::$base->pieces[5]))
241
241
            $type = Filter(Base::$base->pieces[5]);
256
256
                    pm($player, "0x9999ffYour current list of available attacks:");
257
257
                    foreach ($record->bag->attacks as $attack)
258
258
                    {
259
 
                        if (isset($attack) && !is_null($attack) && $attack instanceof Attack)
 
259
                        if (isset($attack) && $attack instanceof Attack)
260
260
                        {
261
261
                            pm($player, "0xffff7f$ 0x3399ff".$attack);
262
262
                        }
267
267
                pm($player, "0xffdd88Attacks you can learn:");
268
268
                foreach (Attack::$attacks as $attack)
269
269
                {
270
 
                    if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($attack->level == $record->experience->level))
 
270
                    if (isset($attack) && $attack instanceof Attack && ($attack->level == $record->experience->level))
271
271
                    {
272
272
                        pm($player, "0xffff7f$ 0x3399ff".$attack);
273
273
                    }
314
314
                {
315
315
                    foreach ($record->bag->attacks as $id => $attack)
316
316
                    {
317
 
                        if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
 
317
                        if (isset($attack) && $attack instanceof Attack && ($attack->log == Filter($name)))
318
318
                        {
319
319
                            con("0xffdd00".$player." 0xff9999forgot 0x55ccff".$attack."!");
320
320
                            unset($record->bag->attacks[$id]);
335
335
function showPlayerAttacks(Player $player)
336
336
{
337
337
    $record = getRecord($player->log);
338
 
    if (isset($record) && !is_null($record) && $record instanceof Record)
 
338
    if (isset($record) && $record instanceof Record)
339
339
    {
340
340
        if (count($record->bag->attacks) > 0)
341
341
        {
342
342
            pm($player, "0x9999ffYour current list of available attacks:");
343
343
            foreach ($record->bag->attacks as $attack)
344
344
            {
345
 
                if (isset($attack) && !is_null($attack) && $attack instanceof Attack)
 
345
                if (isset($attack) && $attack instanceof Attack)
346
346
                {
347
347
                    pm($player, "0xffff7f$ 0x3399ff".$attack);
348
348
                }
353
353
        pm($player, "0xffdd88Attacks you can learn:");
354
354
        foreach (Attack::$attacks as $attack)
355
355
        {
356
 
            if (isset($attack) && !is_null($attack) && $attack instanceof Attack && ($attack->level == $record->experience->level))
 
356
            if (isset($attack) && $attack instanceof Attack && ($attack->level == $record->experience->level))
357
357
            {
358
358
                pm($player, "0xffff7f$ 0x3399ff".$attack);
359
359
            }
379
379
        if (isset(Attack::$attacks[$start]))
380
380
        {
381
381
            $attack = Attack::$attacks[$start];
382
 
            if (isset($attack) && !is_null($attack) && $attack instanceof Attack)
 
382
            if (isset($attack) && $attack instanceof Attack)
383
383
            {
384
384
                pm($player, "0x66ffff= 0xffff88".$attack->level." 0xffff7f| 0x66cc66".$attack);
385
385
            }