1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Fix increase and decrease player rank functions

This commit is contained in:
Matthew Heguy 2019-02-20 13:52:30 -05:00
parent 92dbfb0d46
commit 808c64a8e0

View File

@ -44,6 +44,7 @@ end
-- Local vars
local Public = {}
local set_player_rank
-- Global register vars
local player_ranks = {}
@ -260,7 +261,7 @@ function Public.increase_player_rank(player_name)
local new_rank_name = rank_name_lookup[new_rank]
if new_rank_name then
player_ranks[player_name] = new_rank
set_player_rank(player_name, new_rank)
return new_rank_name
else
return nil
@ -274,7 +275,7 @@ end
-- @return <boolean> <LocalisedString> success/failure, and LocalisedString of the player's rank
function Public.increase_player_rank_to(player_name, rank)
if Public.less_than(player_name, rank) then
Public.set_player_rank(player_name, rank)
set_player_rank(player_name, rank)
return true, get_rank_name(rank)
else
return false, get_player_rank_name(player_name)
@ -293,7 +294,7 @@ function Public.decrease_player_rank(player_name)
local new_rank_name = rank_name_lookup[new_rank]
if new_rank_name then
player_ranks[player_name] = new_rank
set_player_rank(player_name, new_rank)
return new_rank_name
else
return nil
@ -307,7 +308,7 @@ end
-- @return <boolean> <LocalisedString> success/failure, and LocalisedString of the player's rank
function Public.decrease_player_rank_to(player_name, rank)
if Public.greater_than(player_name, rank) then
Public.set_player_rank(player_name, rank)
set_player_rank(player_name, rank)
return true, get_rank_name(rank)
else
return false, get_player_rank_name(player_name)
@ -337,6 +338,7 @@ function Public.set_player_rank(player_name, rank)
return true
end
end
set_player_rank = Public.set_player_rank
--- Resets a player's rank to guest (or higher if a user meets the criteria for automatic rank)
-- @param player_name <string>
@ -352,10 +354,10 @@ function Public.reset_player_rank(player_name)
local rank
if player and player.valid and (player.online_time > Config.time_for_trust) then
rank = auto_trusted
Public.set_player_rank(player_name, rank)
set_player_rank(player_name, rank)
else
rank = guest_rank
Public.set_player_rank(player_name, rank)
set_player_rank(player_name, rank)
end
return true, get_rank_name(rank)
end