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-399] Deal damage over time #662

Merged
merged 34 commits into from
Jun 12, 2024
Merged

[GH-399] Deal damage over time #662

merged 34 commits into from
Jun 12, 2024

Conversation

ncontinanza
Copy link
Contributor

@ncontinanza ncontinanza commented May 28, 2024

Motivation

We need to implement the damage over time executions for effects, following the guidelines found in the design document

Closes lambdaclass/afk_gacha_game#399

Summary of changes

  • Add executions_over_time to effects
  • Process the executions over time when a skill that has one of them is casted.
  • Add a test for this new behaviour

How to test it?

Check the tests and play with the skills cooldowns, DoT duration and period to check that the behaviour is the expected one.

Checklist

  • Tested the changes locally.
  • Reviewed the changes on GitHub, line by line.
  • This change requires new documentation.
    • Documentation has been added/updated.

@ncontinanza ncontinanza marked this pull request as ready for review May 30, 2024 22:11
@lotuuu lotuuu added the autobattler AFK Gacha Autobattler game label May 31, 2024
Copy link
Contributor

@lotuuu lotuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall implementation is in line with what I had imagined, love it! Left some small code design comments and general details

apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/test/battle_test.exs Outdated Show resolved Hide resolved
apps/champions/test/battle_test.exs Outdated Show resolved Hide resolved
apps/champions/test/battle_test.exs Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
apps/champions/test/battle_test.exs Outdated Show resolved Hide resolved
apps/champions/lib/champions/battle/simulator.ex Outdated Show resolved Hide resolved
@ncontinanza ncontinanza marked this pull request as draft June 10, 2024 00:36
@ncontinanza ncontinanza marked this pull request as ready for review June 10, 2024 18:10
|> Map.put(:health, target.health - damage_after_defense)
|> update_in([:executions_over_time], fn current_executions ->
Enum.map(current_executions, fn exec ->
if exec == execution_over_time do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a really, really edge-y edge case here where this fails still. Do you think we should add an issue to revisit this later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, the case in which two units of the same character apply the same EoT to a target would be handled by this comparison because the execution over time would have different values in the caster field.

Copy link
Contributor

@lotuuu lotuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is looking fine to me! However I'm getting an error when trying to play a level:

[error] Ranch listener Gateway.Endpoint.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.1514.0> exit with reason: {%Protocol.UndefinedError{protocol: Enumerable, value: nil, description: ""}, [{Enumerable, :impl_for!, 1, [file: ~c"lib/enum.ex", line: 1]}, {Enumerable, :reduce, 3, [file: ~c"lib/enum.ex", line: 166]}, {Enum, :reduce, 3, [file: ~c"lib/enum.ex", line: 4399]}, {Champions.Battle.Simulator, :apply_tags, 4, [file: ~c"lib/champions/battle/simulator.ex", line: 968]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: ~c"lib/enum.ex", line: 2528]}, {Champions.Battle.Simulator, :"-process_step_for_effects/1-fun-0-", 4, [file: ~c"lib/champions/battle/simulator.ex", line: 592]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: ~c"lib/enum.ex", line: 2528]}, {Champions.Battle.Simulator, :"-process_step_for_effects/1-fun-2-", 2, [file: ~c"lib/champions/battle/simulator.ex", line: 588]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: ~c"lib/enum.ex", line: 2528]}, {Champions.Battle.Simulator, :process_step_for_effects, 1, [file: ~c"lib/champions/battle/simulator.ex", line: 579]}, {Champions.Battle.Simulator, :"-simulate_battle/3-fun-0-", 3, [file: ~c"lib/champions/battle/simulator.ex", line: 193]}, {Enumerable.Range, :reduce, 5, [file: ~c"lib/range.ex", line: 538]}, {Enum, :reduce_while, 3, [file: ~c"lib/enum.ex", line: 2582]}, {Champions.Battle.Simulator, :simulate_battle, 3, [file: ~c"lib/champions/battle/simulator.ex", line: 184]}, {Champions.Battle, :run_battle, 3, [file: ~c"lib/champions/battle.ex", line: 61]}, {Ecto.Multi, :apply_operation, 5, [file: ~c"lib/ecto/multi.ex", line: 883]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: ~c"lib/enum.ex", line: 2528]}, {Ecto.Multi, :"-apply_operations/5-fun-1-", 5, [file: ~c"lib/ecto/multi.ex", line: 856]}, {Ecto.Adapters.SQL, :"-checkout_or_transaction/4-fun-0-", 3, [file: ~c"lib/ecto/adapters/sql.ex", line: 1358]}, {DBConnection, :run_transaction, 4, [file: ~c"lib/db_connection.ex", line: 1710]}]}

This is the battle:
Screenshot 2024-06-10 at 3 44 30 PM

lotuuu
lotuuu previously approved these changes Jun 11, 2024
Copy link
Contributor

@agustinesco agustinesco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lotuuu lotuuu merged commit c6f03e5 into main Jun 12, 2024
1 check passed
@lotuuu lotuuu deleted the gh-399-deal-damage-over-time branch June 12, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autobattler AFK Gacha Autobattler game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Executions] DealDamageOverTime
3 participants