public function set_resource_class($pValue)
 {
     $pValue = Zupal_Domain_Abstract::_as($pValue, 'Game_Model_Gameresourceclasses', TRUE);
     if (!$pValue) {
         return;
     }
     $this->resource_class = $pValue;
 }
 /**
  *
  * @return <type>
  */
 public function target()
 {
     if ($target = $this->target->get_value()) {
         return Zupal_Domain_Abstract::_as($target, 'Ultimatum_Model_Ultgamegroups');
     } else {
         return NULL;
     }
 }
 /**
  * @param int | Game_Model_Gametypes  $pGame_type
  * @return array
  */
 public function options($pGame_type)
 {
     $pGame_type = Zupal_Domain_Abstract::_as($pGame_type, 'Game_Model_Gametypes', TRUE);
     $params = array('game_type' => $pGame_type);
     $classes = $this->find($params, 'rank');
     $out = array();
     foreach ($classes as $class) {
         $out[$class->identity()] = $class->title;
     }
     return $out;
 }
Exemplo n.º 4
0
 public function __construct($pGroup, $pGame = NULL)
 {
     $pGroup = Zupal_Domain_Abstract::_as($pGroup, 'Ultimatum_Model_Ultgroups');
     if ($pGame) {
         $pGame = Zupal_Domain_Abstract::_as($pGame, 'Ultimatum_Model_Ultgames');
     } else {
         $pGame = Ultimatum_Model_Ultgames::get_active();
     }
     parent::_load();
     $this->game_id->set_value($pGame->identity());
     $this->group_id->set_value($pGroup->identity());
     $this->set_label('Change size of ' . $pGroup);
 }
Exemplo n.º 5
0
 public function __construct($pg)
 {
     $pg = Zupal_Domain_Abstract::_as($pg, 'Ultimatum_Model_Ultgamegroups');
     $this->set_player_group($pg);
     $path = dirname(__FILE__) . '/GroupResize.ini';
     $options = new Zend_Config_Ini($path, 'fields');
     parent::__construct($options);
     $this->network->setValue(100 + $pg->network_size());
     $this->growth->setValue(100 + $pg->growth_size());
     $this->offense->setValue(100 + $pg->offense_size());
     $this->defense->setValue(100 + $pg->defense_size());
     $this->player_group->setValue($pg->identity());
     $this->player_group->removeDecorator('htmlTag');
     $this->player_group->removeDecorator('label');
 }
Exemplo n.º 6
0
    /**
     *
     * @return <type>
     */
    public function pendingorder($pPendingOrder)
    {
        $pPendingOrder = Zupal_Domain_Abstract::_as($pPendingOrder, 'Ultimatum_Model_Ultplayergrouporders');
        $pg = $pPendingOrder->player_group();
        $ot = $pPendingOrder->order_type();
        $type = $ot->identity();
        $target = $pPendingOrder->get_target();
        ?>
<fieldset>
    <legend>
        (ID: <?php 
        echo $pPendingOrder->identity();
        ?>
)
        <?php 
        echo $pg;
        ?>
        
    </legend>
 <?php 
        if ($type == 'resize' && $pPendingOrder->resize()) {
            echo $this->view->powerMatrix($pPendingOrder->resize());
            ?>
    <?php 
        }
        ?>
    <p><b><?php 
        echo $ot;
        ?>
</b>
        <?php 
        if ($target) {
            ?>
 to <?php 
            echo $target;
            ?>
 <?php 
        }
        ?>
        <?php 
        echo $pPendingOrder->cancel_link();
        ?>
</p>


</fieldset>
<?php 
    }
 public function group_sizes($pGroup, $pGame = NULL)
 {
     $pGroup = Zupal_Domain_Abstract::_as($pGroup, 'Ultimatum_Model_Ultgroups');
     if (!$pGroup) {
         throw new Exception(__METHOD__ . ': no group found');
     }
     if (is_null($pGame)) {
         $pGame = Ultimatum_Model_Ultgames::get_active();
     } else {
         $pGame = Zupal_Domain_Abstract::_as($pGame, 'Ultimatum_Model_Ultgames');
     }
     if (!$pGame) {
         throw new Exception(__METHOD__ . ': no game found');
     }
     $params = array('game' => $pGame->identity(), 'group_id' => $pGroup->identity());
     return $this->find($params, array('turn', 'changed_on'));
 }
 /**
  *
  * @param $pPlayer_group
  * @return void
  */
 public static function clear_orders($pPlayer_group, $pTarget = NULL)
 {
     $pPlayer_group = Zupal_Domain_Abstract::_as($pPlayer_group, 'Ultimatum_Model_Ultgamegroups', TRUE);
     $params = array('player_group' => $pPlayer_group);
     if ($pTarget) {
         $pTarget = Zupal_Domain_Abstract::_as($pTarget, 'Ultimatum_Model_Ultgroups', TRUE);
         if ($pTarget) {
             $params['target'] = $pTarget;
         }
     }
     foreach (self::getInstance()->find($params) as $order) {
         $order->cancel();
     }
 }
 public static function player_group_scan($pPlayer, $pGroup)
 {
     $player = Zupal_Domain_Abstract::_as($pPlayer, 'Ultimatum_Model_Ultplayers', TRUE);
     $group = Zupal_Domain_Abstract::_as($pGroup, 'Ultimatum_Model_Ultgroups', TRUE);
     $params = array('player' => $player, 'group_id' => $group);
     return self::getInstance()->findOne($params, 'scanned_at DESC');
 }
Exemplo n.º 10
0
 /**
  *
  * @param Game_Model_Gametypes $pType
  * @param int $pSkip_node
  * @param int $pDepth
  * @return array
  */
 protected function _tree_node($pParent, $pSkip_node = 0, $pDepth = 0)
 {
     $pParent = $pParent ? Zupal_Domain_Abstract::_as($pParent, 'Game_Model_Gametypes', TRUE) : 0;
     $params = array('based_on' => $pParent);
     if ($pSkip_node) {
         $params['id'] = array($pSkip_node, '!=');
     }
     $tops = $this->find($params);
     $tree = array('type' => $pType, 'children' => array(), 'depth' => $pDepth);
     foreach ($tops as $type) {
         $tree['children'][] = $this->_tree_node($type, $pSkip_node, $pDepth + 1);
     }
     return $tree;
 }
Exemplo n.º 11
0
 /**
  * This method is a bit more "expansive" than as_game_group
  * as it allows a game group object to autospawn if $pGreat = TRUE.
  * @param  $pGroup
  * @return Ultimatum_Model_Ultgamegroups
  */
 public function group_for_game($pGroup, $pGame = NULL, $pCreate = FALSE)
 {
     $pGroup = Zupal_Domain_Abstract::_as($pGroup, 'Ultimatum_Model_Ultgroups', TRUE);
     $pGame = $pGame ? Zupal_Domain_Abstract::_as($pGame, 'Ultimatum_Model_Ultgames', TRUE) : Ultimatum_Model_Ultgames::getInstance()->get_active_id();
     $params = array('group' => $pGroup, 'game' => $pGame);
     $gfg = $this->findOne($params);
     if (!$gfg && $pCreate) {
         $gfg = new self();
         $gfg->group = $pGroup;
         $gfg->game = $pGame;
         $gfg->save();
     }
     return $gfg;
 }
Exemplo n.º 12
0
 public function activate($pFor_user = NULL)
 {
     $game_type = $this->game_type();
     $gtid = $game_type->identity();
     if ($pFor_user) {
         $uid = Zupal_Domain_Abstract::_as($pFor_user, 'Model_Users', TRUE);
     } elseif ($user = Model_Users::current_user()) {
         $uid = $user->identity();
     } else {
         throw new Exception(__METHOD__ . ': no user present');
     }
     $params = array('game_type' => $gtid, 'user' => $uid);
     $other_player_sessions = Game_Model_Gamesessionplayers::getInstance()->find($params);
     foreach ($other_player_sessions as $other_player_session) {
         if ($other_player_session->game_session == $this->identity()) {
             $other_player_session->active = 1;
         } else {
             $other_player_session->active = 0;
         }
         $other_player_session->save();
     }
     /*
     
             $bond = new Model_Zupalbonds();
             if (!$pFor_user):
                 $pFor_user = Model_Users::current_user();
                 if (!$pFor_user):
                     throw new Exception(__METHOD__ . ': trying to bond missing user to session');
                 endif;
             endif;
     
             $bond->type = 'active';
             $bond->set_to_atom($this);
             $bond->set_from_atom($pFor_user);
             $bond->set_bond_atom($this->game_type());
     
             $params = array(
                 'from_atom' => $bond->from_atom()->get_atomic_id(),
                 'bond_atom' => $bond->to_atom()->get_atomic_id(),
                 'type' => 'active'
                 );
     
            $other_bonds = $bond->find($params);
     
            $other_bond = array_pop($other_bonds);
     
            if (count($other_bonds)):
                 foreach($other_bonds as $extra_bond):
                     $extra_bond->delete();
                 endforeach;
            endif;
     
            // find an existing bond that is a syner-G game activation for this user.
     
            if ($other_bond):
                 $other_bond->set_to_atom($this);
                 $other_bond->save();
            else:
                 $bond->save();
            endif;
     */
 }