javalent / fantasy-statblocks

Create Dungeons and Dragons style statblocks for Obsidian.md
MIT License
352 stars 71 forks source link

🐞 Extends feature - extending an extended creature inherits the original creatures stats instead of the modified ones. #400

Closed MattGRMP closed 5 months ago

MattGRMP commented 5 months ago

Check for existing bug reports before submitting.

Expected Behavior

Creature A extends an Acolyte but changes the stats. Creature B then extends creature A. The expected behavior is that creature B will have the same stats as creature A.

name: Creature A
extends: Acolyte
stats:
  - 8
  - 12
  - 12
  - 10
  - 10
  - 16
name: Creature B
extends: 
- Creature A

Current behaviour

Instead of inheriting the stats specified in the creature A statblock, it ends up using the stats from the original Acolyte stat block. image image

Reproduction

  1. Launch Obsidian Sandbox via the 'Open Sandbox Vault' command.
  2. Install the Fantasy Statblocks plugin and enable it.
  3. Create a new note.
  4. Paste the following into the new note
    
    ---
    statblock: inline
    name: Creature A
    ---

name: Creature A
extends: Acolyte
stats:
  - 8
  - 12
  - 12
  - 10
  - 10
  - 16
name: Creature B
extends: 
- Creature A

5. Run the Fantasy Statblocks: Parse Frontmatter for Creatures command
6. Refresh Creature B statblock (move the text cursor into the statblock and out again.)

### Which Operating Systems are you using?

- [ ] Android
- [ ] iPhone/iPad
- [ ] Linux
- [ ] macOS
- [X] Windows

### Obsidian Version Check

1.5.12 and 1.5.3

### Plugin Version

4.2.4

### Confirmation

- [X] I have disabled all other plugins and the issue still persists.

### Possible solution

Is the recursive function used by the extends feature calling itself after applying stats from the current depth? If so maybe it should be calling itself at the start of the function to start from the deepest level and overwrite stats as it returns.