Interest in a Java Pokemon API?
View Single Post
March 28th, 2013 (7:30 PM).
Some Game Developer
Join Date: Jan 2011
I'm actually creating a Mystery Dungeon kit, in a similar format. As for interfaces, I learnt the main use of them when creating another game. This is where Interfaces > Classes.
Say we have an Ability. Ability is a class. Then, we have a Pokemon, with it's updateState method.
Ability has a method. This method is called effect(), and receives a Pokemon. It then does everything it needs to.
Now. Let's say there are 10 abilities. We would like to avoid creating 600+ files for Pokemon, so we have 1 generic class that will do everything for us (Maybe some other helper classes too).
The updateState method looks something like this:
public void updateState(String state)
Ability a1 = this.primaryAbility;
if(ability instanceof AOvergrow)
//And then again for secondary effect
This is ridiculous. For every ability in the game, we add an extra 2 lines, and, with secondary abilities, that's 4 lines per ability!
However, with Ability as an interface, it's one line!
Sure, more classes, but you could narrow them down. You'd find a way
The Monoball Challenge - Have you got what it takes to catch 'em all, but with only one type of Pokéball?
Also Known As:
Formerly known as Anglican
View Public Profile
Send a private message to UnderMybrella
Find all posts by UnderMybrella
Find threads started by UnderMybrella