Saturday 4 April 2015

Scroll in the grave

Grave texts were earlier in a Scroll class. It's not that confusing, because texts of scrolls and graves work pretty much the same way, they only have a different kind of graphics background. What I wanted to do is get rid of extra data for graves in the Scroll class, since scrolls only have relatively simple text in them.

When I was refactoring I realized it would be useful to have a basic class for handling text pieces needed in scrolls, graves etc. with several display options and parsing routines depending on the data.

I guess it was the only good thing that followed this refactoring, because in the end I realized that I had only shifted the problem of gravestones from Scroll to Sign class. Signs on the other hand have also simple text data as scrolls, but they also include graves. Of course, I could create a new class for gravestones only, but adding a new game object type is anything else than trivial. The game object system is quite unwieldy and requires another set of features in Level class. I doubt it will be worth the trouble.

The solution is include gravestone data as an extra member of Sign class, just as it was in Scroll class. I guess it's anyway better than gravestones being 'scrolls' as they were before. Signs and gravestones are similar enough that they can share the same game object type, but it's a bit annoying to have that extra member which is 'empty' when the sign is not a gravestone type. I don't want to think about a tomb which is a Grave object type, but also a Sign, or rather gravestone. Or is it just a grave?

No comments:

Post a Comment