I'm developing a turn based RPG in java for android phones and I'm currently trying to figure out how to handle attacks that have extra variables beyond damage. For example, I would like to have fire attacks do an extra 10% damage when the target has a burn effect. I'm a bit unsure how to go about doing this in an efficient way and one that allows for future additions to my status/attack system.
So here are my thoughts on how I can do this:
A series of if/else statements or switch's
switch (status) { case burned: if (type == fire) { damage = damage * 1.1; } break; case frozen: if (type == ice) { damage = damage * 2; } break; }
I could also use nested switches if I have many possible results for each status.
Use an two dimensional array with the
x
values being statuses and they
values being attacks or types. When you check the[x][y]
it returns a numerical value for the change that will occur in attack.Burned Frozen Fire [1.1] [1] Ice [1] [2]
While both of these seem fine for now, I'm unsure if it will work for the future. Right now, I can certainly use combinations that change the damage amount, but what about attacks that have non-numerical effects where I can't simply return a value and multiply my damage by that value?
Would it be possible to generate some sort of code that represents a situation like:
burned = 1 in first position, frozen = 2 fire attack = f in 2nd position, ice = i damage mod is in the 3rd position
so a fire attack on a burned enemy would be 1-f-1.1
.