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

[GH-982] Square Wall Parameters in the Configurator #986

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ defmodule ConfiguratorWeb.MapConfigurationController do
|> Map.update("bushes", "", &parse_json/1)
|> Map.update("pools", "", &parse_json/1)
|> Map.update("crates", "", &parse_json/1)
|> Map.update("square_wall", "", &parse_json/1)
end

defp parse_json(""), do: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
</.modal>
<% end %>
</:col>
<:col :let={map_configuration} label="Square Wall">
<%= if is_nil(map_configuration.square_wall) do %>
<p>N/A</p>
<% else %>
<.button type="button" phx-click={show_modal("square-wall-#{map_configuration.id}")}>Show</.button>
<.modal id={"square-wall-#{map_configuration.id}"}>
<p class="whitespace-pre">
<%= embed_to_string(map_configuration.square_wall) |> Jason.encode!() |> Jason.Formatter.pretty_print() %>
</p>
</.modal>
<% end %>
</:col>
<:action :let={map_configuration}>
<.link navigate={~p"/map_configurations/#{map_configuration}"}>View</.link>
</:action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@
<.input
field={f[:version_id]}
type="select"
options={Enum.map(GameBackend.Configuration.list_versions(), fn version -> {version.name, version.id} end)}
options={
Enum.map(GameBackend.Configuration.list_versions(), fn version ->
{version.name, version.id}
end)
}
label="Version"
/> <.input field={f[:name]} type="text" label="Name" />
/>
<.input field={f[:name]} type="text" label="Name" />
<.input field={f[:radius]} type="number" label="Radius" step="any" />
<.input
field={f[:initial_positions]}
type="textarea"
label="Initial positions"
value={embed_to_string(f[:initial_positions].value)}
/>
<.input
field={f[:square_wall]}
type="textarea"
label="Square Wall"
value={embed_to_string(f[:square_wall].value) |> Jason.encode!() |> Jason.Formatter.pretty_print()}
/>
<.input field={f[:obstacles]} type="textarea" label="Obstacles" value={embed_to_string(f[:obstacles].value)} />
<.input field={f[:bushes]} type="textarea" label="Bushes" value={embed_to_string(f[:bushes].value)} />
<.input field={f[:pools]} type="textarea" label="Pools" value={embed_to_string(f[:pools].value)} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@
<% end %>
</dd>
</div>
<div class="flex gap-5 py-4 border-b-2 items-center">
<dt>Square Wall</dt>
<dd>
<%= if is_nil(@map_configuration.square_wall) do %>
<p>N/A</p>
<% else %>
<.button type="button" phx-click={show_modal("square-wall-#{@map_configuration.id}")}>Show</.button>
<.modal id={"square-wall-#{@map_configuration.id}"}>
<p class="whitespace-pre">
<%= embed_to_string(@map_configuration.square_wall) |> Jason.encode!() |> Jason.Formatter.pretty_print() %>
</p>
</.modal>
<% end %>
</dd>
</div>
</div>

<.back navigate={~p"/map_configurations"}>Back to Map Configurations</.back>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ defmodule ConfiguratorWeb.MapConfigurationControllerTest do
bushes: "",
pools: "",
crates: "",
active: true
active: true,
square_wall: ""
}
@update_attrs %{
name: "another_map",
Expand All @@ -23,7 +24,8 @@ defmodule ConfiguratorWeb.MapConfigurationControllerTest do
bushes: "",
pools: "",
crates: "",
active: false
active: false,
square_wall: nil
}
@invalid_attrs %{
name: nil,
Expand All @@ -33,7 +35,8 @@ defmodule ConfiguratorWeb.MapConfigurationControllerTest do
bushes: nil,
pools: nil,
crates: nil,
active: nil
active: nil,
square_wall: ""
}

describe "index" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ defmodule GameBackend.CurseOfMirra.MapConfiguration do
def changeset(square_wall, attrs) do
square_wall
|> cast(attrs, [:right, :left, :top, :bottom])
|> validate_required([:right, :left, :top, :bottom])
end
end

Expand Down
Loading