mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-07 23:02:06 +02:00
Add Diggy automatic restart (#1264)
- Added a discord role to automatically ping diggy users - Added role to role reactions on carlbot - Added diggy specific restart command
This commit is contained in:
parent
23228f22e1
commit
6f679ced7d
@ -7,6 +7,7 @@ diggy_clear_void=Clears the void in a given area but still triggers all events D
|
|||||||
restart=Restarts the map.
|
restart=Restarts the map.
|
||||||
abort=Aborts a restart.
|
abort=Aborts a restart.
|
||||||
danger_ore_restart_condition_not_met=Not enough [item=satellite] have been launched to restart the map.
|
danger_ore_restart_condition_not_met=Not enough [item=satellite] have been launched to restart the map.
|
||||||
|
diggy_restart_condition_not_met=Mine harder dwarf! You must reach Mining Productivity __1__ to start a new mining venture!
|
||||||
crash_site_restart=Restarts the crashsite scenario.
|
crash_site_restart=Restarts the crashsite scenario.
|
||||||
crash_site_restart_abort=Aborts the restart of the crashsite scenario.
|
crash_site_restart_abort=Aborts the restart of the crashsite scenario.
|
||||||
crash_site_spy=Spend coins to send a fish to spy on the enemy for a short time.
|
crash_site_spy=Spend coins to send a fish to spy on the enemy for a short time.
|
||||||
|
67
map_gen/maps/diggy/feature/restart_command.lua
Normal file
67
map_gen/maps/diggy/feature/restart_command.lua
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
local Discord = require 'resources.discord'
|
||||||
|
local Server = require 'features.server'
|
||||||
|
local Core = require 'utils.core'
|
||||||
|
local Restart = require 'features.restart_command'
|
||||||
|
local Global = require 'utils.global'
|
||||||
|
local Color = require 'resources.color_presets'
|
||||||
|
|
||||||
|
local restart_difficulty
|
||||||
|
|
||||||
|
Global.register_init({},
|
||||||
|
function(tbl)
|
||||||
|
tbl.restart_difficulty = math.random(5, 15) -- mining productivity 5 costs 5k of each science (1x tech multiplier), mining productivity 15 costs 30k of each science.
|
||||||
|
end,
|
||||||
|
function(tbl)
|
||||||
|
restart_difficulty = tbl.restart_difficulty
|
||||||
|
end)
|
||||||
|
|
||||||
|
return function(config)
|
||||||
|
-- Use these on live to ping @diggy role in #map-promotion channel
|
||||||
|
local map_promotion_channel = Discord.channel_names.map_promotion
|
||||||
|
local diggy_role_mention = Discord.role_mentions.diggy
|
||||||
|
|
||||||
|
-- Use these instead if testing new restart features so as to not ping @diggy role:
|
||||||
|
--local map_promotion_channel = Discord.channel_names.bot_playground
|
||||||
|
--local diggy_role_mention = Discord.role_mentions.test
|
||||||
|
|
||||||
|
Restart.set_start_game_data({type = Restart.game_types.scenario, name = config.scenario_name or 'diggy-next'})
|
||||||
|
|
||||||
|
local function can_restart(player)
|
||||||
|
local adjusted_difficulty = restart_difficulty - 1 --because the labels in game are different from the technologies[].level. This adjusts the printed messages so it's correct for player.
|
||||||
|
if player.admin then
|
||||||
|
if game.forces.player.technologies["mining-productivity-4"].level < restart_difficulty then
|
||||||
|
player.print("Victory condition overriden. Did not reach Mining Productivity "..adjusted_difficulty,Color.fail)
|
||||||
|
else
|
||||||
|
player.print("Victory condition reached: Mining Productivity: "..adjusted_difficulty,Color.success)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if game.forces.player.technologies["mining-productivity-4"].level < restart_difficulty then
|
||||||
|
player.print({'command_description.diggy_restart_condition_not_met', adjusted_difficulty},Color.fail)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restart_callback()
|
||||||
|
local start_game_data = Restart.get_start_game_data()
|
||||||
|
local new_map_name = start_game_data.name
|
||||||
|
|
||||||
|
local time_string = Core.format_time(game.ticks_played)
|
||||||
|
|
||||||
|
local message = {
|
||||||
|
diggy_role_mention,
|
||||||
|
' **Diggy has just restarted! Previous map lasted: ',
|
||||||
|
time_string,
|
||||||
|
'!\\n',
|
||||||
|
'Next map: ',
|
||||||
|
new_map_name,
|
||||||
|
'**'
|
||||||
|
}
|
||||||
|
message = table.concat(message)
|
||||||
|
|
||||||
|
Server.to_discord_named_raw(map_promotion_channel, message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Restart.register(can_restart, restart_callback)
|
||||||
|
end
|
@ -3,8 +3,11 @@ local Config = require 'map_gen.maps.diggy.config'
|
|||||||
local ScenarioInfo = require 'features.gui.info'
|
local ScenarioInfo = require 'features.gui.info'
|
||||||
local RS = require 'map_gen.shared.redmew_surface'
|
local RS = require 'map_gen.shared.redmew_surface'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local type = type
|
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
local type = type
|
||||||
|
|
||||||
|
local restart_command = require 'map_gen.maps.diggy.feature.restart_command'
|
||||||
|
restart_command({scenario_name = 'diggy'})
|
||||||
|
|
||||||
require 'utils.table'
|
require 'utils.table'
|
||||||
require 'utils.core'
|
require 'utils.core'
|
||||||
@ -79,4 +82,5 @@ function Scenario.register()
|
|||||||
global.diggy_scenario_registered = true
|
global.diggy_scenario_registered = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return Scenario
|
return Scenario
|
||||||
|
@ -14,6 +14,7 @@ return {
|
|||||||
test = '<@&593534612051984431>',
|
test = '<@&593534612051984431>',
|
||||||
crash_site = '<@&762441731194748958>',
|
crash_site = '<@&762441731194748958>',
|
||||||
danger_ore = '<@&793231011144007730>',
|
danger_ore = '<@&793231011144007730>',
|
||||||
moderator = '<@&454192594633883658>'
|
moderator = '<@&454192594633883658>',
|
||||||
|
diggy = '<@&921476458076061718>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user