~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/special/bounty.php

  • Committer: zodiacsohma1 at gmail
  • Date: 2014-03-07 04:38:51 UTC
  • Revision ID: zodiacsohma1@gmail.com-20140307043851-227c9g2ywbko36uj
Adjusted the bounty assignment to only AIs when one human is active on the grid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
{
23
23
    try
24
24
    {
 
25
        //  don't do it if only ais are active on grid
 
26
        if ((Base::$base->ai_alive >= 0) && (Base::$base->humans_alive == 0))
 
27
            return;
 
28
 
25
29
        $bounty_number = getSetting("BOUNTY_NUMBER");
26
30
        $tries = 0;
27
31
        $total_alive = Base::$base->ai_alive + Base::$base->humans_alive;
 
32
        $only_humans = true;
 
33
 
28
34
        if ($total_alive > 1)
29
35
        {
30
36
            if ($bounty_number->value <= $total_alive)
31
37
                $tries = $bounty_number->value;
32
38
            else
33
39
                $tries = 2;
 
40
 
 
41
            if ((Base::$base->humans_alive == 1) && (Base::$base->ai_alive > 0))
 
42
            {
 
43
                $only_humans = false;
 
44
            }
34
45
        }
35
46
 
36
 
        //  don't do it if only ais are active on grid
37
 
        if ((Base::$base->ai_alive >= 0) && (Base::$base->humans_alive == 0))
38
 
            return;
39
 
 
40
47
        $Cycles = array();
41
48
        if (count(Base::$base->PLAYERS) > 0)
42
49
        {
43
50
            foreach (Base::$base->PLAYERS as $p)
44
51
            {
45
 
                if (isset($p) && $p instanceof Player && isset($p->cycle) && $p->cycle instanceof Cycle)
 
52
                if (isset($p) && $p instanceof Player && ($p->human == $only_humans) && isset($p->cycle) && $p->cycle instanceof Cycle)
46
53
                {
47
54
                    $Cycles[] = $p;
48
55
                }