All Questions

Community

Grominet

How to test the challenge?

It is the first time I am using Godot Resource functionality, and so I have troubles testing my code with your example to see if everything works. How would you do it?

  • Nathan Lovato replied

    I would create a dedicated scene with only a node and script. And from the code, create an instance of the Stats script and run code on it, then use assert() to test the expected output. Here's some code off the top of my head to get the idea across.

    var stats = Stats.new()
    func test_stats():
        stats.base_attack = 100
        stats.add_multiplier_modifier("attack", 0.2)
        stats.add_amount_modifier("attack", 50)
        assert(stats.attack == 170)