/** * * @return void */ public function save() { if ($this->package == 'core') { $this->enabled = 1; } parent::save(); }
/** * * @return <type> */ public function target() { if ($target = $this->target->get_value()) { return Zupal_Domain_Abstract::_as($target, 'Ultimatum_Model_Ultgamegroups'); } else { return NULL; } }
public function set_resource_class($pValue) { $pValue = Zupal_Domain_Abstract::_as($pValue, 'Game_Model_Gameresourceclasses', TRUE); if (!$pValue) { return; } $this->resource_class = $pValue; }
/** * @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; }
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); }
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'); }
/** * * @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')); }
/** * * @return <type> */ public function save() { parent::save(); $cache = Zupal_Bootstrap::$registry->cache->remove('roles'); }
/** * * @return <type> */ public function save() { parent::save(); $this->get_atomic_id(); }
/** * * @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(); } }
/** * * @param <type> * @return <type> */ public function toArray() { $out = parent::toArray(); $out['title'] = $this->title; $out['lead'] = $this->lead; $out['content'] = $this->content; return $out; }
/** * * @param <boolean $pErase */ public function delete($pErase = FALSE) { if ($pErase) { parent::delete(); } $this->status = 'deleted'; $this->active = 0; $this->save(); }
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; */ }
/** * * @return <type> */ public function save() { parent::save(); if (func_num_args() && func_get_arg(0)) { // if there is a true first paremeter skip the resort script. // should break recursion return; } if ($this->parent()) { $siblings = $this->parent()->children(); } else { $params = array('panel' => $this->panel, 'parent' => 0); $siblings = $this->find($params, 'sort_by'); } foreach ($siblings as $new_sort_by => $menu) { $menu->save(TRUE); } }
/** * * @param <type> $pMethod, $pParams * @return <type> */ public function __call($pMethod, $pParams) { if (preg_match('~^domain_(.*)~', $pMethod, $hits)) { return call_user_func_array(array($this, $hits[1]), $pParams); } return parent::__call($pMethod, $pParams); }
/** * * @param Zupal_Domain_Abstract $pItem */ public function move($pItem, $pMode, $pRank, $pData = NULL) { $id = $pItem->identity(); if (!$pItem->isSaved()) { throw new Exception(__METHOD__ . ': attempt to move unsaved ' . get_class($pItem)); } if (is_null($pData)) { $pData = $this->findAll($pRank); } $found = FALSE; $out = array(); switch ($pMode) { case self::MOVE_TOP: $out[] = $pItem; foreach ($pData as $item) { if ($pItem->identity() != $item->identity()) { $out[] = $item; } } break; case self::MOVE_UP: foreach ($pData as $item) { if ($found) { $out[] = $item; } elseif ($pItem->identity() == $item->identity()) { if (count($out)) { $prev = array_pop($out); $out[] = $item; $out[] = $prev; } else { $out[] = $item; } $found = TRUE; } else { $out[] = $item; } } break; case self::MOVE_DOWN: $just_saved = FALSE; foreach ($pData as $item) { if ($found) { $out[] = $item; if ($just_saved) { $out[] = $pItem; $just_saved = FALSE; } } elseif ($pItem->identity() == $item->identity()) { $found = TRUE; $just_saved = TRUE; } } break; case self::MOVE_BOTTOM: foreach ($pData as $item) { if ($pItem->identity() != $item->identity()) { $out[] = $item; } } $out[] = $pItem; break; default: throw new Exception(__METHOD__ . ': attempt to sort with unknown mode ' . $pMode); } foreach ($out as $k => $item) { $item->{$pRank} = $k; $item->save(); } }
/** * * @param boolean $pErase * @return void */ public function delete($pErase = FALSE) { foreach ($this->players() as $player) { $player->delete($pErase); } if ($pErase) { return parent::delete(); } $this->status = 'deleted'; $this->save(); }
/** * 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; }
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'); }
/** * * @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; }
public function delete() { $logger = Zupal_Module_Manager::getInstance()->get('people')->logger(); $logger->info('Person ' . $this->identity() . ' deleted'); $cache = Zupal_Bootstrap::$registry->cache; $cache->remove('people_data'); parent::delete(); }
/** * * @return <type> */ public function save() { $country = $this->getCountry(); if ($country && $country->identity()) { $this->country_id = $country->identity(); if ($this->getState()->identity()) { $this->state_id = $this->getState()->identity(); } elseif ($this->state) { $state = new Zupal_Places_States(); $state->set_value($this->state); $state->country = $this->country_id; $state->save(); $this->state_id = $state->identity(); } if ($this->getstate()->identity()) { $this->state_id = $this->getstate()->identity(); } } parent::save(); }