npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@unrealknight/cc-battleframework

v1.0.1

Published

薛之猫 战斗框架扩展包 - 提供完整的即时战斗系统

Downloads

2

Readme

@xforge/cc-battle

XForge 战斗框架扩展包 - 提供完整的回合制/即时战斗系统

特性

  • 🎮 完整的战斗系统 - 支持回合制和即时战斗
  • 📊 属性系统 - 灵活的属性计算和修改器系统
  • ⚔️ 技能系统 - 普攻、主动技能、被动技能、终结技
  • 🛡️ Buff系统 - 支持增益、减益、控制、持续伤害/治疗等
  • 🤖 AI系统 - 基于行为树的AI决策系统
  • 📡 事件系统 - 完善的事件中心,解耦逻辑与表现
  • 🎯 目标选择 - 多种目标选择策略
  • 🔧 高可扩展性 - 工厂模式,支持自定义技能和Buff

安装

npm run pkg:add @xforge/cc-battle

快速开始

1. 初始化配置

import { BattleManager, ConfigManager } from '@xforge/cc-battle';

// 加载配置
BattleManager.instance.initializeConfigs(heroConfigs, skillConfigs, buffConfigs);

2. 创建战斗

import { BattleManager, Camp } from '@xforge/cc-battle';

// 战斗配置
const battleConfig = {
    teamA: [
        { heroId: 1001, position: { x: -200, y: 0 }, level: 10 }
    ],
    teamB: [
        { heroId: 2001, position: { x: 200, y: 0 }, level: 10 }
    ],
    timeLimit: 180,
    randomSeed: 12345
};

// 初始化并开始战斗
BattleManager.instance.init(battleConfig);
BattleManager.instance.start();

3. 战斗更新

// 在游戏主循环中调用
update(dt: number) {
    BattleManager.instance.update(dt);
}

4. 监听事件

import { EventCenter, BattleEvents } from '@xforge/cc-battle';

// 监听伤害事件
EventCenter.on(BattleEvents.DAMAGE_TAKEN, (data) => {
    console.log(`角色 ${data.heroId} 受到 ${data.damage.finalDamage} 点伤害`);
});

// 监听战斗结束
EventCenter.on(BattleEvents.BATTLE_END, (data) => {
    console.log(`战斗结束,胜利方: ${data.winner}`);
});

配置表格式

角色配置 (HeroConfig)

const heroConfig: HeroConfig = {
    id: 1001,
    name: "战士",
    type: HeroType.MELEE,
    baseAttrs: {
        MHP: 1000,
        ATT: 100,
        DEF: 50,
        SPD: 1,
        MSPD: 5
    },
    skills: {
        normalAttack: 10001,
        skills: [10002, 10003],
        passives: [10004]
    }
};

技能配置 (SkillConfig)

const skillConfig: SkillConfig = {
    id: 10001,
    name: "普通攻击",
    type: SkillType.NORMAL_ATTACK,
    conditions: { cooldown: 1 },
    timing: {
        preCastTime: 0.1,
        channelTime: 0,
        castTime: 0.3,
        recoveryTime: 0.2
    },
    targeting: {
        type: TargetType.SINGLE_ENEMY,
        camp: TargetCamp.ENEMY,
        range: 100,
        maxTargets: 1
    },
    effects: [{
        type: EffectType.DAMAGE,
        trigger: EffectTrigger.ON_HIT,
        target: EffectTarget.SKILL_TARGET,
        damage: {
            formula: "ATT * 1.0",
            damageType: DamageType.PHYSICAL,
            canCrit: true
        }
    }]
};

Buff配置 (BuffConfig)

const buffConfig: BuffConfig = {
    id: 20001,
    name: "攻击强化",
    type: BuffType.POSITIVE,
    duration: { baseDuration: 10 },
    stacking: { type: StackType.REFRESH, maxStacks: 1, stackDuration: false },
    effects: [{
        type: BuffEffectType.ATTR_MODIFY,
        trigger: BuffEffectTrigger.ON_ADD,
        attrModify: {
            attrType: AttrType.ATT,
            modifyType: ModifyType.PERCENT_ADD,
            value: 0.2 // 攻击力+20%
        }
    }]
};

架构

@xforge/cc-battle
├── types/          # 类型定义
│   ├── Enums.ts      # 枚举定义
│   ├── Interfaces.ts # 接口定义
│   └── Configs.ts    # 配置表类型
├── event/          # 事件系统
│   ├── EventCenter.ts
│   └── BattleEvents.ts
├── core/           # 核心逻辑层
│   ├── BattleContext.ts  # 战斗上下文
│   ├── BattleManager.ts  # 战斗管理器
│   ├── entity/           # 实体系统
│   ├── fsm/              # 状态机
│   ├── skill/            # 技能系统
│   ├── buff/             # Buff系统
│   ├── calculator/       # 计算器
│   ├── ai/               # AI系统
│   ├── target/           # 目标选择
│   └── utils/            # 工具类
├── config/         # 配置管理
│   └── ConfigManager.ts
└── adapter/        # Cocos适配层
    ├── BattleSceneAdapter.ts
    ├── HeroViewAdapter.ts
    └── ...

自定义扩展

自定义技能

import { Skill, SkillFactory } from '@xforge/cc-battle';

class MyCustomSkill extends Skill {
    protected onCast(): void {
        // 自定义技能逻辑
    }
}

// 注册自定义技能
SkillFactory.register(99001, MyCustomSkill);

自定义Buff

import { Buff, BuffFactory } from '@xforge/cc-battle';

class MyCustomBuff extends Buff {
    protected onTick(): void {
        // 自定义心跳逻辑
    }
}

// 注册自定义Buff
BuffFactory.register(99001, MyCustomBuff);

自定义AI行为

import { AIBehavior, BTNodeStatus } from '@xforge/cc-battle';

class MyAIBehavior extends AIBehavior {
    name = 'MyBehavior';
    
    canExecute(owner, blackboard) {
        return true;
    }
    
    execute(owner, blackboard) {
        // 自定义AI行为
        return BTNodeStatus.SUCCESS;
    }
}

许可证

MIT