1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-11 14:49:24 +02:00

Role adjustments

Changes:
- When crew is protected: officer becomes captain, if it joins a crew with no captain.
- If officer becomes captain, old captain gets demoted to officer, instead of member.
- When captain changes, officers don't reset anymore.
This commit is contained in:
Piratux 2023-02-24 14:02:55 +02:00
parent 5de6c541f1
commit 8d00fb5464
2 changed files with 15 additions and 2 deletions

View File

@ -396,7 +396,7 @@ function Public.join_crew(player, crewid, rejoin)
end
end
if not memory.run_is_protected then
if (not memory.run_is_protected) or Common.is_officer(player.index) then
Roles.confirm_captain_exists(player)
end

View File

@ -172,6 +172,12 @@ function Public.make_captain(player)
local global_memory = Memory.get_global_memory()
local memory = Memory.get_crew_memory()
local make_previous_captain_officer = false
local previous_captain_index = memory.playerindex_captain
if Common.is_officer(player.index) then
make_previous_captain_officer = true
end
if memory.playerindex_captain then
Public.update_privileges(game.players[memory.playerindex_captain])
end
@ -180,7 +186,14 @@ function Public.make_captain(player)
global_memory.playerindex_to_captainhood_priority[player.index] = nil
memory.captain_acceptance_timer = nil
Public.reset_officers()
if make_previous_captain_officer then
-- WARNING: don't use "make_officer()" as it checks if player is connected
memory.officers_table[previous_captain_index] = true
end
-- don't use "unmake_officer" as it prints additional messages
memory.officers_table[player.index] = nil
Public.update_privileges(player)
local force = player.force