Rogue C# – A Few Odd Repairs
This week, I’m taking care of some general fixes and looking at ways to improve the codebase and keep things maintainable around the place. As a bonus, I discovered helper functions in C#.
Technology should be the means, not the end.
Science is not only compatible with spirituality; it is a profound source of spirituality. When we recognize our place in an immensity of light-years and in the passage of ages, when we grasp the intricacy, beauty, and subtlety of life, then that soaring feeling, that sense of elation and humility combined, is surely spiritual.
Carl Sagan, The Demon-Haunted World: Science as a Candle in the Dark
This week, I’m taking care of some general fixes and looking at ways to improve the codebase and keep things maintainable around the place. As a bonus, I discovered helper functions in C#.
Rings are actually one of my least used items in my playing of the classic Rogue. They tend to be risky as they increase food consumption and a cursed ring just won’t come off. Still, they’re part of the game and a great challenge for this project so I decided to add them to the inventory list.
Happily, the remaining traps to my roguelike game did not break anything new in the code; I was able to build on existing resources already in the classes. I also reorganized some code, clearing the deck for the addition of monster special attacks and upcoming inventory additions.
After adding all those potions in one shot, they still had to be tested and every single one exposed something that needed to be improved in the code. The sheer number of fixes would be too long for this post but I did come up with a few interesting examples.
Potions are much like scrolls but every new effect potentially requires supporting changes elsewhere, including new properties and changes to game play. In this chapter, I sample all the potions and see how many ways I can break the code.
As a program grows, it’s important to maintain standards and practices within the code. Classes and methods need clear lines of responsibility and operation in order to keep the code maintainable and reduce errors.
Traps add to the challenge of the game, even if they are annoying sometimes. In this chapter, I add them to the game and discover that the player and monsters have more in common than they know.
During the rescue of the Rogue C# project, I’ve seen some examples of things that weren’t quite thought out the first time around but the MoveMonster() function might have been a case of over-thinking … or of just really needing to walk away for a bit.
Not all scrolls and potions are helpful in a roguelike but that’s part of the fun … more or less. In this update, I add a mix of scrolls including Remove Curse, a frustratingly rare item that you’ll want after putting on the wrong armor and Aggravate Monsters which wil make your life on the level a lot more exciting. As before, every new scroll leads to a re-examination of the code.
The Scroll of Confuse Monster is a scroll that gives the player the power to confuse the next monster they attack for a certain number of turns and then the monster’s confusion lasts a certain number of turns so there are multiple steps to tackle here.