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
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8c20a5f
Add executions over time. Adapt skills.json
ncontinanza May 28, 2024
e7dc796
Add empty executions over time in skills.json and tests
ncontinanza May 28, 2024
7b7e93e
Add execution_over_time to model. Write a failing test that uses a DoT
ncontinanza May 28, 2024
100a739
WIP: process executions over time
ncontinanza May 29, 2024
8b86536
WIP: process executions over time
ncontinanza May 29, 2024
2c83739
Merge branch 'main' of github.com:lambdaclass/game_backend into gh-39…
ncontinanza May 29, 2024
3c66ab9
First working version of the DoT
ncontinanza May 30, 2024
2ed4298
Add period delay to DoT execution
ncontinanza May 30, 2024
f3e8cc6
Refactor duplicate code
ncontinanza May 30, 2024
0659b5a
Remove commented code
ncontinanza May 30, 2024
915b70c
Simplify the use of the process_execution_over_time function
ncontinanza May 30, 2024
80927e2
Simplify the use of the apply_execution_over_time function
ncontinanza May 30, 2024
e21dce7
Change period for interval. Remove period from executions over time
ncontinanza May 31, 2024
930cd8d
Format
ncontinanza May 31, 2024
8142ce9
Process executions over time after checking the ability to cast a skill
ncontinanza Jun 5, 2024
69ba52f
Use unit initial state to process executions over time
ncontinanza Jun 5, 2024
24862e8
Merge branch 'main' of github.com:lambdaclass/game_backend into gh-39…
ncontinanza Jun 5, 2024
ef92bb8
Calculate interval steps from interval when mapping the effect
ncontinanza Jun 5, 2024
38d7a97
replace function pattern matching for a case statement in process_exe…
ncontinanza Jun 5, 2024
3d12b61
Improve function naming and make it private
ncontinanza Jun 5, 2024
2a34bc7
Add explanatory comment to calculate_damage/3
ncontinanza Jun 5, 2024
8e5d064
Improve test naming
ncontinanza Jun 5, 2024
8718b8e
Improve test documentation
ncontinanza Jun 5, 2024
1def3b3
Fix required steps calculation and add assert to verify that one less…
ncontinanza Jun 5, 2024
4c02dc0
Refactor apply_deal_damage_over_time function to solve credo warning
ncontinanza Jun 5, 2024
dce506b
Merge branch 'main' of github.com:lambdaclass/game_backend into gh-39…
ncontinanza Jun 10, 2024
82416c4
Simplify new_state update
ncontinanza Jun 10, 2024
d755b7c
Replace case for if-else statement
ncontinanza Jun 10, 2024
11c3ad3
Improve test explanatory comment
ncontinanza Jun 10, 2024
a5a24ea
Use unit initial state to calculate damage
ncontinanza Jun 10, 2024
fdafe26
Use the whole execution to compare, instead of the skill_id, to preve…
ncontinanza Jun 10, 2024
4313ec6
Add function's explanatory comment above the function definition
ncontinanza Jun 10, 2024
1b4e2c3
Handle nil apply_tags case
ncontinanza Jun 10, 2024
beab235
Compare executions instead of skill ids
ncontinanza Jun 12, 2024
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
15 changes: 10 additions & 5 deletions apps/champions/lib/champions/battle/simulator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ defmodule Champions.Battle.Simulator do
# Calculate the new state of the battle after a step passes for a unit.
# Updates cooldowns, casts skills and reduces self-affecting modifier durations.
defp process_step_for_unit(unit, current_state, initial_step_state, history) do
agustinesco marked this conversation as resolved.
Show resolved Hide resolved
{unit, new_history} = process_executions_over_time(unit, history)
current_state = Map.put(current_state, :units, Map.put(current_state.units, unit.id, unit))

{new_state, new_history} =
cond do
not can_attack(unit, initial_step_state) ->
{current_state, new_history}
{current_state, history}

can_cast_ultimate_skill(unit) ->
Logger.info("Unit #{format_unit_name(unit)} casting Ultimate skill")
Expand All @@ -278,7 +277,7 @@ defmodule Champions.Battle.Simulator do

new_history =
add_to_history(
new_history,
history,
%{
caster_id: unit.id,
target_ids: [],
Expand Down Expand Up @@ -316,7 +315,7 @@ defmodule Champions.Battle.Simulator do

new_history =
add_to_history(
new_history,
history,
%{
caster_id: unit.id,
target_ids: [],
Expand All @@ -338,7 +337,7 @@ defmodule Champions.Battle.Simulator do
{new_state, new_history}

true ->
{current_state, new_history}
{current_state, history}
end

# Reduce modifier remaining timers & remove expired ones
Expand Down Expand Up @@ -366,6 +365,12 @@ defmodule Champions.Battle.Simulator do
|> put_in([:units, unit.id, :modifiers], new_modifiers)
|> put_in([:units, unit.id, :tags], new_tags)

{new_unit, new_history} = process_executions_over_time(new_state.units[unit.id], new_history)

new_state =
new_state
|> put_in([:units, unit.id], new_unit)
lotuuu marked this conversation as resolved.
Show resolved Hide resolved

{new_state, new_history}
end

Expand Down