Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor do_landfill_hidden_tile #1454

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

RedRafe
Copy link
Contributor

@RedRafe RedRafe commented Nov 23, 2024

Take 2 on the landfill handling
Tested on DO and CS

Additional unit testing for the specific function:

function set_hidden(tile)
  local tt = type(tile) == 'table'
  local tile_name = tt and tile.tile or tile
  local hidden_tile = tt and tile.hidden_tile
  if tile_name == 'landfill' and not hidden_tile then
    return true
  else
    return false
  end
end

for _, test in pairs({
  { result = false, tile = nil },
  { result = false, tile = true },
  { result = false, tile = 'grass' },
  { result = true, tile = 'landfill' },
  { result = true, tile = { tile = 'landfill' } },
  { result = false, tile = { tile = 'landfill', hidden_tile = 'grass' } },
  { result = false, tile = { tile = 'grass' } },
  { result = false, tile = { tile = 'grass', hidden_tile = 'grass' } },
}) do
  print((set_hidden(test.tile) == test.result) and 'passed' or 'failed')
end
Output:

passed
passed
passed
passed
passed
passed
passed
passed
]]

@grilledham grilledham merged commit f04b99e into Refactorio:develop Nov 23, 2024
1 check passed
@RedRafe RedRafe deleted the landfill-handling-2 branch November 26, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants