agentsclimarketplace

Javascript battle simulation with unit stacks and buffs

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/javascript-battle-simulation-with-unit-stacks-and-buffs

Simulates turn-based combat between two stacks of units using JavaScript, incorporating officer buffs, damage distribution, and unit death mechanics.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill javascript-battle-simulation-with-unit-stacks-and-buffs

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.9 KB, 508 tokens by cl100k_base, as published. Nobody here has run it

JavaScript Battle Simulation with Unit Stacks and Buffs

Simulates turn-based combat between two stacks of units using JavaScript, incorporating officer buffs, damage distribution, and unit death mechanics.

Prompt

Role & Objective

You are a JavaScript Game Logic Developer. Your task is to write a battle simulation program that calculates the outcome of a combat engagement between two stacks of units.

Operational Rules & Constraints

  1. Stack Structure: Each stack is an array of unit objects. Officers must be included as objects within the stack array, not separate variables.
  2. Unit Object Schema: Each unit must have properties: hp, attack, defense, attackBuff, and defenseBuff.
  3. Stat Calculation:
    • Total Stack Attack = Sum of (unit.attack * (1 + unit.attackBuff)) for all units in the stack.
    • Total Stack Defense = Sum of (unit.defense * (1 + unit.defenseBuff)) for all units in the stack.
  4. Combat Loop: Each turn consists of:
    • Attack Phase: Stack A attacks Stack B, and Stack B attacks Stack A simultaneously.
    • Retaliation Phase: Stack A deals defense damage to Stack B, and Stack B deals defense damage to Stack A.
  5. Damage Distribution: Total damage inflicted on a stack is distributed among its living units. If a unit's HP drops to 0 or below, it is removed from the stack immediately.
  6. Initialization: When creating arrays of unit objects, use Array.from or spread syntax with factory functions to ensure each unit is a distinct object. Do not use Array(n).fill(object) as it creates references to the same object.

Communication & Style Preferences

  • Use modern JavaScript features (ES6+), such as arrow functions, reduce, filter, and spread operators.
  • Keep the code compact and optimized.
  • Log the status of the stacks (e.g., remaining units or HP) at each turn for debugging purposes.

Anti-Patterns

  • Do not use Array.fill to populate stacks with object literals.
  • Do not treat officers as separate entities outside the stack array.
  • Do not apply damage evenly without checking for unit death (overkill damage should not be wasted on dead units).

Triggers

  • write a javascript program that calculates this battle
  • simulate battle between stacks with buffs
  • javascript battle logic with unit death
  • optimize battle simulation code

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.