Core
๐ฎ TypeScript game numeric engine for RPG & strategy games. Zero dependencies, type-safe formula parsing, battle system simulation, and expression evaluation. ๅบไบ TypeScript ็ๆธธๆๆฐๅผๅผๆ๏ผไธไธบ RPG ๅ็ญ็ฅๆธธๆ่ฎพ่ฎกใ้ถไพ่ตใ็ฑปๅๅฎๅ จ็ๅ ฌๅผ่งฃๆใๆๆ็ณป็ปๆจกๆๅ่กจ่พพๅผ่ฎก็ฎใ
Install / Use
/learn @soonfx-engine/CoreREADME
SoonFx Runtime
The TypeScript-first numeric engine for games.
Decouple logic from code, manage complex formulas with ease, and build robust RPG/SLG/Card systems.
Installation ยท Quick Start ยท Documentation ยท Examples ยท Roadmap ยท Online Demo
</div>โ What is SoonFx?
<img src="assets/editor.gif" align="right" width="250" style="margin-left: 6px;" alt="SoonFx Editor Preview">SoonFx is a TypeScript-first numeric engine designed specifically for games. It addresses the common challenge of managing complex game logic, formulas, and numeric relationships that often become hardcoded "spaghetti code."
๐ซ The Problem
In many game projects, damage calculations, resource production rates, and other numeric logic are hardcoded directly into the source code.
- Hard to maintain: Formulas are buried in nested if-else statements.
- Slow iteration: Designers need engineers to change a simple constant or formula structure.
- Bug prone: Copy-pasting logic leads to subtle errors.
โ The Solution
SoonFx decouples logic from code.
- Logic as Data: Formulas and relationships are defined as data (JSON).
- Runtime Execution: The engine parses and executes this data safely at runtime.
- Visual Tooling: Designers use the SoonFx Editor to visually build these relationships.
๐จ Visual Editor Driven
Stop hardcoding formulas. Build them visually.
SoonFx Runtime is the engine that powers the SoonFx Editor. It allows game designers to configure complex logic without writing a single line of code, while developers can safely execute it at runtime.
The Workflow
- Design: Designers create formulas, skill effects, and attribute relationships in the Visual Editor.
- Export: The editor generates a JSON configuration file.
- Run: The SoonFx Runtime loads this JSON and executes the logic in your game.
Note: While SoonFx Runtime can be used standalone for math and expressions, its true power is unlocked when paired with the Editor.

๐ก Use Cases
SoonFx is designed for numeric-heavy game genres:
- โ๏ธ RPG Systems: Skill damage, character stats growth, equipment bonuses, combat power (CP) calculations.
- ๐ฐ SLG / Strategy: Resource production rates, building upgrade timers, marching times, tech tree requirements.
- ๐ Card Games: Dynamic card values, synergy effects, deck balancing simulation.
- ๐ Simulation: Complex economy models, probability calculations.
๐ธ Demo
Runtime Demo

