I've got a reasonable handle on it in terms of observers and events in the model and communicating these to the view (and controller), however I'm having a bit of difficultly in figuring out how to completely eliminate data about the graphical representation from the model.
Take this (massively simple) example of a fairly basic RPG. Since my model is data-driven, I have a single "Unit" class which contains information about the units (no need for Troll, Goblin, etc subclasses).
class Unit
{
string name; //Friendly name, e.g. Dave
int hp;
int damage;
int range;
Unit(string name, int hp, int damage);
}
Then in my model I keep a list of these Units as well as a method to retrieve them so the view can access them.
class Model // LevelState or similar would be a better name for this
{
Unit[] units;
Unit[] GetUnits();
}
The problem occurs when I come to drawing the units, as far as my model is concerned it doesn't care about if the unit is a goblin, an archer or a giant salamader, all it cares about is the unit's stats which define it's behavior.
However, the view very much cares about if the unit is a goblin, an archer or a giant salamader as it will have to draw different sprites for each of them.
What is the best way to solve this? I could add an enumerated "type" field to the Unit class, but this feels wrong as it's polluting the model with data that it doesn't care about, but I really can't see any other way of doing this.
Am I just overthinking and getting too concerned with what is "right" and "clean"?