function tribe_recalcLeader($tag, $oldLeaderID, $db) { global $governmentList; // find the new leader if (!($government = government_getGovernmentForTribe($tag, $db))) { return -1; } $det = $governmentList[$government[governmentID]][leaderDeterminationID]; switch ($det) { case 1: $newLeader = tribe_recalcLeader1($tag, $db); break; case 2: $newLeader = tribe_recalcLeader2($tag, $db); break; } if ($newLeader < 0) { return $newLeader; } // change the leader if ($newLeader == $oldLeaderID) { return 0; } if ($oldLeaderID && !tribe_unmakeLeader($oldLeaderID, $tag, $db)) { return -1; } if ($newLeader && !tribe_makeLeader($newLeader, $tag, $db)) { return -1; } if (!$newLeader) { tribe_sendTribeMessage($tag, TRIBE_MESSAGE_LEADER, "Anführerwechsel", "Ihr Clan hat momentan keinen Anführer " . "mehr"); } else { $player = getPlayerFromID($newLeader); $newLeaderName = $player ? $player[name] : $newLeader; tribe_sendTribeMessage($tag, TRIBE_MESSAGE_LEADER, "Anführerwechsel", "Der Spieler {$newLeaderName} ist soeben neuer " . "Anführer des Clans geworden."); } return $newLeader; }
function tribe_recalcLeader($tag, $oldLeaderID, $oldJuniorLeaderID, $db) { global $governmentList; // find the new leader if (!($government = government_getGovernmentForTribe($tag, $db))) { return -1; } $det = $governmentList[$government['governmentID']]['leaderDeterminationID']; switch ($det) { case 1: $newLeadership = tribe_recalcLeader1($tag, $db); break; case 2: $newLeadership = tribe_recalcLeader2($tag, $db); if ($newLeadership[0] == $oldLeaderID) { $newLeadership[1] = $oldJuniorLeaderID; } break; } if (!is_array($newLeadership)) { return $newLeadership; } //wihthout a Leader also no JuniorLeader if ($newLeadership[0] == 0) { $newLeadership[1] = 0; } // change the leader return tribe_ChangeLeader($tag, $newLeadership, $oldLeaderID, $oldJuniorLeaderID, $db); }
function tribe_recalcLeader($tag, $oldLeaderID) { // find the new leader if (!($government = government_getGovernmentForTribe($tag))) { return -1; } $det = $GLOBALS['governmentList'][$government['governmentID']]['leaderDeterminationID']; switch ($det) { case 1: $newLeadership = tribe_recalcLeader1($tag); break; case 2: $newLeadership = tribe_recalcLeader2($tag); break; } if (!is_array($newLeadership)) { return $newLeadership; } // change the leader return tribe_ChangeLeader($tag, $newLeadership, $oldLeaderID); }