Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test spells (json) and spell tests (cpp) #40328

Merged
merged 1 commit into from
May 10, 2020

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented May 8, 2020

Summary

SUMMARY: Infrastructure "Add tests for magic spells"

Purpose of change

Getting a start on spell tests to help support Magiclysm

Describe the solution

Adds test spells to the TEST_DATA mod, and some test cases using them to verify behaviors of spell-related functions.

Currently exercises these functions:

  • spell class:
    • name
    • exp_to_next_level
    • get_level, set_level
    • damage, range, aoe
    • duration_string
    • cast_spell_effect
  • spell_effect class:
    • target_attack
    • spawn_summoned_monster
    • recover_energy

JSON data covered:

  • name, max_level
  • min_damage, max_damage, damage_increment
  • min_duration, max_duration, duration_increment
  • min_range, max_range, range_increment
  • min_aoe, max_aoe, aoe_increment
  • effect, effect_str
  • base_energy_cost, energy_source

Also includes a fix to the gain_levels spell that was causing an infinite loop when trying to reach the maximum level.

Describe alternatives you've considered

Eternal shadow

There are many more effects that are not yet tested, but this should lay the groundwork.

Testing

tests/cata_test [magic]

Additional context

Reference: doc/MAGIC.md

@wapcaplet wapcaplet requested a review from KorGgenT as a code owner May 8, 2020 03:08
@wapcaplet wapcaplet force-pushed the spelling-bee branch 2 times, most recently from 75ddef9 to a9a23c9 Compare May 8, 2020 03:45
@KorGgenT
Copy link
Member

KorGgenT commented May 8, 2020

damage over time is also a member of spells, and pretty new at that

@wapcaplet
Copy link
Contributor Author

damage over time is also a member of spells, and pretty new at that

Ha, I had momentarily stubbed in a _dot test before I saw the magic doc say they are "currently not implemented". I will add some tests for those functions too.

Test spell functions and effects with fake spells in the `TEST_DATA` mod.

Exercises these functions:

- spell class:
  - name
  - exp_to_next_level
  - get_level, set_level
  - damage, range, aoe
  - duration_string
  - cast_spell_effect

- spell_effect class:
  - target_attack
  - spawn_summoned_monster
  - recover_energy

Related JSON data:

- name, max_level
- min_damage, max_damage, damage_increment
- min_duration, max_duration, duration_increment
- min_range, max_range, range_increment
- min_aoe, max_aoe, aoe_increment
- effect, effect_str
- base_energy_cost, energy_source

Also fixes a potential infinite loop in spell::gain_levels when attempting to
reach the maximum spell level.

Co-authored-by: Curtis Merrill <[email protected]>
@wapcaplet wapcaplet changed the title [WIP] Add test spells (json) and spell tests (cpp) Add test spells (json) and spell tests (cpp) May 9, 2020
@ZhilkinSerg ZhilkinSerg added Code: Tests Measurement, self-control, statistics, balancing. Mods: Magiclysm Anything to do with the Magiclysm mod labels May 10, 2020
@ZhilkinSerg ZhilkinSerg merged commit 9481bcd into CleverRaven:master May 10, 2020
@wapcaplet wapcaplet deleted the spelling-bee branch May 24, 2020 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Tests Measurement, self-control, statistics, balancing. Mods: Magiclysm Anything to do with the Magiclysm mod
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants