Skip to content

Commit

Permalink
Add new boolean to effects to differentiate effects inside pool only …
Browse files Browse the repository at this point in the history
…vs effects still valid outside them
  • Loading branch information
Nico-Sanchez committed Nov 1, 2024
1 parent 6d2936a commit a9038a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
14 changes: 4 additions & 10 deletions apps/arena/lib/arena/game/effect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,14 @@ defmodule Arena.Game.Effect do
cond do
Map.has_key?(game_state.players, entity_id) ->
update_in(game_state, [:players, entity_id, :aditional_info, :effects], fn current_effects ->
# TODO: here we filter "all damage" effects for toxic Shinko attacks. This needs a better handling.
Enum.reject(current_effects, fn effect ->
effect.owner_id == owner_id and
not Enum.all?(effect.effect_mechanics, fn mechanic -> mechanic.name == "damage" end)
end)
# Here we remove all effects from owner if they only apply there (pools for now).
Enum.reject(current_effects, fn effect -> effect.owner_id == owner_id and effect.disabled_outside_pool end)
end)

Map.has_key?(game_state.crates, entity_id) ->
update_in(game_state, [:crates, entity_id, :aditional_info, :effects], fn current_effects ->
# TODO: here we filter "all damage" effects for toxic Shinko attacks. This needs a better handling.
Enum.reject(current_effects, fn effect ->
effect.owner_id == owner_id and
not Enum.all?(effect.effect_mechanics, fn mechanic -> mechanic.name == "damage" end)
end)
# Here we remove all effects from owner if they only apply there (pools for now).
Enum.reject(current_effects, fn effect -> effect.owner_id == owner_id and effect.disabled_outside_pool end)
end)

true ->
Expand Down
4 changes: 4 additions & 0 deletions apps/game_backend/lib/game_backend/curse_of_mirra/effect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule GameBackend.CurseOfMirra.Effect do
:allow_multiple_effects,
:consume_projectile,
:effect_mechanics,
:disabled_outside_pool,
:name
]}
embedded_schema do
Expand All @@ -22,6 +23,7 @@ defmodule GameBackend.CurseOfMirra.Effect do
field(:one_time_application, :boolean)
field(:allow_multiple_effects, :boolean)
field(:consume_projectile, :boolean)
field(:disabled_outside_pool, :boolean)
embeds_many(:effect_mechanics, EffectMechanic)
end

Expand All @@ -33,12 +35,14 @@ defmodule GameBackend.CurseOfMirra.Effect do
:one_time_application,
:allow_multiple_effects,
:consume_projectile,
:disabled_outside_pool,
:name
])
|> validate_required([
:remove_on_action,
:one_time_application,
:allow_multiple_effects,
:disabled_outside_pool,
:name
])
|> cast_embed(:effect_mechanics)
Expand Down
14 changes: 14 additions & 0 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ singularity_effect = %{
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "pull",
Expand All @@ -262,6 +263,7 @@ denial_of_service =
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "damage",
Expand All @@ -279,6 +281,7 @@ invisible_effect =
remove_on_action: true,
one_time_application: false,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "invisible",
Expand All @@ -301,6 +304,7 @@ whirlwind_effect =
remove_on_action: false,
one_time_application: false,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "defense_change",
Expand All @@ -318,6 +322,7 @@ buff_singularity_effect =
one_time_application: true,
consume_projectile: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "buff_pool",
Expand All @@ -334,6 +339,7 @@ inferno_effect = %{
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "speed_boost",
Expand All @@ -356,6 +362,7 @@ toxic_onion_effect = %{
duration_ms: 3000,
one_time_application: false,
allow_multiple_effects: true,
disabled_outside_pool: false,
effect_mechanics: [
%{
name: "damage",
Expand All @@ -372,6 +379,7 @@ peb_effect = %{
duration_ms: 4000,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: false,
effect_mechanics: [
%{
name: "damage",
Expand Down Expand Up @@ -1221,6 +1229,7 @@ golden_clock_effect = %{
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: false,
effect_mechanics: [
%{
name: "reduce_stamina_interval",
Expand Down Expand Up @@ -1266,6 +1275,7 @@ magic_boots_effect =
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "speed_boost",
Expand Down Expand Up @@ -1295,6 +1305,7 @@ mirra_blessing_effect =
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "damage_immunity",
Expand Down Expand Up @@ -1323,6 +1334,7 @@ giant_effect =
remove_on_action: false,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: true,
effect_mechanics: [
%{
name: "modify_radius",
Expand Down Expand Up @@ -1367,6 +1379,7 @@ polymorph_effect = %{
name: "polymorph_effect",
duration_ms: 9000,
remove_on_action: true,
disabled_outside_pool: false,
one_time_application: true,
allow_multiple_effects: true,
effect_mechanics: []
Expand Down Expand Up @@ -1423,6 +1436,7 @@ _slow_field_effect = %{
remove_on_action: true,
one_time_application: true,
allow_multiple_effects: true,
disabled_outside_pool: false,
effect_mechanics: [
%{
name: "speed_boost",
Expand Down

0 comments on commit a9038a0

Please sign in to comment.