Skip to content

Commit

Permalink
Champions skills config (#438)
Browse files Browse the repository at this point in the history
* Remove targeting from skills

* Rename armor to defense

* Remove skill targetting

* Add period field to permanent skill types

* Abstract lowest-highest attribute strategies

* Add new components to effects

* Refactor execution type cast

* Require modifier fields

* Fix create_effect_map

* Refactor Execution

* Fix execution field

* Fix execution

* Update Muflus skills in seeds

* Capitalize Defense

* Remvoe wrong function

* Update doc + format

* Turn Components into a custom Ecto Type

* General fixes

* Lock ChanceToApply component between 0 and 1

* Add ChanceToApply functionality

* Refactor effect_hits?

* Add apply_effect and process_execution for type DealDamage

* Add todo comment

* Add energy regen and rename some variables for clarity

* Fix choose_targets

* Lowercase target_strategy pattern match

* Cast energy_regen

* Add missing fields to effect_map

* Add energy_regen to muflus basic skill seed

* Fix battle

* Nest units inside initial state map

* Implement skill delays

* Add effect delays

* Add energy_regen and delay to skills

* Format seeds

* Revert changes to simulator

They will be merged from a different branch

* Restore armor -> defense rename

* Add animation_duration and animation_trigger to skills

* Fix seeds

* Add skill animation delays and effect delays

* Replace inspects with logs

* Rename format function

* Uncomment character class

* Update comment

* Add helper unit name format function and logs on death

* Update moduledoc

* Update simulator module doc

* Define targets on effect cast (instead of on delay end)

* Delete unused parameter

* Add comment

* Modify log

* Implement modifiers

* Add attribute to modifiers

* Add Execution-DealDamage tests

* Add step applied for overrides

* Expand DealDamage test with cases that involve delays in the basic skill

* Implement Modifier expiration

* Add examples to Effect attributes docs

* Add delays tests

* Add battle tests that involve the use of components

* WIP: test with modifiers

* Use ultimate skill to test modifiers

* Restore logger level

* Recover changes from #346

* Add name field to skills migration

* Fix merge

* Remove wrong log

* Preload character skills on get_unit

* Add comments

* Remove unnecesary preloads

* Add some module doc

* Clarify the objective of the modifiers test

* Add comments to serve as documentation

* Fix merge

* Muflus basic and ulti

* Replace put_in with update_in

* Replace Enum.any? with Map.has_key?

* Handle the two ways of getting the execution data

* Add unique index for skill's name field

* Refactor step processing for effeccts

* Add doc comment

* Rename trigger_skill_effects

* Refactor process_step_for_unit

* Refactor battle processing to use pipes

* Change the executions definition to a map array

* Delete unused execution module

* Refactor new_modifiers

* Fix step number logs

* Adapt tests to changes in effects refactor

* Refactor process_step_for_effects

* Delete components module and define a skills components as an array of maps. Include Heal and AddEnergy cases to the executions

* Fix tests after last merge

* Delete execution obsolete module

* Adapt seeds and tests to the skills refactor

* Add the first 15 champions skills

* Some more champions skills

* Complete champions skills

* Misc fixes

* Remove duplicate lines in effect.ex

* Add skills to characters in config

* Fix typo in modifiers and use atoms for effect type

* apps/champions/test/support/test_utils.ex

* Remove custom type for effect type and use a map

* Add skills to characters.csv

* Simplify validation in effect cast

* Rename function to comply with elixir convention

* Format json

* implement fallback values in simulator

* Revert typo fix as it will be fixed in #464

* Simplify how we get a skill by name in the characters config

* Remove target_attributes field, replacing it with a map in the target strategies

* Prevent a nil access when the skill is not found

* JSON corrections and improvements

* Add increasing delays to skills with multiple executions of the same kind

* Add comment to explain why a function is unused

---------

Co-authored-by: lotuuu <[email protected]>
  • Loading branch information
ncontinanza and lotuuu authored Apr 12, 2024
1 parent efc156d commit 9af26a8
Show file tree
Hide file tree
Showing 9 changed files with 2,100 additions and 205 deletions.
5 changes: 3 additions & 2 deletions apps/champions/lib/champions/battle/simulator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,10 @@ defmodule Champions.Battle.Simulator do
type: effect.type,
delay: effect.initial_delay,
target_count: effect.target_count,
target_strategy: effect.target_strategy,
# TODO: replace random for the corresponding target strategy name (CHoM #325)
# target_strategy: effect.target_strategy,
target_strategy: "random",
target_allies: effect.target_allies,
target_attribute: effect.target_attribute,
components: effect.components,
modifiers: Enum.map(effect.modifiers, &Map.put(&1, :skill_id, skill_id)),
executions: effect.executions
Expand Down
22 changes: 21 additions & 1 deletion apps/champions/lib/champions/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ defmodule Champions.Config do
|> Enum.to_list()

characters
|> Enum.map(fn [name, quality, ranks_dropped_in, class, faction, attack, health, defense] ->
|> Enum.map(fn [
name,
quality,
ranks_dropped_in,
class,
faction,
attack,
health,
defense,
basic_skill,
ultimate_skill
] ->
%{
name: name,
quality: String.downcase(quality) |> String.to_atom() |> Units.get_quality(),
Expand All @@ -42,9 +53,18 @@ defmodule Champions.Config do
base_health: Integer.parse(health) |> elem(0),
base_defense: Integer.parse(defense) |> elem(0),
game_id: Utils.game_id(),
basic_skill_id: get_skill_id(basic_skill),
ultimate_skill_id: get_skill_id(ultimate_skill),
active: true
}
end)
|> Characters.upsert_characters()
end

defp get_skill_id(skill) do
case Skills.get_skill_by_name(skill) do
nil -> nil
skill -> skill.id
end
end
end
66 changes: 33 additions & 33 deletions apps/champions/priv/characters.csv
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
Name,Quality,RanksDroppedIn,Class,Faction,ATK,HP,DEF
Melo,Common,1,Warrior,Araban,27,254,45
Arupe,Common,1,Mage,Kaline,45,156,40
Valcher,Common,1,Hunter,Merliot,36,161,43
Byte,Common,1,Warrior,Otobi,29,227,46
Qurin,Common,2,Hunter,Araban,49,251,53
Chekla,Common,2,Cleric,Kaline,45,265,56
Germund,Common,2,Mage,Merliot,56,232,54
Scratch,Common,2,Assassin,Otobi,64,206,49
Kel'mut,Common,3,Assassin,Araban,81,289,53
Toburo,Common,3,Warrior,Kaline,51,438,61
Dafnet,Common,3,Cleric,Merliot,59,394,58
Hash,Common,3,Hunter,Otobi,70,325,57
Obure,Rare,4,Cleric,Araban,62,542,66
Zil'kan,Rare,4/5,Hunter,Araban,72,481,65
Fetra,Rare,4/5,Assassin,Araban,86,365,64
Kampako,Rare,4/5,Warrior,Kaline,64,549,67
Zanochi,Rare,4/5,Hunter,Kaline,69,471,65
Kura'bara,Rare,4/5,Mage,Kaline,82,442,67
Boy Kampf,Rare,4/5,Hunter,Merliot,86,431,64
Romulo,Rare,4/5,Assassin,Merliot,82,425,59
Grimstein,Rare,4/5,Warrior,Merliot,45,615,68
Elix1r,Rare,4/5,Cleric,Otobi,70,519,65
Rust,Rare,4/5,Assassin,Otobi,91,394,62
Jayson,Rare,4/5,Mage,Otobi,73,482,63
Muflus,Epic,5,Warrior,Araban,63,621,78
Otix,Epic,5,Mage,Araban,91,409,73
Uma,Epic,5,Assassin,Kaline,98,413,68
Uren,Epic,5,Cleric,Kaline,77,598,71
D'agna,Epic,5,Cleric,Merliot,84,556,65
Valtimer,Epic,5,Mage,Merliot,93,519,67
H4ck,Epic,5,Hunter,Otobi,90,515,66
Kenzu,Epic,5,Warrior,Otobi,92,510,71
Name,Quality,Ranks Dropped In,Class,Faction,ATK,HP,DEF, Basic Skill, Ultimate Skill
Melo,Common,1,Warrior,Araban,27,254,45,Melo Basic,Melo Ultimate
Arupe,Common,1,Mage,Kaline,45,156,40,Arupe Basic,Arupe Ultimate
Valcher,Common,1,Hunter,Merliot,36,161,43,Valcher Basic,Valcher Ultimate
Byte,Common,1,Warrior,Otobi,29,227,46,Byte Basic,Byte Ultimate
Qurin,Common,2,Hunter,Araban,49,251,53,Qurin Basic,Qurin Ultimate
Chekla,Common,2,Cleric,Kaline,45,265,56,Chekla Basic,Chekla Ultimate
Germund,Common,2,Mage,Merliot,56,232,54,Germund Basic,Germund Ultimate
Scratch,Common,2,Assassin,Otobi,64,206,49,Scratch Basic,Scratch Ultimate
Kel'mut,Common,3,Assassin,Araban,81,289,53,Kel'mut Basic,Kel'mut Ultimate
Toburo,Common,3,Warrior,Kaline,51,438,61,Toburo Basic,Toburo Ultimate
Dafnet,Common,3,Cleric,Merliot,59,394,58,Dafnet Basic,Dafnet Ultimate
Hash,Common,3,Hunter,Otobi,70,325,57,Hash Basic,Hash Ultimate
Obure,Rare,4,Cleric,Araban,62,542,66,Obure Basic,Obure Ultimate
Zil'kan,Rare,4/5,Hunter,Araban,72,481,65,Zil'kan Basic,Zil'kan Ultimate
Fetra,Rare,4/5,Assassin,Araban,86,365,64,Fetra Basic,Fetra Ultimate
Kampako,Rare,4/5,Warrior,Kaline,64,549,67,Kampako Basic,Kampako Ultimate
Zanochi,Rare,4/5,Hunter,Kaline,69,471,65,Zanochi Basic,Zanochi Ultimate
Kura'bara,Rare,4/5,Mage,Kaline,82,442,67,Kura'bara Basic,Kura'bara Ultimate
Boy Kampf,Rare,4/5,Hunter,Merliot,86,431,64,Boy Kampf Basic,Boy Kampf Ultimate
Romulo,Rare,4/5,Assassin,Merliot,82,425,59,Romulo Basic,Romulo Ultimate
Grimstein,Rare,4/5,Warrior,Merliot,45,615,68,Grimstein Basic,Grimstein Ultimate
Elix1r,Rare,4/5,Cleric,Otobi,70,519,65,Elix1r Basic,Elix1r Ultimate
Rust,Rare,4/5,Assassin,Otobi,91,394,62,Rust Basic,Rust Ultimate
Jayson,Rare,4/5,Mage,Otobi,73,482,63,Jayson Basic,Jayson Ultimate
Muflus,Epic,5,Warrior,Araban,63,621,78,Muflus Basic,Muflus Ultimate
Otix,Epic,5,Mage,Araban,91,409,73,Otix Basic,Otix Ultimate
Uma,Epic,5,Assassin,Kaline,98,413,68,Uma Basic,Uma Ultimate
Uren,Epic,5,Cleric,Kaline,77,598,71,Uren Basic,Uren Ultimate
D'agna,Epic,5,Cleric,Merliot,84,556,65,D'agna Basic,D'agna Ultimate
Valtimer,Epic,5,Mage,Merliot,93,519,67,Valtimer Basic,Valtimer Ultimate
H4ck,Epic,5,Hunter,Otobi,90,515,66,H4ck Basic,H4ck Ultimate
Kenzu,Epic,5,Warrior,Otobi,92,510,71,Kenzu Basic,Kenzu Ultimate
Loading

0 comments on commit 9af26a8

Please sign in to comment.