当前位置: 首页>>代码示例>>PHP>>正文


PHP data::initialize方法代码示例

本文整理汇总了PHP中data::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP data::initialize方法的具体用法?PHP data::initialize怎么用?PHP data::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data的用法示例。


在下文中一共展示了data::initialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Buildings

 function Buildings()
 {
     data::initialize();
     $this->planet_id = current_planet();
     $this->building_id = isset($_REQUEST['building_id']) ? (int) $_REQUEST['building_id'] : NULL;
     permissions_check(PERMISSION_PLANET, $this->planet_id, array('build', 'commission'));
     $this->data->updater->update(0, $this->planet_id);
     $this->quiet = false;
 }
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:9,代码来源:buildings.php

示例2: upgrade


//.........这里部分代码省略.........
     if ($attribute != mysql_real_escape_string($attribute)) {
         error(__FILE__, __LINE__, 'DATA_INVALID', 'Invalid attribute selected');
     }
     $db_query = "\n\t\t\t\tSELECT \n\t\t\t\t\t`time`, \n\t\t\t\t\t`workers`, \n\t\t\t\t\t`energy`, \n\t\t\t\t\t`minerals`, \n\t\t\t\t\t`mineralspread`, \n\t\t\t\t\t`techlevel_current`, \n\t\t\t\t\t`techlevel_max`, \n\t\t\t\t\t`" . $attribute . "_base`, \n\t\t\t\t\t`" . $attribute . "_max`, \n\t\t\t\t\t`" . $attribute . "_inc`, \n\t\t\t\t\t`" . $attribute . "_per`, \n\t\t\t\t\t`" . $attribute . "_size`, \n\t\t\t\t\t`" . $attribute . "_sizeinc`, \n\t\t\t\t\t`size_base`, \n\t\t\t\t\t`size_max` \n\t\t\t\tFROM \n\t\t\t\t\t`" . $design_name . "designs` \n\t\t\t\tWHERE \n\t\t\t\t\t`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND \n\t\t\t\t\t`" . $design_name . "design_id` = '" . $design_id . "' \n\t\t\t\tLIMIT 1";
     $db_result = mysql_query($db_query);
     if (mysql_num_rows($db_result) == 0) {
         error(__FILE__, __LINE__, 'DATA_INVALID', 'Invalid design selected');
     }
     $design = mysql_fetch_array($db_result, MYSQL_ASSOC);
     $design['mineralspread'] = unserialize($design['mineralspread']);
     if ($design['techlevel_current'] >= $design['techlevel_max']) {
         $status[] = 'The tech level has been maxed out.';
     }
     if ($design[$attribute . '_base'] == $design[$attribute . '_max']) {
         $status[] = 'That attribute has been maxed out.';
     }
     if (!empty($status)) {
         if ($output_mode == 'javascript') {
             echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;';
             exit;
         }
         $this->smarty->append('status', $status);
         $this->overview();
         exit;
     }
     $db_query = "SELECT `planet_id` FROM `tasks` WHERE `kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND `type` IN ('2', '3') AND (`planet_id` = '" . $planet_id . "' OR `design_id` = '" . $design_id . "') LIMIT 2";
     $db_result = mysql_query($db_query);
     while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) {
         if ($db_row['planet_id'] == $planet_id) {
             $status[] = 'That planet is already researching something.';
         } else {
             $status[] = 'That design is already being researched elsewhere';
         }
     }
     if (!empty($status)) {
         if ($output_mode == 'javascript') {
             echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;';
             exit;
         }
         $this->smarty->append('status', $status);
         $this->overview();
         exit;
     }
     $db_query = "SELECT `player_id`, `workers`, `energy`, `minerals`, `researchbonus` FROM `planets` WHERE `planet_id` = '" . $planet_id . "' LIMIT 1";
     $db_result = mysql_query($db_query);
     $planet = mysql_fetch_array($db_result, MYSQL_ASSOC);
     $planet['minerals'] = unserialize($planet['minerals']);
     $resources = array('workers', 'energy');
     foreach ($resources as $value) {
         $planet[$value] -= $design[$value];
         if ($planet[$value] < 0) {
             $status[] = 'Not enough ' . $value . '.';
         }
     }
     if (!empty($design['mineralspread'])) {
         $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h');
         foreach ($design['mineralspread'] as $key => $value) {
             $mineral = $value / 100 * $design['minerals'];
             $planet['minerals'][$key] -= $mineral;
             if ($planet['minerals'][$key] < 0) {
                 $status[] = 'Not enough ' . $mineralnames[$key] . '.';
             }
         }
     }
     if (!empty($status)) {
         if ($output_mode == 'javascript') {
             echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;';
             exit;
         }
         $this->smarty->append('status', $status);
         $this->overview();
         exit;
     }
     $completion = $design['time'] * $_SESSION['round_speed'] * ((100 - $planet['researchbonus']) / 100);
     $warptime = request_variable('warptime');
     if (!is_null($warptime)) {
         data::initialize();
         $data_planet =& $this->data->planet($planet_id);
         if ($data_planet['warptime_research'] > $completion) {
             $data_planet['warptime_research'] -= $completion;
             $completion = 0;
         } else {
             $completion -= $data_planet['warptime_research'];
             $data_planet['warptime_research'] = 0;
         }
         $this->data->save();
     }
     $insert_design = array('round_id' => $_SESSION['round_id'], 'kingdom_id' => $_SESSION['kingdom_id'], 'planet_id' => $planet_id, 'type' => 3, 'design_id' => $design_id, 'attribute' => $attribute, 'number' => $type, 'start' => microfloat(), 'completion' => microfloat() + $completion);
     $db_result = $this->sql->execute('tasks', $insert_design);
     $this->sql->set(array(array('planets', 'researching', 1), array('planets', 'workers', $planet['workers']), array('planets', 'energy', $planet['energy']), array('planets', 'minerals', serialize($planet['minerals']))));
     $this->sql->where(array('planets', 'planet_id', $planet_id));
     $this->sql->limit(1);
     $db_result = $this->sql->execute();
     if ($output_mode == 'javascript') {
         echo 'varUpgrading = true; varError = false;';
         exit;
     }
     $_SESSION['status'][] = 'Upgrade successfully started.';
     redirect('designs.php');
 }
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:101,代码来源:designs.php

示例3: IK_Smarty

 function IK_Smarty()
 {
     data::initialize();
 }
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:4,代码来源:ik-smarty.php

示例4: alerts

 function alerts()
 {
     data::initialize();
 }
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:4,代码来源:alerts.php

示例5: Updater_Round

 function Updater_Round()
 {
     data::initialize();
     $this->combat =& new Updater_Combat();
 }
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:5,代码来源:updater_round.php


注:本文中的data::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。