Skip to content

Commit

Permalink
Merge branch 'main' into campaign-rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
lotuuu authored Mar 7, 2024
2 parents dbb47e1 + b1d6b71 commit 7887271
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 195 deletions.
3 changes: 1 addition & 2 deletions apps/arena/.credo.exs → .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.TagFIXME, []},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/elixir-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,21 @@ jobs:
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Elixir set up
working-directory: apps/arena/
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
- name: Credo Elixir and Clippy Rust Check
working-directory: apps/arena/
run: make lints
- name: Check Elixir Formatting
working-directory: apps/arena/
run: mix format --check-formatted
- name: Check Rust Formatting
working-directory: apps/arena/
run: cargo fmt --manifest-path native/physics/Cargo.toml --all -- --check
- name: Credo check
run: mix credo
- name: Compiles without warnings
working-directory: apps/arena/
run: mix compile --all-warnings --warnings-as-errors
- name: Run tests
working-directory: apps/arena/
run: mix test
- name: (Arena) Check Rust Formatting
working-directory: apps/arena/native/physics/
run: cargo fmt --all -- --check
- name: (Arena) Clippy Rust checks
working-directory: apps/arena/native/physics/
run: cargo clippy --all-targets -- -D warnings
3 changes: 2 additions & 1 deletion apps/arena/.formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
import_deps: [:phoenix],
subdirectories: ["priv/*/migrations"],
inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}", "priv/*/seeds.exs"]
inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}", "priv/*/seeds.exs"],
line_length: 120
]
2 changes: 1 addition & 1 deletion apps/arena/lib/arena/game/player.ex
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ defmodule Arena.Game.Player do
player =
add_action(player, action_name, skill.execution_duration_ms)
|> change_stamina(-skill.stamina_cost)
|> put_in([:direction], skill_direction)
|> put_in([:direction], skill_direction |> Utils.normalize())
|> put_in([:is_moving], false)
|> put_in([:aditional_info, :last_skill_triggered], System.monotonic_time(:millisecond))

Expand Down
14 changes: 4 additions & 10 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,7 @@ defmodule Arena.GameUpdater do
})

{game, _} =
Enum.reduce(clients, {new_game, config.map.initial_positions}, fn {client_id,
character_name,
_from_pid},
Enum.reduce(clients, {new_game, config.map.initial_positions}, fn {client_id, character_name, _from_pid},
{new_game, positions} ->
last_id = new_game.last_id + 1
{pos, positions} = get_next_position(positions)
Expand Down Expand Up @@ -613,12 +611,9 @@ defmodule Arena.GameUpdater do
%{game_state | projectiles: moved_projectiles}
end

defp resolve_players_collisions_with_power_ups(
%{players: players, power_ups: power_ups} = game_state
) do
defp resolve_players_collisions_with_power_ups(%{players: players, power_ups: power_ups} = game_state) do
{updated_players, updated_power_ups} =
Enum.reduce(players, {players, power_ups}, fn {_player_id, player},
{players_acc, power_ups_acc} ->
Enum.reduce(players, {players, power_ups}, fn {_player_id, player}, {players_acc, power_ups_acc} ->
case find_collided_power_up(player.collides_with, power_ups_acc) do
nil ->
{players_acc, power_ups_acc}
Expand Down Expand Up @@ -904,8 +899,7 @@ defmodule Arena.GameUpdater do
updated_player =
update_in(player, [:aditional_info, :power_ups], fn amount -> amount + 1 end)

{Map.put(players_acc, player.id, updated_player),
Map.put(power_ups_acc, power_up.id, updated_power_up)}
{Map.put(players_acc, player.id, updated_player), Map.put(power_ups_acc, power_up.id, updated_power_up)}
else
{players_acc, power_ups_acc}
end
Expand Down
4 changes: 4 additions & 0 deletions apps/arena/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ defmodule Arena.MixProject do
[
app: :arena,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.16",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
Loading

0 comments on commit 7887271

Please sign in to comment.