예제 #1
0
 public function main($id, $mode)
 {
     global $cache, $user, $template, $config, $phpEx, $phpbb_admin_path, $phpbb_root_path;
     $user->add_lang(array('mods/dkp_admin', 'mods/dkp_common', 'mods/dkp_gameworld'));
     $template->assign_vars(array('BP_VERS' => $config['bbdkp_gameworld_version']));
     $this->page_title = $user->lang['WORLDPROGRESS'] . ' ' . $config['bbdkp_gameworld_version'];
     $this->game_id = request_var('displaygame', request_var('game_id', ''));
     $this->igame = new games\Game();
     $this->igame->game_id = $this->game_id;
     $this->igame->Get();
     $this->gmlink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>';
     $this->zonelink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;game_id=" . $this->game_id) . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>';
     $this->bosslink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;game_id=" . $this->game_id) . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>';
     foreach ($this->games as $id => $gamename) {
         $template->assign_block_vars('game_row', array('VALUE' => $id, 'SELECTED' => $id == $this->game_id ? ' selected="selected"' : '', 'OPTION' => $gamename));
     }
     switch ($mode) {
         case 'gameworldconfig':
             $submit = isset($_POST['submitsettings']) ? true : false;
             if ($submit) {
                 set_config('bbdkp_boss_hidenonkilled', isset($_POST['hidenewboss']) ? 1 : 0);
                 set_config('bbdkp_zone_photo', request_var('headertype', 0), 0);
                 set_config('bbdkp_zone_style', request_var('zonestyle', 0));
                 set_config('bbdkp_zone_progress', request_var('zoneprogress', 0));
                 set_config('bbdkp_boss_hidenewzone', isset($_POST['hidenewzone']) ? 1 : 0);
                 set_config('bbdkp_zone_block_show', isset($_POST['blockprogressbar']) ? 1 : 0);
                 set_config('bbdkp_portal_bossprogress', request_var('show_bosspblock', 0), true);
                 $cache->destroy('config');
                 trigger_error($user->lang['ADMIN_UPDATE_GAMEWORLD_SUCCESS'] . $this->gmlink, E_USER_NOTICE);
             }
             // display list of games
             $listgames = new \bbdkp\controller\games\Game();
             $gamelist = $listgames->listgames();
             foreach ($gamelist as $this->game_id => $game) {
                 $template->assign_block_vars('gamerow', array('ID' => $game['id'], 'NAME' => $game['name'], 'GAME_ID' => $game['game_id'], 'U_VIEW_GAME' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;" . URI_GAME . '=' . $game['game_id']), 'U_VIEW_ZONES' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;" . URI_GAME . '=' . $game['game_id']), 'U_VIEW_BOSSES' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;" . URI_GAME . '=' . $game['game_id']), 'VIEWZONES' => sprintf($user->lang['VIEWZONES'], $game['name']), 'VIEWBOSSES' => sprintf($user->lang['VIEWBOSSES'], $game['name']), 'STATUS' => $game['status']));
             }
             // display the list of zones
             $bp_styles['0'] = $user->lang['BP_STYLE_BP'];
             $bp_styles['1'] = $user->lang['BP_STYLE_BPS'];
             $bp_styles['2'] = $user->lang['BP_STYLE_RP3R'];
             foreach ($bp_styles as $value => $option) {
                 $template->assign_block_vars('style_row', array('VALUE' => $value, 'SELECTED' => $config['bbdkp_zone_style'] == $value ? ' selected="selected"' : '', 'OPTION' => $option));
             }
             $arrvals = array('GAME_ID' => $this->game_id, 'F_CONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=gameworldconfig"), 'BP_HIDENONKIBOSS' => $config['bbdkp_boss_hidenonkilled'] == 1 ? 'checked="checked"' : '', 'HEADER_SEL_SEPIA' => $config['bbdkp_zone_photo'] == 0 ? 'selected="selected"' : '', 'HEADER_SEL_BLUE' => $config['bbdkp_zone_photo'] == 1 ? 'selected="selected"' : '', 'HEADER_SEL_NONE' => $config['bbdkp_zone_photo'] == 2 ? 'selected="selected"' : '', 'BP_SHOWSB' => $config['bbdkp_zone_progress'] == 1 ? 'checked="checked"' : '', 'BP_HIDENEWZONE' => $config['bbdkp_boss_hidenewzone'] == 1 ? 'checked="checked"' : '', 'BP_BLOCKSHOWPROGRESSBAR' => $config['bbdkp_zone_block_show'] == 1 ? ' checked="checked"' : '', 'S_BP_SHOW' => true, 'SHOW_BOSS_YES_CHECKED' => $config['bbdkp_portal_bossprogress'] == '1' ? ' checked="checked"' : '', 'SHOW_BOSS_NO_CHECKED' => $config['bbdkp_portal_bossprogress'] == '0' ? ' checked="checked"' : '');
             $template->assign_vars($arrvals);
             $this->tpl_name = 'dkp/acp_gameworld';
             break;
         case 'zonebase':
             if (isset($_GET['move_up'])) {
                 $this->Zonebase_move('up');
             }
             if (isset($_GET['move_down'])) {
                 $this->Zonebase_move('down');
             }
             if (isset($_POST['bpadd'])) {
                 $this->ShowAddZonebase();
             }
             if (isset($_GET['edit'])) {
                 $this->ShowEditZonebase();
             }
             // user pressed the submit button in the add/edit zone screen
             if (isset($_POST['addnew'])) {
                 $this->AddNewZonebase();
             }
             if (isset($_POST['zoneparam'])) {
                 $this->UpdateZonebase();
             }
             // user pressed the red cross
             if (isset($_GET['delete'])) {
                 $this->DeleteZonebase();
             }
             $iZone = new games\Zone($this->game_id);
             $data = $iZone->GetAllZones();
             $numzones = count($data);
             $start = request_var('start', 0);
             $arrvals = array('GAME_ID' => $this->game_id, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $this->game_id . '/' . $this->game_id . '.png', 'GAMENAME' => $this->igame->getName(), 'ZONEBASEURL' => $this->igame->getZonebaseurl(), 'U_BACK1' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;game_id=" . $this->game_id), 'U_BACK2' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=gameworldconfig"), 'PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;game_id=" . $this->game_id), $numzones, 30, $start, true), 'PAGE_NUMBER' => on_page($numzones, 2, $start));
             $template->assign_vars($arrvals);
             $i = 0;
             $j = 0;
             foreach ($data as $row) {
                 $i += 1;
                 if ($i >= $start) {
                     $j += 1;
                     //show max 10 zones per page
                     if ($j <= 30) {
                         $template->assign_block_vars('gamezone', array('ZONE_ID' => $row['id'], 'ZONE_SEQUENCE' => $row['sequence'], 'ZONE_NAME' => $row['name'], 'ZONE_NAME_SHORT' => $row['name_short'], 'ZONE_IMAGENAME' => $row['imagename'], 'ZONE_WEBID' => $row['webid'], 'ZONE_URL' => sprintf($this->igame->getZonebaseurl(), $row['webid']), 'ZONE_SHOW' => $row['showzone'] == 1 ? 'checked="checked"' : '', 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;edit=1&amp;id={$row['id']}&amp;game_id=" . $this->game_id), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;delete=1&amp;id={$row['id']}&amp;game_id=" . $this->game_id), 'U_MOVE_UP' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;move_up=1&amp;id={$row['id']}&amp;game_id=" . $this->game_id), 'U_MOVE_DOWN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=zonebase&amp;move_down=1&amp;id={$row['id']}&amp;game_id=" . $this->game_id)));
                     }
                 }
             }
             $this->page_title = $user->lang['RP_ZONE'];
             $this->tpl_name = 'dkp/acp_gameworld_zonebase';
             break;
         case 'bossbase':
             if (isset($_POST['bpadd'])) {
                 $this->ShowAddBoss();
             }
             if (isset($_POST['addnew'])) {
                 $this->AddUpdateBoss();
             }
             if (isset($_GET['edit'])) {
                 $this->EditBoss();
             }
             if (isset($_GET['delete'])) {
                 $this->DeleteBoss();
             }
             if (isset($_POST['bpsave'])) {
                 $this->UpdateBossList();
             }
             $izone = new games\Zone($this->game_id);
             $zonelist = $izone->GetAllZones();
             $numzones = count($zonelist);
             $start = request_var('start', 0);
             $arrvals = array('GAME_ID' => $this->game_id, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $this->game_id . '/' . $this->game_id . '.png', 'GAMENAME' => $this->igame->getName(), 'BOSSBASEURL' => $this->igame->getBossbaseurl(), 'F_CONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase"), 'U_BACK1' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;game_id=" . $this->game_id), 'U_BACK2' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=gameworldconfig"), 'PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;game_id=" . $this->game_id), $numzones, 3, $start, true), 'PAGE_NUMBER' => on_page($numzones, 2, $start));
             $template->assign_vars($arrvals);
             $iboss = new games\Boss($this->game_id);
             $i = 0;
             $j = 0;
             foreach ($zonelist as $row) {
                 $i += 1;
                 if ($i >= $start) {
                     $j += 1;
                     //show max 3 zones per page
                     if ($j <= 3) {
                         $template->assign_block_vars('zone', array('ZONE_NAME' => $row['name'], 'ZONE_IMAGENAME' => $phpbb_root_path . "images/bbdkp/gameworld/" . $this->game_id . "/zones/normal/" . $row['imagename'] . ".jpg"));
                         $bossdata = $iboss->GetAllBosses($row['id']);
                         foreach ($bossdata as $row2) {
                             $template->assign_block_vars('zone.boss', array('BOSS_ID' => $row2['id'], 'BOSS_NAME' => htmlspecialchars($row2['name']), 'BOSS_NAME_SHORT' => htmlspecialchars($row2['name_short']), 'BOSS_IMAGENAME' => $row2['imagename'], 'GAME_ID' => $this->game_id, 'BOSS_WEBID' => $row2['webid'], 'BOSS_URL' => sprintf($this->igame->getBossbaseurl(), $row2['webid']), 'BOSS_URLVIEW' => $phpbb_root_path . "images/bbdkp/icons/view.gif", 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;edit=1&amp;id={$row2['id']}&amp;game_id=" . $this->game_id), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&amp;mode=bossbase&amp;delete=1&amp;id={$row2['id']}&amp;game_id=" . $this->game_id)));
                         }
                     }
                 }
             }
             $this->page_title = $user->lang['BOSSPROGRESS'];
             $this->tpl_name = 'dkp/acp_gameworld_' . $mode;
             break;
     }
 }
예제 #2
0
 public function GetAllZoneProgress($guild_id, $game_id)
 {
     global $phpbb_root_path, $config, $db, $user;
     $sql_array = array('SELECT' => 'z.id as zoneid, z.imagename,
             l.name as zonename, l.name_short as zonename_short, z.webid ', 'FROM' => array(ZONEBASE => 'z', BB_LANGUAGE => 'l'), 'WHERE' => " 1=1 AND l.attribute_id = z.id\n                    AND z.showzone = 1\n                    AND l.attribute='zone' AND l.language= '" . $config['bbdkp_lang'] . "'\n\t\t\t\t\tAND z.game= '" . $game_id . "' and z.game = l.game_id ", 'ORDER_BY' => 'z.sequence desc ');
     $bp = new BossProgress($game_id);
     $zones = array();
     $sql = $db->sql_build_query('SELECT', $sql_array);
     $result = $db->sql_query($sql);
     while ($row = $db->sql_fetchrow($result)) {
         switch ($config['bbdkp_zone_photo']) {
             case 0:
                 //sepia
                 $progrimg = $phpbb_root_path . 'images/bbdkp/gameworld/' . $game_id . '/zones/normal/' . $row['imagename'] . '.jpg';
                 $background = $phpbb_root_path . 'images/bbdkp/gameworld/' . $game_id . '/zones/photo/' . $row['imagename'] . '.jpg';
                 break;
             case 1:
                 //blackwhite
                 $progrimg = $phpbb_root_path . 'images/bbdkp/gameworld/' . $game_id . '/zones/normal/' . $row['imagename'] . '.jpg';
                 $background = $phpbb_root_path . 'images/bbdkp/gameworld/' . $game_id . '/zones/sw/' . $row['imagename'] . '.jpg';
                 break;
             case 2:
                 $progrimg = '';
                 $background = $phpbb_root_path . 'images/bbdkp/gameworld/' . $game_id . '/zones/normal/' . $row['imagename'] . '.jpg';
         }
         $gameworld = new games\Boss($game_id);
         $bossinfo = $gameworld->GetAllBosses($row['zoneid']);
         $bosses = $bp->get_bossprogress($guild_id, $row['zoneid'], $game_id);
         $bosskilled = 0;
         foreach ($bosses as $j => $boss) {
             if ($boss['bosskilled'] == "1") {
                 $bosskilled++;
             }
         }
         if (count($bossinfo) > 0) {
             $zonecomplete = $j > 0 ? round($bosskilled / count($bossinfo) * 100, 2) : 0;
         } else {
             $zonecomplete = 0;
         }
         $zonestats = $user->lang['BOSSPROGRESS'] . ' ' . $bosskilled . '/' . count($bossinfo) . ' (' . $zonecomplete . '%)';
         $zones[$row['zoneid']] = array('zoneid' => $row['zoneid'], 'zonename' => $row['zonename'], 'zonename_short' => $row['zonename_short'], 'imagename' => $row['imagename'], 'zoneimage' => $progrimg, 'zonebackground' => $background, 'zonecomplete' => $zonecomplete, 'bosses' => $bosses, 'zonestats' => $zonestats, 'zonekills' => $bosskilled, 'zonebosses' => count($bossinfo), 'webid' => $row['webid']);
     }
     return $zones;
 }