Giter Club home page Giter Club logo

Comments (6)

smytheagain avatar smytheagain commented on June 16, 2024

Possibly related to issue #19 since I was leaning on the 'Z' key in the battles to speed up reproduction of the issue. I can't remember if the first time I saw it was using the mouse or the 'Z' key.
I will replace the AttackCurrentMonster code with that suggested in #19 and report back.

from soscsrpg.

ScottLilly avatar ScottLilly commented on June 16, 2024

Thank you for sharing that (along with providing all those details).

from soscsrpg.

smytheagain avatar smytheagain commented on June 16, 2024

Thanks Scott. I'm actually a software tester by trade so I tend to throw in detail where I can.

Unfortunately the issue is still present with the modified AttackCurrentMonster code but can take a long time before it presents itself (my character has 195 experience points - that's 39 snake kills haha).

from soscsrpg.

FrejGMNielsen avatar FrejGMNielsen commented on June 16, 2024

I have tested around a little bit with this issue. One dirty fix is to clear the GameMessages textbox every now and then, to stop it from growing too large in size.
Doing so, seems to completely stop the issue from happening.

Code snippet from MainWindow.xaml.cs if you want to test it on your machine:

        private void OnGameMessageRaised(object sender, GameMessageEventArgs e)
        {
            GameMessages.Document.Blocks.Clear();
            GameMessages.Document.Blocks.Add(new Paragraph(new Run(e.Message)));
            GameMessages.ScrollToEnd();
        }

Furthermore I've tried creating a unit test to emulate the player behavior of holding down the attack-button (it does not crash):

        [TestMethod]
        public void TestALoadOfMonsterKillingForCrashing()
        {
            GameSession gameSession = new();

            // Move player to Herbalist's Garden
            gameSession.MoveNorth();
            gameSession.MoveNorth();

            // Set weapon to rusty sword.
            gameSession.CurrentPlayer.CurrentWeapon = ItemFactory.CreateGameItem(1002);

            // Check if the weapon was equipped correctly, and make sure there are enemies at this location.
            Assert.IsTrue(gameSession.CurrentPlayer.CurrentWeapon.ItemTypeID == 1002);
            Assert.IsTrue(gameSession.CurrentLocation.MonstersHere.Any());

            // Attack an absurd amount of monsters, to see if it crashes.
            // Furthermore; ensure the player moves back to the Herbalist's Garden.
            for (int i = 0; i < 10000; i++)
            {
                while (!gameSession.CurrentLocation.MonstersHere.Any())
                {
                    gameSession.MoveNorth();
                }
                gameSession.AttackCurrentMonster();
            }
            // If the player has more than 100 experience points (in reality, it should be in the thousands), the test is concluded.
            Assert.IsTrue(gameSession.CurrentPlayer.ExperiencePoints > 100);
        }

And one last thing I want to add, if you use a weapon that one-shots the monsters, the issue doesn't seem to appear at all, no matter how much text fills up in the RichTextBox.
Also thanks for the tutorials, Scott!

from soscsrpg.

ScottLilly avatar ScottLilly commented on June 16, 2024

Thanks @FrejGMNielsen

I might check that code out this week. I just started a new project for a client last week, and haven't had much time to look at anything except their code.

In one of the later changes to the code, I added a change that limited the number of messages allowed to bind to the display. I also changed the UI control from a RichTextBox to a FlowDocument. Were you seeing the error with that change, or was it happening with the RichTextBox?

       private void OnGameMessageRaised(object sender, GameMessageEventArgs e)
        {
            if (GameMessages.Count > 250)
            {
                GameMessages.RemoveAt(0);
            }

            GameMessages.Add(e.Message);
        }

from soscsrpg.

FrejGMNielsen avatar FrejGMNielsen commented on June 16, 2024

Were you seeing the error with that change, or was it happening with the RichTextBox?

       private void OnGameMessageRaised(object sender, GameMessageEventArgs e)
        {
            if (GameMessages.Count > 250)
            {
                GameMessages.RemoveAt(0);
            }

            GameMessages.Add(e.Message);
        }

It was indeed on an earlier lection using RichTextBox. I imagine your change would've eliminated the issue, but I can't confirm it myself since I am still early on in the lections.

from soscsrpg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.