StevenGann / TRPG

An OOP C# framework for Text RPG games, inspired by the improved console window in Windows 10.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Some monsters become invulnerable after another monster is killed.

StevenGann opened this issue · comments

Sometimes, though not all the time, some monsters will become invulnerable after another monster in the same room has been killed. Specifically, the message "You cannot do that." is shown, meaning that there was a caught exception from this line:

gui.MainText = GameRules.PlayerAttacksMonster(this, (Weapon)playerInventory.Find(newCommand.Tokens[3].Text), playerStats, (Monster)dungeon.CurrentRoom.Contents.Find(newCommand.Tokens[1].Text), (int)DateTime.Now.Ticks & 0x0000FFFF);

The Try/Catch block surrounding this line of code was a lazy approach to making sure that the thing being attacked is a Monster, and the thing being used for attacking is a Weapon. I could replace it with a bunch of If blocks, but that'd be ugly and tedious.

ce9dae4

Nevermind that. It took a while to step through it all but I found and fixed the issue. RNG rolls have to be clamped to >= 1.