Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
吴 亚丹
300s.d.ts
Commits
dd2770c1
Commit
dd2770c1
authored
2 weeks ago
by
吴 亚丹
Browse files
Options
Download
Email Patches
Plain Diff
更新合并脚本
parent
cba50a00
main
No related merge requests found
Pipeline
#223
failed with stages
in 0 seconds
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
bin/300api.d.ts/api.d.ts/GetPlayerInfoCommand.d.ts
+153
-0
bin/300api.d.ts/api.d.ts/GetPlayerInfoCommand.d.ts
bin/api.d.ts
+14398
-1151
bin/api.d.ts
bin/mergeApis.js
+178
-22
bin/mergeApis.js
src/sample.ts
+16
-5
src/sample.ts
tsconfig.json
+18
-0
tsconfig.json
with
14763 additions
and
1178 deletions
+14763
-1178
bin/300api.d.ts/api.d.ts/GetPlayerInfoCommand.d.ts
0 → 100644
+
153
-
0
View file @
dd2770c1
/**
* GetPlayerInfoCommand API 声明文件
* 提供用于获取玩家信息和属性的脚本命令
*/
/**
* 玩家ID类型
*/
export
type
PlayerID
=
number
;
/**
* 命令结果类型
* 0: 成功, -1: 失败
*/
export
type
CommandResult
=
0
|
-
1
;
/**
* 字符串结果类型
* 空字符串表示失败
*/
export
type
StringResult
=
string
;
/**
* 元素类型枚举
*/
export
enum
ElementType
{
Fire
=
1
,
// 火元素
Water
=
2
,
// 水元素
Earth
=
3
,
// 土元素
Wind
=
4
,
// 风元素
Light
=
5
,
// 光元素
Dark
=
6
// 暗元素
}
/**
* 玩家信息类型枚举
*/
export
enum
PlayerInfoType
{
// 基本信息
Name
=
"
name
"
,
// 玩家名称
Level
=
"
level
"
,
// 玩家等级
SummonerLevel
=
"
summonerlevel
"
,
// 召唤师等级
Profession
=
"
profession
"
,
// 职业
Sex
=
"
sex
"
,
// 性别
// 位置信息
MapID
=
"
mapid
"
,
// 地图ID
MapX
=
"
mapx
"
,
// 地图X坐标
MapY
=
"
mapy
"
,
// 地图Y坐标
// 资源信息
Money
=
"
money
"
,
// 金钱
Hp
=
"
hp
"
,
// 当前生命值
MaxHp
=
"
maxhp
"
,
// 最大生命值
Mp
=
"
mp
"
,
// 当前魔法值
MaxMp
=
"
maxmp
"
,
// 最大魔法值
Exp
=
"
exp
"
,
// 经验值
// 属性信息
Strength
=
"
strength
"
,
// 力量
Agility
=
"
agility
"
,
// 敏捷
Intelligence
=
"
intelligence
"
,
// 智力
Vitality
=
"
vitality
"
,
// 体力
// 战斗属性
Attack
=
"
attack
"
,
// 攻击力
Defense
=
"
defense
"
,
// 防御力
MagicAttack
=
"
magicattack
"
,
// 魔法攻击
MagicDefense
=
"
magicdefense
"
,
// 魔法防御
HitRate
=
"
hitrate
"
,
// 命中率
DodgeRate
=
"
dodgerate
"
,
// 闪避率
CritRate
=
"
critrate
"
,
// 暴击率
MoveSpeed
=
"
movespeed
"
,
// 移动速度
// 特殊信息
Prestige
=
"
prestige
"
,
// 声望(需要额外参数指定声望类型)
Item
=
"
item
"
,
// 物品(需要额外参数指定物品ID)
Equip
=
"
equip
"
,
// 装备(需要额外参数指定装备槽位)
// 社交信息
GuildID
=
"
guildid
"
,
// 公会ID
GuildName
=
"
guildname
"
,
// 公会名称
GuildPosition
=
"
guildposition
"
,
// 公会职位
// 状态信息
IsDead
=
"
isdead
"
,
// 是否死亡
IsOnline
=
"
isonline
"
,
// 是否在线
IsFighting
=
"
isfighting
"
,
// 是否战斗中
// 其他信息
CreateTime
=
"
createtime
"
,
// 角色创建时间
LastLoginTime
=
"
lastlogintime
"
,
// 最后登录时间
OnlineTime
=
"
onlinetime
"
// 在线时间
}
/**
* 获取玩家信息
*
* 此命令用于获取指定玩家的各种信息和属性
*
* @param playerID 玩家ID,-1表示当前脚本拥有者
* @param infoType 要获取的信息类型
* @param extraParam 特定信息类型的额外参数(声望类型、装备槽位等)
* @returns 请求的信息值,失败时返回-1或空字符串
*
* @remarks
* - 当操作失败时,数值型返回-1,字符串型返回空字符串
* - 某些信息类型需要额外参数(声望类型、装备槽位等)
* - 帮会相关信息仅在玩家在帮会中时可用
* - 某些属性可能有特殊处理或计算(例如,最终移动速度)
*/
export
function
GetPlayerInfo
(
playerID
:
PlayerID
|
-
1
,
infoType
:
PlayerInfoType
,
extraParam
?:
number
):
CommandResult
|
StringResult
;
/**
* 获取玩家装备元素属性值(放大1000倍)
*
* 此命令用于获取指定玩家装备的元素属性值
*
* @param playerID 玩家ID,-1表示当前脚本拥有者
* @param elementType 元素类型
* @returns 元素属性值(放大1000倍),失败时返回0
*
* @remarks
* - 返回的是放大1000倍的值,使用时需要除以1000转换回实际值
* - 元素属性值计算可能涉及多个装备的属性累加,应优化计算过程
*/
export
function
GetPlayerEquipElementValue1000X
(
playerID
:
PlayerID
|
-
1
,
elementType
:
ElementType
):
number
;
/**
* 添加玩家重置点数
*
* 此命令用于增加或减少玩家的重置点数
*
* @param playerID 玩家ID,-1表示当前脚本拥有者
* @param value 要添加的点数值
* @returns 0表示成功,失败时也返回0
*
* @remarks
* - 可以使用负值减少玩家的重置点数
* - 重置点数可能有最大值限制,超过限制的添加可能会被忽略
* - 重置点数的修改应确保数据一致性,避免并发操作导致的数据不一致
*/
export
function
AddPlayerRerollPoint
(
playerID
:
PlayerID
|
-
1
,
value
:
number
):
CommandResult
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bin/api.d.ts
+
14398
-
1151
View file @
dd2770c1
This diff is collapsed.
Click to expand it.
bin/mergeApis.js
+
178
-
22
View file @
dd2770c1
...
...
@@ -17,27 +17,153 @@ async function mergeApiDefinitions() {
mergedContent
+=
'
* 自动合并生成,包含所有API模块
\n
'
;
mergedContent
+=
'
*/
\n\n
'
;
// 添加缺失的类型定义
mergedContent
+=
'
// 添加缺失的类型定义
\n
'
;
mergedContent
+=
'
interface SkillInfo {
\n
'
;
mergedContent
+=
'
id: number;
\n
'
;
mergedContent
+=
'
name: string;
\n
'
;
mergedContent
+=
'
description: string;
\n
'
;
mergedContent
+=
'
maxLevel: number;
\n
'
;
mergedContent
+=
'
}
\n\n
'
;
mergedContent
+=
'
interface SkillLevelInfo {
\n
'
;
mergedContent
+=
'
level: number;
\n
'
;
mergedContent
+=
'
damage: number;
\n
'
;
mergedContent
+=
'
cooldown: number;
\n
'
;
mergedContent
+=
'
cost: number;
\n
'
;
mergedContent
+=
'
}
\n\n
'
;
// 用于跟踪已经添加的类型和接口,避免重复
const
addedTypes
=
new
Set
();
const
addedInterfaces
=
new
Set
();
const
addedFunctions
=
new
Set
();
// 添加缺失的类型定义
mergedContent
+=
'
// 添加缺失的类型定义
\n
'
;
// 添加类型定义的函数
function
addType
(
name
,
definition
)
{
if
(
!
addedTypes
.
has
(
name
))
{
mergedContent
+=
`type
${
name
}
=
${
definition
}
;\n\n`
;
addedTypes
.
add
(
name
);
}
}
// 通用类型
addType
(
'
CommandResult
'
,
'
0 | -1
'
);
addType
(
'
PlayerID
'
,
'
number
'
);
addType
(
'
FighterID
'
,
'
number
'
);
addType
(
'
StatusID
'
,
'
number
'
);
addType
(
'
MapID
'
,
'
number
'
);
addType
(
'
Side
'
,
'
number
'
);
addType
(
'
ItemID
'
,
'
number
'
);
addType
(
'
MonsterID
'
,
'
number
'
);
addType
(
'
HeroID
'
,
'
number
'
);
addType
(
'
DuplicateID
'
,
'
number
'
);
addType
(
'
TaskID
'
,
'
number
'
);
// 玩家信息类型
addType
(
'
PlayerInfoType
'
,
'
string
'
);
addType
(
'
ElementType
'
,
'
number
'
);
// AI命令相关类型
addType
(
'
AICommandResult
'
,
'
CommandResult
'
);
addType
(
'
AIPlayerID
'
,
'
PlayerID
'
);
addType
(
'
AINumLimit
'
,
'
number
'
);
addType
(
'
PosX
'
,
'
number
'
);
addType
(
'
PosY
'
,
'
number
'
);
// 达尔文相关类型
addType
(
'
DarwinCommandResult
'
,
'
CommandResult
'
);
addType
(
'
DarwinPlayerID
'
,
'
PlayerID
'
);
addType
(
'
TableName
'
,
'
string
'
);
addType
(
'
RowName
'
,
'
string
'
);
addType
(
'
ColumnIndex
'
,
'
number
'
);
addType
(
'
Score
'
,
'
number
'
);
addType
(
'
Level
'
,
'
number
'
);
// 飞行相关类型
addType
(
'
FlyCommandResult
'
,
'
CommandResult
'
);
addType
(
'
FlyPlayerID
'
,
'
PlayerID
'
);
addType
(
'
FlyMapID
'
,
'
MapID
'
);
addType
(
'
FlyMapCoordinate
'
,
'
number
'
);
addType
(
'
CheckFlag
'
,
'
0 | 1
'
);
addType
(
'
CheckEffectFlag
'
,
'
0 | 1
'
);
// 公会相关类型
addType
(
'
GuildCommandResult
'
,
'
CommandResult
'
);
addType
(
'
GuildPlayerID
'
,
'
PlayerID
'
);
addType
(
'
CopyStage
'
,
'
number
'
);
addType
(
'
BuildingType
'
,
'
number
'
);
addType
(
'
TaskType
'
,
'
number
'
);
addType
(
'
AttributeType
'
,
'
number
'
);
// 物品相关类型
addType
(
'
ItemCommandResult
'
,
'
CommandResult
'
);
addType
(
'
ItemPlayerID
'
,
'
PlayerID
'
);
// 数学相关类型
addType
(
'
Angle
'
,
'
number
'
);
addType
(
'
Coordinate
'
,
'
number
'
);
addType
(
'
Length
'
,
'
number
'
);
addType
(
'
Year
'
,
'
number
'
);
addType
(
'
Month
'
,
'
number
'
);
addType
(
'
Day
'
,
'
number
'
);
addType
(
'
Hour
'
,
'
number
'
);
addType
(
'
Minute
'
,
'
number
'
);
addType
(
'
TimeStamp
'
,
'
number
'
);
// 玩家变量相关类型
addType
(
'
PVarCommandResult
'
,
'
CommandResult
'
);
addType
(
'
PVarPlayerID
'
,
'
PlayerID
'
);
addType
(
'
VarIndex
'
,
'
number
'
);
addType
(
'
SyncType
'
,
'
number
'
);
// 特效相关类型
addType
(
'
EffectFileName
'
,
'
string
'
);
// 生产相关类型
addType
(
'
ProduceCommandResult
'
,
'
CommandResult
'
);
addType
(
'
ProducePlayerID
'
,
'
PlayerID
'
);
addType
(
'
SciencePoint
'
,
'
number
'
);
addType
(
'
TireValue
'
,
'
number
'
);
addType
(
'
ProduceSkillID
'
,
'
number
'
);
addType
(
'
ProduceSkillLevel
'
,
'
number
'
);
// PvE相关类型
addType
(
'
PvECommandResult
'
,
'
CommandResult
'
);
addType
(
'
PvEPlayerID
'
,
'
PlayerID
'
);
addType
(
'
PvEValueName
'
,
'
string
'
);
addType
(
'
PvEValueIndex
'
,
'
number
'
);
addType
(
'
PvEValue
'
,
'
number
'
);
addType
(
'
EquipID
'
,
'
number
'
);
addType
(
'
EquipCooldown
'
,
'
number
'
);
addType
(
'
PvEScriptType
'
,
'
number
'
);
addType
(
'
PvEScriptID
'
,
'
number
'
);
// 随机相关类型
addType
(
'
MinValue
'
,
'
number
'
);
addType
(
'
MaxValue
'
,
'
number
'
);
// 职业学习相关类型
addType
(
'
SPCCommandResult
'
,
'
CommandResult
'
);
addType
(
'
SPCPlayerID
'
,
'
PlayerID
'
);
addType
(
'
JumpValue
'
,
'
number
'
);
// 任务相关类型
addType
(
'
TaskState
'
,
'
number
'
);
addType
(
'
TaskMonsterIndex
'
,
'
number
'
);
addType
(
'
TaskMonsterCount
'
,
'
number
'
);
addType
(
'
TaskLoopCount
'
,
'
number
'
);
addType
(
'
TaskUpdateType
'
,
'
number
'
);
addType
(
'
TaskMaxValue
'
,
'
number
'
);
addType
(
'
TaskValue
'
,
'
number
'
);
// 称号相关类型
addType
(
'
TitleID
'
,
'
number
'
);
// 添加接口定义的函数
function
addInterface
(
name
,
body
)
{
if
(
!
addedInterfaces
.
has
(
name
))
{
mergedContent
+=
`interface
${
name
}
{\n
${
body
}
}\n\n`
;
addedInterfaces
.
add
(
name
);
}
}
// 技能相关接口
addInterface
(
'
SkillInfo
'
,
'
id: number;
\n
name: string;
\n
description: string;
\n
maxLevel: number;
'
);
addInterface
(
'
SkillLevelInfo
'
,
'
level: number;
\n
damage: number;
\n
cooldown: number;
\n
cost: number;
'
);
// 添加GetPlayerInfo函数声明
mergedContent
+=
'
/**
\n
'
;
mergedContent
+=
'
* GetPlayerInfo函数声明
\n
'
;
mergedContent
+=
'
*/
\n
'
;
mergedContent
+=
'
declare function GetPlayerInfo(playerID: number, infoType: string, param?: number): any;
\n\n
'
;
// 读取API目录中的所有文件
const
apiFiles
=
await
fs
.
readdir
(
apiSourceDir
);
const
dtsFiles
=
apiFiles
.
filter
(
file
=>
...
...
@@ -136,7 +262,7 @@ function generateDefinitionsForModule(moduleName, content, mergedContent, addedT
const
typeName
=
typeMatch
[
1
];
const
typeDefinition
=
typeMatch
[
2
];
//
检查类型是否已经添加过
//
使用addType函数添加类型
if
(
!
addedTypes
.
has
(
typeName
))
{
mergedContent
+=
`type
${
typeName
}
=
${
typeDefinition
}
;\n\n`
;
addedTypes
.
add
(
typeName
);
...
...
@@ -150,7 +276,7 @@ function generateDefinitionsForModule(moduleName, content, mergedContent, addedT
const
interfaceName
=
interfaceMatch
[
1
];
const
interfaceBody
=
interfaceMatch
[
2
];
//
检查接口是否已经添加过
//
使用addInterface函数添加接口
if
(
!
addedInterfaces
.
has
(
interfaceName
))
{
mergedContent
+=
`interface
${
interfaceName
}
{\n
${
interfaceBody
}
}\n\n`
;
addedInterfaces
.
add
(
interfaceName
);
...
...
@@ -158,10 +284,40 @@ function generateDefinitionsForModule(moduleName, content, mergedContent, addedT
}
// 使用正则表达式匹配导出函数声明
const
f
unctionRegex
=
/
\/\*\*\s
*
([\s\S]
*
?)\s
*
\*\/\s
*export
\s
+function
\s
+
(\w
+
)\s
*
\(([^
)
]
*
)\)\s
*:
\s
*
([^
;
]
+
)
;/g
;
const
exportF
unctionRegex
=
/
\/\*\*\s
*
([\s\S]
*
?)\s
*
\*\/\s
*export
\s
+function
\s
+
(\w
+
)\s
*
\(([^
)
]
*
)\)\s
*:
\s
*
([^
;
]
+
)
;/g
;
let
match
;
while
((
match
=
functionRegex
.
exec
(
content
))
!==
null
)
{
while
((
match
=
exportFunctionRegex
.
exec
(
content
))
!==
null
)
{
const
comments
=
match
[
1
].
trim
();
const
functionName
=
match
[
2
];
const
parameters
=
match
[
3
];
const
returnType
=
match
[
4
];
// 检查函数是否已经添加过
if
(
!
addedFunctions
.
has
(
functionName
))
{
// 添加函数声明
mergedContent
+=
`/**\n`
;
// 处理注释,保留每一行
const
commentLines
=
comments
.
split
(
'
\n
'
);
for
(
const
line
of
commentLines
)
{
const
trimmedLine
=
line
.
trim
().
replace
(
/^
\*\s
*/
,
''
);
if
(
trimmedLine
)
{
mergedContent
+=
` *
${
trimmedLine
}
\n`
;
}
}
mergedContent
+=
` */\n`
;
mergedContent
+=
`declare function
${
functionName
}
(
${
parameters
}
):
${
returnType
}
;\n\n`
;
addedFunctions
.
add
(
functionName
);
}
}
// 使用正则表达式匹配declare函数声明
const
declareFunctionRegex
=
/
\/\*\*\s
*
([\s\S]
*
?)\s
*
\*\/\s
*declare
\s
+function
\s
+
(\w
+
)\s
*
\(([^
)
]
*
)\)\s
*:
\s
*
([^
;
]
+
)
;/g
;
while
((
match
=
declareFunctionRegex
.
exec
(
content
))
!==
null
)
{
const
comments
=
match
[
1
].
trim
();
const
functionName
=
match
[
2
];
const
parameters
=
match
[
3
];
...
...
@@ -295,10 +451,10 @@ function generateInterfaceForModule(interfaceName, content, mergedContent, added
return
mergedContent
;
}
catch
(
error
)
{
console
.
error
(
`处理接口
文件
${
interfaceName
}
时出错:`
,
error
);
console
.
error
(
`处理接口
${
interfaceName
}
时出错:`
,
error
);
return
mergedContent
;
}
}
// 执行合并操作
mergeApiDefinitions
();
\ No newline at end of file
mergeApiDefinitions
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/sample.ts
+
16
-
5
View file @
dd2770c1
// 声明全局函数
declare
function
GetPlayerInfo
(
playerID
:
number
,
infoType
:
string
):
any
;
/// <reference path="../bin/api.d.ts" />
gameapi
.
OnSkillPreFireStart
=
function
()
{
let
playerinfo
=
GetPlayerInfo
(
0
,
"
name
"
)
// 获取玩家信息
let
playerName
=
GetPlayerInfo
(
0
,
"
name
"
);
let
playerLevel
=
GetPlayerInfo
(
0
,
"
level
"
);
let
playerHp
=
GetPlayerInfo
(
0
,
"
hp
"
);
// 使用其他API
let
randomValue
=
RandomNumber
(
1
,
100
);
// 条件判断
if
(
Number
(
playerHp
)
>
0
)
{
// 记录日志
console
.
log
(
`玩家
${
playerName
}
,等级
${
playerLevel
}
,随机值:
${
randomValue
}
`
);
}
// 原有代码
let
a
=
1
&&
0
while
(
a
!=
0
){
let
b
=
1
;
if
(
b
)
a
}
}
...
...
This diff is collapsed.
Click to expand it.
tsconfig.json
0 → 100644
+
18
-
0
View file @
dd2770c1
{
"compilerOptions"
:
{
"target"
:
"es2016"
,
"module"
:
"commonjs"
,
"esModuleInterop"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"strict"
:
true
,
"skipLibCheck"
:
true
,
"typeRoots"
:
[
"./node_modules/@types"
,
"./bin"
]
},
"include"
:
[
"src/**/*"
,
"bin/api.d.ts"
]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets