@sun@shitposter.world i'm confused about how you can't easily just throw every single attribute into a new map and then pattern matching will work from top down, so you just have your most specific cases to least specific in order
def execute_turn(other_player_attributes, other_player) do
get_random_attack_value()
|> calculate_dmg(other_player_attributes)
|> deduct_health(other_player)
end
def calculate_dmg(damage, %{condition: :on_fire}), do: damage * 1.5
def calculate_dmg(damage, %{condition: :sleepy}), do: damage * 0.8
def calculate_dmg(damage, _attributes), do: damageetc etc
the thing is you have to already ignore the idea of a class heirarchy or even traits and go back to data, if you have to set up traits then you're dealing with that complexity generated by your combinations (which might not even matter for most interactions) instead of just defining your interactions based on the data (which is what really matters)
Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
受不了包 (shibao@misskey.bubbletea.dev)'s status on Saturday, 06-Apr-2024 01:49:02 JST受不了包