calc-h 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -3
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/o/enemy.d.ts +8 -0
- package/dist/core/o/enemy.js +3 -0
- package/dist/core/o/index.d.ts +42 -0
- package/dist/core/o/index.js +56 -0
- package/dist/core/o/resistance.d.ts +3 -0
- package/dist/core/o/resistance.js +1 -0
- package/dist/core/o/utils/calc.d.ts +1 -0
- package/dist/core/o/utils/calc.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +29 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 H-Pluto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
|
1
|
+
# OCalc
|
|
2
|
+
一个伤害计算库
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './o/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './o/index.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Resistance } from './resistance.js';
|
|
2
|
+
/**
|
|
3
|
+
* 攻击力计算
|
|
4
|
+
* @author huaju
|
|
5
|
+
* @param baseAttack 基础攻击(白值)
|
|
6
|
+
* @param extreme 加成百分比
|
|
7
|
+
* @param 面板攻击力
|
|
8
|
+
*/
|
|
9
|
+
export declare function attackCalc(baseAttack: number, extreme: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* 基础伤害计算
|
|
12
|
+
* @author huaju
|
|
13
|
+
* @param attribute 计算属性
|
|
14
|
+
* @param multiplier 计算倍率
|
|
15
|
+
* @returns 基础伤害
|
|
16
|
+
*/
|
|
17
|
+
export declare function baseDamageCalc(attribute: number, multiplier: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* 羽毛加成计算
|
|
20
|
+
* @author huaju
|
|
21
|
+
* @param attribute 计算属性
|
|
22
|
+
* @param multiplier 计算倍率
|
|
23
|
+
* @description 只计算出羽毛的增加的值
|
|
24
|
+
* @returns 羽毛加成值
|
|
25
|
+
*/
|
|
26
|
+
export declare function featherCalc(attribute: number, multiplier: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* 敌对单位防御计算
|
|
29
|
+
* @author huaju
|
|
30
|
+
* @param roleLevel 角色等级
|
|
31
|
+
* @param enemyLevel 敌人等级
|
|
32
|
+
*/
|
|
33
|
+
export declare function defenseCalc(roleLevel: number, enemyLevel: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* 抗性计算
|
|
36
|
+
* @author huaju
|
|
37
|
+
* @description 减抗后的负抗性相当于增伤,但是效果减半
|
|
38
|
+
* @param resistance 原始抗性
|
|
39
|
+
* @param reduce 削抗值
|
|
40
|
+
* @returns 最终抗性
|
|
41
|
+
*/
|
|
42
|
+
export declare function resistanceCalc(resistance: Resistance, reduce: Resistance): Resistance;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { roundTo } from './utils/calc.js';
|
|
2
|
+
/**
|
|
3
|
+
* 攻击力计算
|
|
4
|
+
* @author huaju
|
|
5
|
+
* @param baseAttack 基础攻击(白值)
|
|
6
|
+
* @param extreme 加成百分比
|
|
7
|
+
* @param 面板攻击力
|
|
8
|
+
*/
|
|
9
|
+
export function attackCalc(baseAttack, extreme) {
|
|
10
|
+
return roundTo(baseAttack * (1 + extreme));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 基础伤害计算
|
|
14
|
+
* @author huaju
|
|
15
|
+
* @param attribute 计算属性
|
|
16
|
+
* @param multiplier 计算倍率
|
|
17
|
+
* @returns 基础伤害
|
|
18
|
+
*/
|
|
19
|
+
export function baseDamageCalc(attribute, multiplier) {
|
|
20
|
+
return roundTo(attribute * multiplier);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 羽毛加成计算
|
|
24
|
+
* @author huaju
|
|
25
|
+
* @param attribute 计算属性
|
|
26
|
+
* @param multiplier 计算倍率
|
|
27
|
+
* @description 只计算出羽毛的增加的值
|
|
28
|
+
* @returns 羽毛加成值
|
|
29
|
+
*/
|
|
30
|
+
export function featherCalc(attribute, multiplier) {
|
|
31
|
+
return roundTo(attribute * multiplier);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 敌对单位防御计算
|
|
35
|
+
* @author huaju
|
|
36
|
+
* @param roleLevel 角色等级
|
|
37
|
+
* @param enemyLevel 敌人等级
|
|
38
|
+
*/
|
|
39
|
+
export function defenseCalc(roleLevel, enemyLevel) {
|
|
40
|
+
return roundTo((roleLevel + 100) / (roleLevel + 100 + enemyLevel + 100));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 抗性计算
|
|
44
|
+
* @author huaju
|
|
45
|
+
* @description 减抗后的负抗性相当于增伤,但是效果减半
|
|
46
|
+
* @param resistance 原始抗性
|
|
47
|
+
* @param reduce 削抗值
|
|
48
|
+
* @returns 最终抗性
|
|
49
|
+
*/
|
|
50
|
+
export function resistanceCalc(resistance, reduce) {
|
|
51
|
+
let resultFire = resistance.fire - reduce.fire;
|
|
52
|
+
let result = {
|
|
53
|
+
fire: roundTo(resultFire < 0 ? resultFire / 2 : resultFire),
|
|
54
|
+
};
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function roundTo(value: number, decimals?: number): number;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "calc-h",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "伤害计算公式集",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "huaju",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc && tsc-alias",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"lint": "oxlint",
|
|
19
|
+
"lint:fix": "oxlint --fix",
|
|
20
|
+
"format": "prettier --write .",
|
|
21
|
+
"format:check": "prettier --check ."
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"oxlint": "^1.90.0",
|
|
25
|
+
"prettier": "^3.9.10",
|
|
26
|
+
"tsc-alias": "^1.9.10",
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
29
|
+
"vitest": "^5.0.5"
|
|
30
|
+
}
|
|
31
|
+
}
|