Thread: [Discussion] Interest in a Java Pokemon API?
View Single Post
Old March 2nd, 2013 (10:31 AM).
iTeruri's Avatar
iTeruri iTeruri is offline
Join Date: May 2006
Location: The Nederlands
Nature: Relaxed
Posts: 277
The true beauty comes in when people start using the field in different ways, I think. With these kind of projects it's important to make things as abstract as possible. While it makes more sense for the effect-field to just be some kind of identifier when the effects are hard coded, it might not make any sense with other ways of using the field. I do like the instanceof solution, didn't think of that one before.

So you might code Adaptability like that, but using the same effect-field and Interface, but with a different implementation, I might code Adaptability like this:

public whatever damageCalculation()
    //the ability should do it's effect that triggers when attacking the opponent.
    //calculate damge.
    //for this specific anility, the Pokemon class could have a STAB field, or something like that. Or a List of 'attack bonusses' that now has a HigherSTAB bonus or something, it depens on the engine.
We are still using the exact same Pokemon class, with the exact same Ability class and the same reference to a field of the type Effect. While I might have to change a few things around, for the most part the Data Structures are unchanged.
Reply With Quote