โจ Features
- โก Zero Dependencies - Lightweight and fast, less than 50KB minified
- ๐ก๏ธ Type-Safe - Full TypeScript support with strict typing and intelligent code completion
- ๐ Expression Engine - Parse and evaluate complex mathematical expressions with RPN conversion
- ๐ฎ Battle System - Built-in RPG battle simulation with character attributes and damage calculation
- ๐ง Extensible - Flexible operator system supporting complex game logic and formula combinations
- ๐ฆ Tree-shakable - Modern ESM support with CommonJS fallback
๐ For Users
To use this library in your project:
npm install @soonfx/engine
๐ฆ Development Setup
Clone and setup the development environment:
# Clone the repository
git clone https://github.com/soonfx-engine/core.git
cd core
# Install dependencies
npm install
# Build the project
npm run build
# Run examples
cd examples
npm install
npm run dev
๐ฏ Quick Start
Basic Usage
import { fx } from '@soonfx/engine';
// 1. Mathematical utilities
const distance = fx.distance(0, 0, 10, 10);
console.log('Distance between points:', distance); // 14.142135623730951
// 2. Expression evaluation
const result = fx.evaluateExpression('(2 + 3) * 4');
console.log('Expression result:', result); // 20
// 3. Numeric processing
const fixed = fx.fixedDecimal(3.14159, 2);
console.log('Fixed to 2 decimals:', fixed); // 3.14
Event System
import { Eve, Call, CallCenter } from '@soonfx/engine';
// Create event call center
const callCenter = new CallCenter();
// Listen to events
callCenter.addEventListener(Eve.SHIFT_ADD_BOARD, (data) => {
console.log('Board added event triggered:', data);
});
// Send events
Call.send(Eve.ADD_DATABASE_DATA, [data, body, index]);
๐ Core API
Mathematical Utilities (fx)
Vector and Geometry Operations
// Calculate distance between two points
const distance = fx.distance(x1, y1, x2, y2);
// Vector dot product
const dotProduct = fx.dot(p1x, p1y, p2x, p2y);
// Vector cross product
const crossProduct = fx.cross(p1x, p1y, p2x, p2y);
// Calculate vector length
const length = fx.length(a, b);
// Coordinate transformation
const coord = fx.coordinate(x, y, angle, distance);
Game Characters (Player)
The Player class provides character attributes, battle calculations, and combat simulation. See the Examples section below for complete battle system demonstrations.
๐๏ธ System Architecture
@soonfx/fx
โโโ Core Systems (core/)
โ โโโ EventManager Event management
โ โโโ System System base class
โ โโโ Types Type definitions
โ
โโโ Mathematical Modules
โ โโโ Vector Vector operations (dot, cross, distance)
โ โโโ Numeric Numeric processing (fixedDecimal, currencyConversion)
โ โโโ Geometry Geometric calculations (coordinate, length)
โ
โโโ Expression System
โ โโโ Parser Expression parser
โ โโโ RPN Converter Reverse Polish Notation converter
โ โโโ Evaluator Evaluation engine
โ
โโโ Data Management (data/)
โ โโโ Layers Layer system
โ โโโ Metadata Metadata management
โ โโโ Models Data models
โ โโโ Storage Storage system
โ
โโโ Game Systems (game/)
โ โโโ FXCentre Game engine core
โ โโโ Player Player character system
โ โโโ Formulas Formula calculation system
โ
โโโ Communication (communication/)
โ โโโ Events Event system
โ โโโ Call Event calling
โ โโโ Message Message passing
โ
โโโ Utilities (utils/)
โโโ ExtendsUtil Extension utilities
๐ Examples
Check out the example project for complete development examples.
Example Contents:
- โ๏ธ Battle system simulation
- ๐ Character attribute calculations
- ๐ฏ PVE data generation
- ๐ Multi-battle comparison analysis
- ๐ฎ Complete game numeric system demonstration
Run Examples Locally:
See the Getting Started section in Contributing for setup instructions.
๐ ๏ธ TypeScript Support
SoonFx provides complete TypeScript type definitions:
// Automatic type inference
const distance: number = fx.distance(0, 0, 10, 10);
// Full IntelliSense support
fx. // IDE will show all available methods
Type Definition Features:
- โ Complete TypeScript type definitions (.d.ts)
- โ Intelligent code completion
- โ Type checking and error hints
- โ Parameter type inference
- โ Return type inference
๐ง Browser and Environment Support
Supported Environments
- โ Node.js >= 14.0.0
- โ
Modern Browsers (ES2015+)
- Chrome, Firefox, Safari, Edge (latest versions)
- โ
Build Tools
- esbuild (recommended, used in this project)
- Webpack, Vite, Rollup, and other modern bundlers
Module Systems
- โ ESM (ES Modules) - Recommended
- โ CommonJS - Node.js environment
๐ค Contributing
We welcome all forms of contributions!
Getting Started
First, clone the repository:
git clone https://github.com/soonfx-engine/core.git
cd core
To Run Examples:
# Navigate to examples directory
cd examples
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
To Contribute Code:
# Install dependencies
npm install
# Build the project
npm run build
# Run tests (if available)
npm test
๐บ๏ธ Roadmap
See our Roadmap for planned features and improvements.
๐ Changelog
View the complete changelog
๐ License
This project is licensed under the Apache 2.0 License. You are free to use, modify, and distribute this project.
๐ Links
- ๐ฆ npm Package
- ๐ป GitHub Repository
- ๐ Online Demo
- ๐ Issue Tracker
- ๐ฌ Discussions
๐ Getting Help
If you encounter any issues:
- ๐ฌ GitHub Discussions - Ask questions and discuss
- ๐ GitHub Issues - Bug reports and feature reques
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
85.3kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
99.6kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
