mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-12 06:11:00 +00:00
feat: new Embassy logic for demolitions and alliance quitting
This commit is contained in:
@@ -6,6 +6,12 @@ else {
|
||||
$aid = $session->alliance;
|
||||
}
|
||||
$allianceinfo = $database->getAlliance($aid);
|
||||
$isOwner = ($aid && $database->isAllianceOwner($session->uid) == $aid);
|
||||
|
||||
if ($isOwner) {
|
||||
$membersCount = $database->countAllianceMembers($aid);
|
||||
}
|
||||
|
||||
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
|
||||
include("alli_menu.tpl");
|
||||
?>
|
||||
@@ -20,9 +26,69 @@ include("alli_menu.tpl");
|
||||
<th colspan="2">Quit alliance</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr><td colspan="2" class="info">In order to quit the alliance you have to enter your password again for safety reasons.</td></tr>
|
||||
<tr><th>password:</th>
|
||||
<td><input class="pass text" type="password" name="pw" maxlength="20"></td>
|
||||
</tr></tbody></table>
|
||||
<?php
|
||||
if ($isOwner && $membersCount > 0) {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="info">
|
||||
Because you are the alliance founder, you need to select a replacement founder before you leave.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
new founder:
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
$memberlist = $database->getAllMember($aid);
|
||||
?>
|
||||
<select name="new_founder" class="name dropdown">
|
||||
<?php
|
||||
$canQuit = false;
|
||||
foreach($memberlist as $member) {
|
||||
if (($member['id'] != $session->uid) && ($database->getSingleFieldTypeCount($member['id'], 18, 3, '>=') >= 1)) {
|
||||
echo "<option value=\"".$member['id']."\">".$member['username']."</option>";
|
||||
$canQuit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$canQuit) {
|
||||
echo "<option value=\"-1\">no candidates!</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="info">
|
||||
<br />In order to quit the alliance you have to enter your password again for safety reasons.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
password:
|
||||
</th>
|
||||
<td>
|
||||
<input class="pass text" type="password" name="pw" maxlength="20">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
if (!$canQuit) {
|
||||
?>
|
||||
<span style="color: red">
|
||||
<br />
|
||||
Unfortunately, there are no members of the alliance with Embassy at level 3 or more. In this case, you will not be able
|
||||
to reassign the founder role. You can still <a href="allianz.php?s=5">kick all members</a> and quit the alliance afterwards,
|
||||
if you wish.
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<p><input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /></form></p>
|
||||
@@ -15,9 +15,13 @@ if(!empty($_REQUEST["demolish"]) && $_REQUEST["c"] == $session->mchecker) {
|
||||
if($session->access != BANNED){
|
||||
if($_REQUEST["type"] != null) {
|
||||
$type = $_REQUEST['type'];
|
||||
$database->addDemolition($village->wid,$type);
|
||||
$session->changeChecker();
|
||||
header("Location: build.php?gid=15&ty=$type&cancel=0&demolish=0");
|
||||
$demolish_permitted = $database->addDemolition($village->wid,$type);
|
||||
if ($demolish_permitted === true) {
|
||||
$session->changeChecker();
|
||||
header("Location: build.php?gid=15&ty=$type&cancel=0&demolish=0");
|
||||
} else {
|
||||
header("Location: build.php?gid=15&ty=$type&nodemolish=".$demolish_permitted);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
@@ -46,9 +50,21 @@ if($village->resarray['f'.$id] >= DEMOLISH_LEVEL_REQ) {
|
||||
}
|
||||
echo "</b>";
|
||||
} else {
|
||||
if (isset($_GET['nodemolish'])) {
|
||||
switch ($_GET['nodemolish']) {
|
||||
case 18:
|
||||
echo '<p style="color: #ff0000; text-align: left">
|
||||
Because you are the founder of your alliance, demolition of a lvl 3 Embassy cannot be started.
|
||||
You can still <a href="allianz.php?s=5">quit the alliance</a>, while selecting a new leader
|
||||
in the "quit alliance" form.
|
||||
</p>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
<form action=\"build.php?gid=15&demolish=1&cancel=0&c=".$session->mchecker."\" method=\"POST\" style=\"display:inline\">
|
||||
<select name=\"type\" class=\"dropdown\">";
|
||||
<select id=\"demolition_type\" name=\"type\" class=\"dropdown\">";
|
||||
for ($i=19; $i<=41; $i++) {
|
||||
$select=($i==$ty)? " SELECTED":"";
|
||||
if ($VillageResourceLevels['f'.$i] >= 1 && !$building->isCurrent($i) && !$building->isLoop($i)) {
|
||||
@@ -61,7 +77,34 @@ if ($village->natar==1) {
|
||||
echo "<option value=99".$select.">99. ".$building->procResType(40)." (lvl ".$VillageResourceLevels['f99'].")</option>";
|
||||
}
|
||||
}
|
||||
echo "</select><input id=\"btn_demolish\" name=\"demolish\" class=\"dynamic_img\" value=\"Demolish\" type=\"image\" src=\"img/x.gif\" alt=\"Demolish\" title=\"".DEMOLISH."\" /></form>";
|
||||
echo "</select><input id=\"btn_demolish\" name=\"demolish\" class=\"dynamic_img\" value=\"Demolish\" type=\"image\" src=\"img/x.gif\" alt=\"Demolish\" title=\"".DEMOLISH."\" onClick=\"javascript:return verify_demolition();\" /></form>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function verify_demolition() {
|
||||
dType = document.getElementById('demolition_type');
|
||||
if (dType.options[dType.selectedIndex].text.indexOf('Embassy (lvl 3)') > -1) {
|
||||
// check if we really want to demolish a lvl 3 embassy
|
||||
if (!window.confirm('WARNING!\n'
|
||||
+ 'You are about to demolish an Embassy at lvl 3!\n\n'
|
||||
+ 'If you are the founder of your alliance and this is your last Embassy and your alliance has no additional members, the alliance will be deleted.\n\n'
|
||||
+ 'Click OK to confirm or Cancel to stop.')) {
|
||||
return false;
|
||||
}
|
||||
} else if (dType.options[dType.selectedIndex].text.indexOf('Embassy (lvl 1)') > -1) {
|
||||
// check if we really want to demolish a lvl 1 embassy
|
||||
if (!window.confirm('WARNING!\n'
|
||||
+ 'You are about to demolish an Embassy at lvl 1!\n\n'
|
||||
+ 'If you are in an alliance and this is your last Embassy in game, you will automatically quit that alliance when the demolition is complete.\n\n'
|
||||
+ 'Click OK to confirm or Cancel to stop.')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
Reference in New Issue
Block a user