Skip to content

Commit

Permalink
Merge branch 'main' into gh-917-deathmatch-iteration-1
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillegas98 committed Nov 15, 2024
2 parents 703ab15 + 83c3ccd commit 664702b
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 51 deletions.
31 changes: 31 additions & 0 deletions apps/arena/lib/arena/game/skill.ex
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,37 @@ defmodule Arena.Game.Skill do
put_in(game_state, [:players, entity.id], entity)
end

def do_mechanic(game_state, %{category: :projectile} = entity, %{type: "spawn_pool"} = pool_params, skill_params) do
last_id = game_state.last_id + 1

skill_direction = maybe_multiply_by_range(skill_params.skill_direction, skill_params.auto_aim?, pool_params.range)

target_position = %{
x: entity.position.x + skill_direction.x,
y: entity.position.y + skill_direction.y
}

Process.send_after(self(), {:activate_pool, last_id}, pool_params.activation_delay)

pool_params =
Map.merge(
%{
id: last_id,
position: target_position,
owner_id: entity.aditional_info.owner_id,
skill_key: entity.aditional_info.skill_key,
status: :WAITING
},
pool_params
)

pool =
Entities.new_pool(pool_params)

put_in(game_state, [:pools, last_id], pool)
|> put_in([:last_id], last_id)
end

def do_mechanic(game_state, player, %{type: "spawn_pool"} = pool_params, skill_params) do
last_id = game_state.last_id + 1

Expand Down
4 changes: 2 additions & 2 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ defmodule Arena.GameUpdater do
|> Map.put(:external_wall, Entities.new_external_wall(0, config.map.radius))
|> Map.put(:square_wall, config.map.square_wall)
|> Map.put(:zone, %{
radius: config.map.radius,
radius: config.map.radius - 5000,
should_start?: if(config.game.game_mode == :DEATHMATCH, do: false, else: config.game.zone_enabled),
started: false,
enabled: false,
Expand Down Expand Up @@ -1305,7 +1305,7 @@ defmodule Arena.GameUpdater do
game_state,
projectile,
projectile.aditional_info.on_explode_mechanics,
%{skill_direction: projectile.direction}
%{skill_direction: projectile.direction, auto_aim?: false}
)
else
game_state
Expand Down
7 changes: 6 additions & 1 deletion apps/arena/lib/arena/matchmaking/game_launcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ defmodule Arena.Matchmaking.GameLauncher do
"Bob",
"El javo",
"Alberso",
"Thomas"
"Thomas",
"Timmy",
"Pablito",
"Nicolino",
"Cangrejo",
"Mansito"
]

# API
Expand Down
7 changes: 6 additions & 1 deletion apps/arena/lib/arena/matchmaking/pair_mode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ defmodule Arena.Matchmaking.PairMode do
"Bob",
"El javo",
"Alberso",
"Thomas"
"Thomas",
"Timmy",
"Pablito",
"Nicolino",
"Cangrejo",
"Mansito"
]

# API
Expand Down
7 changes: 6 additions & 1 deletion apps/arena/lib/arena/matchmaking/quick_game_mode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ defmodule Arena.Matchmaking.QuickGameMode do
"Bob",
"El javo",
"Alberso",
"Thomas"
"Thomas",
"Timmy",
"Pablito",
"Nicolino",
"Cangrejo",
"Mansito"
]

# API
Expand Down
2 changes: 1 addition & 1 deletion apps/arena_load_test/lib/arena_load_test/socket_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule ArenaLoadTest.SocketHandler do
# This is enough for now. Will request bots from the bots app in future iterations.
# https://github.com/lambdaclass/mirra_backend/issues/410
defp get_random_active_character() do
["muflus", "h4ck", "uma", "valtimer", "kenzu", "otix", "shinko"]
["muflus", "h4ck", "uma", "valtimer", "kenzu", "otix", "shinko", "uren"]
|> Enum.random()
end

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ defmodule GameBackend.Matches.ArenaMatchResult do
|> validate_inclusion(:result, ["win", "loss", "abandon"])
## TODO: This enums should actually be read from config
## https://github.com/lambdaclass/mirra_backend/issues/601
|> validate_inclusion(:character, ["h4ck", "muflus", "uma", "valtimer", "kenzu", "otix", "shinko"])
|> validate_inclusion(:killed_by, ["h4ck", "muflus", "uma", "valtimer", "kenzu", "otix", "shinko", "zone"])
|> validate_inclusion(:character, ["h4ck", "muflus", "uma", "valtimer", "kenzu", "otix", "shinko", "uren"])
|> validate_inclusion(:killed_by, ["h4ck", "muflus", "uma", "valtimer", "kenzu", "otix", "shinko", "uren", "zone"])
|> foreign_key_constraint(:user_id)
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= if assigns[:current_user_id] do %>
<.form :let={f} for={%{}} action={~p"/"}>
<.input field={f[:character]} name="character" label="Select a Character" type="select" options={["muflus", "h4ck", "uma", "valtimer", "kenzu", "otix", "shinko"]} value=""/>
<.input field={f[:character]} name="character" label="Select a Character" type="select" options={["muflus", "h4ck", "uma", "valtimer", "kenzu", "otix", "shinko", "uren"]} value=""/>
<.input field={f[:user_id]} name="user_id" type="hidden" value={assigns[:user_id]}/>
<.button type="submit" name="game_mode" value="battle-royale">Play Battle Royal</.button>
<.button type="submit" name="game_mode" value="pair">Play Pair</.button>
Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ config :arena, ArenaWeb.Endpoint,
config :arena, Arena.Mailer, adapter: Swoosh.Adapters.Local

# Amount of clients needed to start a game
config :arena, :players_needed_in_match, 7
config :arena, :players_needed_in_match, 12
config :arena, :spawn_bots, false

################################
Expand Down
Loading

0 comments on commit 664702b

Please sign in to comment.