Skip to content

Comments

Add name-based combat style API (issue #20)#27

Open
MaxBittker wants to merge 1 commit intomainfrom
claude/issue-20-solution-56PTv
Open

Add name-based combat style API (issue #20)#27
MaxBittker wants to merge 1 commit intomainfrom
claude/issue-20-solution-56PTv

Conversation

@MaxBittker
Copy link
Owner

Summary

Implements a name-based combat style API that allows setting combat styles by trained skill name (e.g., 'Attack', 'Strength', 'Defence') instead of opaque weapon-specific indices. The SDK automatically resolves skill names to the correct style index for the currently equipped weapon.

Key Changes

  • New sendSetCombatStyle() overload: Now accepts both numeric indices (for backwards compatibility) and skill names as strings. Automatically resolves skill names to the correct index based on the equipped weapon's available styles.

  • New porcelain bot.setCombatStyle() method: High-level API that sets combat style by skill name and waits for the effect to take place. Returns a typed SetCombatStyleResult with success status, the matched style object, and a reason code for failures (no_matching_style, already_set, etc.).

  • New getCombatStyle() convenience method: Returns the current CombatStyleState containing the equipped weapon name, current style index, and available styles with their trained skills.

  • New types:

    • TrainableSkill type for skill name validation
    • SetCombatStyleResult interface with detailed result information and reason codes
  • Updated documentation: learnings/combat.md now shows the new skill-name-based API with examples, replacing the old index-based approach. Includes examples of error handling and balanced training patterns.

  • Comprehensive test coverage: New combat-style.ts test file verifies:

    • Skill name resolution to correct indices
    • Case-insensitive matching
    • Clear error messages listing available styles
    • Style updates after weapon changes
    • Backwards compatibility with raw indices
    • Porcelain API waiting for effect confirmation

Implementation Details

  • Skill name matching is case-insensitive to improve usability
  • When multiple styles train the same skill, the first match is used
  • Error messages include the list of available styles for the current weapon
  • The porcelain API detects when a style is already set and returns already_set reason
  • Backwards compatibility maintained: raw numeric indices still work as before

https://claude.ai/code/session_01JQF7su76pQyGyixghdNRuL

…ices

Combat style indices are weapon-dependent (e.g. index 3 means Defence for
swords but doesn't exist for unarmed), causing silent training bugs.

Changes:
- sendSetCombatStyle() now accepts TrainableSkill names ('Attack',
  'Strength', 'Defence', 'Ranged', 'Shared') in addition to raw indices
- Add getCombatStyle() convenience method to BotSDK
- Add setCombatStyle() porcelain method to BotActions that waits for
  the style change to take effect
- Add TrainableSkill type and SetCombatStyleResult to types.ts
- Add integration test (sdk/test/combat-style.ts)
- Update learnings/combat.md with name-based API examples

Closes #20

https://claude.ai/code/session_01JQF7su76pQyGyixghdNRuL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants