/** * This function delegates the task at issue to the respective function. */ function takeover_main($caveID, $meineHoehlen) { global $params; // initialize return value $result = ''; // get current task $task = $params->POST->task; switch ($task) { // show main page default: $result = takeover_show($caveID, $meineHoehlen); break; // show change confirmation page // show change confirmation page case 'confirm_change': $result = takeover_confirmChange($caveID, $meineHoehlen); break; // change cave page // change cave page case 'change': $result = takeover_change($caveID, $meineHoehlen); break; // show withdrawal confirmation page // show withdrawal confirmation page case 'confirm_withdrawal': $result = takeover_confirmWithdrawal($caveID, $meineHoehlen); break; // withdrawal page // withdrawal page case 'withdrawal': $result = takeover_withdrawal($caveID, $meineHoehlen); break; } return $result; }
/** * This function delegates the task at issue to the respective function. */ function takeover_main($caveID, $ownCaves) { global $template; // open template $template->setFile('takeover.tmpl'); $feedback = ''; $action = Request::getVar('action', ''); switch ($action) { case 'withdrawal': if (!Request::isPost('postConfirm')) { break; } if (Request::isPost('postConfirm')) { $feedback = takeover_withdrawal(); break; } break; case 'change': if (Request::isPost('abort_change')) { break; } $bidding = takeover_getBidding(); $xCoord = Request::getVar('xCoord', 0); $yCoord = Request::getVar('yCoord', 0); $currentYCoord = isset($bidding['yCoord']) ? $bidding['yCoord'] : 0; $currentXCoord = isset($bidding['xCoord']) ? $bidding['xCoord'] : 0; // only one ordinate if ($xCoord == 0 || $yCoord == 0) { $feedback = array('type' => 'error', 'message' => _('Zum Wechseln mußt du sowohl die x- als auch die y-Koordinate angeben.')); break; // already bidding on this cave } else { if ($currentXCoord == $xCoord && $currentYCoord == $yCoord) { $feedback = array('type' => 'error', 'message' => _('Du bietest bereits für diese Höhle.')); break; } } if (Request::isPost('postConfirm')) { $feedback = takeover_change($xCoord, $yCoord); break; } // generate check value $_SESSION['change_check'] = uniqid('change_check'); $template->addVar('change_check', $_SESSION['change_check']); $template->addVar('xCoord', $xCoord); $template->addVar('yCoord', $yCoord); break; } // get params $playerID = $_SESSION['player']->playerID; $maxcaves = $_SESSION['player']->takeover_max_caves; // show feedback if (!empty($feedback)) { $template->addVar('status_msg', $feedback); } // don't show page, if maxcaves reached if (sizeof($ownCaves) >= $maxcaves) { $template->addVars(array('status_msg' => array('type' => 'info', 'message' => sprintf(_('Sie haben bereits die maximale Anzahl von %d Höhlen erreicht.'), $maxcaves)), 'show_page' => false)); // prepare page } else { $template->addVar('show_page', true); // collect resource ratings $ratings = array(); foreach ($GLOBALS['resourceTypeList'] as $resource) { if ($resource->takeoverValue) { $ratings[] = array('dbFieldName' => $resource->dbFieldName, 'name' => $resource->name, 'value' => $resource->takeoverValue); } } /**************************************************************************************************** * * Übergeben ans Template * ****************************************************************************************************/ // generate check value $_SESSION['withdrawal_check'] = uniqid('withdrawal'); $template->addVars(array('popularity' => GameConstants::TAKEOVER_MAX_POPULARITY_POINTS, 'maxcaves' => $maxcaves, 'target_x_coord' => Request::getVar('targetXCoord', 0) ? Request::getVar('targetXCoord', 0) : '', 'target_y_coord' => Request::getVar('targetYCoord', 0) ? Request::getVar('targetYCoord', 0) : '', 'resource_ratings' => $ratings, 'withdrawal_check' => $_SESSION['withdrawal_check'])); // get bidding $bidding = takeover_getBidding(count($ownCaves)); if ($bidding) { $template->addVars(array('chosen' => true, 'current_x_coord' => $bidding['xCoord'], 'current_y_Coord' => $bidding['yCoord'], 'current_name' => $bidding['caveName'], 'bidding' => $bidding)); } else { $template->addVar('chosen', false); } } }