kill bug & new function

This commit is contained in:
unamed 2022-02-01 23:35:24 +08:00
parent 4a801cbc85
commit 144ef9755e
6 changed files with 2657 additions and 2574 deletions

View File

@ -189,7 +189,6 @@
</div>
</div>
<!-- injection -->
<script src='libs/thirdparty/browser-polyfill.min.js'></script>
<script src='libs/thirdparty/lz-string.min.js'></script>
<script src='libs/thirdparty/priority-queue.min.js'></script>
<script src='libs/thirdparty/localforage.min.js'></script>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

368
runtime.d.ts vendored
View File

@ -8,14 +8,16 @@ type move = 'forward' | direction
type loc = { direction: direction, x: number, y: number }
type rgbarray = [number, number, number, number]
type Block = {
x: number,
y: number,
id: number,
event: {
cls: string,
id: string,
[key: string]: any
type Events = MotaAction[] | string
type Block = {
x: number,
y: number,
id: number,
event: {
cls: string,
id: string,
[key: string]: any
}
}
@ -45,7 +47,53 @@ type Floor = {
}
type ResolvedMap = {
floorId: string
afterBattle: { [x: string]: Events }
afterOpenDoor: { [x: string]: Events }
afterGetItem: { [x: string]: Events }
autoEvent: Event
beforeBattle: { [x: string]: Events }
canFlyFrom: boolean
canFltTo: boolean
canUseQuickShop: boolean
cannotMove: Object
cannotMoveIn: Object
cannotViewMap: boolean
changeFloor: {
[x: string]: {
floorId: ':before' | ':after' | ':now' | string
loc?: [number, number]
stair?: 'upFloor' | 'downFloor' | ':symmetry' | ':symmetry_x' | ':symmetry_y' | 'flyPoint'
direction?: 'left' | 'right' | 'up' | 'down' | ':left' | ':right' | ':back' | ':hero' | ':backhero'
time?: number
ignoreChangeFloor?: boolean
}
}
defaultGround: string
bgm: string | Array<string>
bgmap: number[][]
/** 事件层 */
map: number[][]
fgmap: number[][]
width: number
height: number
images: Array<{
canvas: 'bg' | 'auto' | 'fg'
name: string
x: number
y: number
reverse?: ':x' | ':y' | ':o'
disable?: boolean
sx?: number
sy?: number
w?: number
h?: number
frame?: numer
}>
name: string
ratio: number
title: string
weather: [string, number]
}
type Enemy = {
@ -68,12 +116,12 @@ type Item = {
}
type Save = {
}
type MotaAction = {
type: string,
[key: string]: any
type MotaAction = {
type: string,
[key: string]: any
} | string
type SystemFlags = {
@ -87,7 +135,7 @@ type SystemFlags = {
}
type event = { type: string, [key: string]: any }
type step = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'
type HeroStatus = {
@ -150,12 +198,46 @@ type gameStatus = {
fgmaps: { [key: string]: number[][] }
mapBlockObjs: { [key: string]: any }
/** 显伤伤害 */
checkBlock: {}
damage: {}
checkBlock: {
ambush: { [x: string]: [number, number, string, direction] }
repulse: { [x: string]: [number, number, string, direction] }
damage: { [x: string]: number }
needCache: boolean
type: { [x: string]: { [x: string]: boolean } }
cache: {
[s: string]: {
hp_buff: number
atk_buff: number
def_buff: number
guards: [number, number, string]
}
}
}
damage: {
posX: number
posY: number
data: Array<{
[x: string]: {
text: string
px: number
py: number
color: string | Array<number>
}
}>
extraData: Array<{
[x: string]: {
text: string
px: number
py: number
color: string | Array<number>
alpha: number
}
}>
}
lockControl: boolean
/** 勇士移动状态 */
/** 勇士移动状态 */
heroMoving: number
heroStop: boolean
@ -182,13 +264,13 @@ type gameStatus = {
ctrlDown: boolean
// 路线&回放
route: [],
route: string[],
replay: {
replaying: boolean
pausing: boolean
/** 正在某段动画中 */animate: boolean
toReplay: []
totalList: []
toReplay: string[]
totalList: string[]
speed: number
steps: number
save: []
@ -197,13 +279,13 @@ type gameStatus = {
// event事件
shops: {}
event: {
id: null
data: null
selection: null
ui: null
interval: null
id: string
data: any
selection: any
ui: any
interval: number
}
autoEvents: []
autoEvents: Events
textAttribute: {
position: string
offset: number
@ -253,28 +335,6 @@ declare class control {
*/
updateStatusBar(doNotCheckAutoEvents?: boolean): void
/**
* flag
* @example core.setFlag('xyz', 2) // 设置变量xyz为2
* @param name
* @param value
*/
setFlag(name: string, value: any): void
/**
* flag
* @example core.getFlag('point', 2) // 获得变量point的值如果该变量从未定义过则返回2
* @param name
* @param defaultValue
* @returns
*/
getFlag(name: string, defaultValue: any): any
/**
* 0 core.getFlag('xyz', 0)!=0
*/
hasFlag(name: string): boolean
/** 删除某个flag/变量 */
removeFlag(name: string): void
@ -304,7 +364,7 @@ declare class control {
/** 回放下一个操作 */
replay(): void
/**
*
* @example core.showStartAnimate(); // 重启游戏但不重置bgm
@ -312,14 +372,14 @@ declare class control {
* @param callback
*/
showStartAnimate(noAnimate?: boolean, callback?: () => void): void
/**
*
* @example core.hideStartAnimate(core.startGame); // 淡出标题画面并开始新游戏,跳过难度选择
* @param callback
*/
hideStartAnimate(callback?: () => void): void
/**
*
* @example core.setAutomaticRoute(0, 0, [{direction: "right", x: 4, y: 9}, {direction: "right", x: 5, y: 9}, {direction: "right", x: 6, y: 9}, {direction: "up", x: 6, y: 8}]);
@ -328,21 +388,21 @@ declare class control {
* @param stepPostfix
*/
setAutomaticRoute(destX: number, destY: number, stepPostfix: Array<{ direction: direction, x: number, y: number }>): void
/**
*
* @example core.setAutoHeroMove([{direction: "up", step: 1}, {direction: "left", step: 3}, {direction: "right", step: 3}, {direction: "up", step: 9}]); // 上左左左右右右上9
* @param steps
*/
setAutoHeroMove(steps: Array<{ direction: direction, step: number }>): void
/**
*
* @example core.moveAction(core.doAction); // 尝试前进一步然后继续事件处理。常用于在事件流中让主角像自由行动时一样前进一步可以照常触发moveOneStep跑毒和计步和面前的事件包括但不限于阻激夹域捕
* @param callback
*/
moveAction(callback?: () => void): void
/**
*
* @example core.moveHero(); // 连续前进
@ -350,21 +410,21 @@ declare class control {
* @param callback
*/
moveHero(direction?: direction, callback?: () => void): void
/**
*
* @example core.waitHeroToStop(core.vibrate); // 等待主角停下然后视野左右抖动1秒
* @param callback
*/
waitHeroToStop(callback?: () => void): void
/**
*
* @example core.turnHero(); // 主角顺时针旋转90°即单击主角或按下Z键的效果
* @param direction up, down, left, right, :left, :right, :back
*/
turnHero(direction?: direction): void
/**
* //
* @example core.tryMoveDirectly(6, 0); // 尝试瞬移到地图顶部的正中央以样板0层为例实际效果是瞬移到了上楼梯下面一格然后向上走一步并触发上楼事件
@ -372,7 +432,7 @@ declare class control {
* @param destY
*/
tryMoveDirectly(destX: number, destY: number): void
/**
*
* @example core.drawHero(); // 原地绘制主角的静止帧
@ -381,21 +441,21 @@ declare class control {
* @param frame
*/
drawHero(status?: 'stop' | 'leftFoot' | 'rightFoot', offset?: number, frame?: number): void
/**
* n格的横坐标
* @example core.closeDoor(core.nextX(), core.nextY(), 'yellowDoor', core.turnHero); // 在主角面前关上一扇黄门然后主角顺时针旋转90°
* @param n 01
*/
nextX(n?: number): number
/**
* n格的纵坐标
* @example core.jumpHero(core.nextX(2), core.nextY(2)); // 主角向前跃过一格,即跳跃靴道具的使用效果
* @param n 01
*/
nextY(n?: number): number
/**
* 齿()
* @example core.nearHero(6, 6, 6); // 判定主角是否身处点66的半径为6的锯齿领域
@ -404,15 +464,15 @@ declare class control {
* @param n 1
*/
nearHero(x: number, y: number, n?: number): boolean
/**
*
* 使使core.updateStatusBar()
* @example core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)
* @param floorId id
* @param ctx
*/
updateDamage(floorId?: string, ctx?: CanvasRenderingContext2D): void
/** 仅重绘地图显伤 */
drawDamage(ctx?: CanvasRenderingContext2D): void
@ -423,7 +483,7 @@ declare class control {
* @param value
*/
setStatus<K extends keyof HeroStatus>(name: K, value: HeroStatus[K]): void
/**
* core.setStatus(name, core.getStatus(name) + value)
* @example core.addStatus('name', '酱'); // 在主角的名字后加一个“酱”字
@ -431,7 +491,7 @@ declare class control {
* @param value
*/
addStatus<K extends keyof HeroStatus>(name: K, value: HeroStatus[K]): void
/**
*
* @example core.getStatus('loc'); // 读取主角的坐标和朝向
@ -439,17 +499,17 @@ declare class control {
* @returns
*/
getStatus<K extends keyof HeroStatus>(name: K): HeroStatus[K]
/**
*
* @example core.getRealStatus('atk'); // 计算主角的攻击力,包括百分比修正。战斗使用的就是这个值
* @param name NaN
*/
getRealStatus(name: string): any
getRealStatus<K extends keyof HeroStatus>(name: K): HeroStatus[K]
/** 获得某个状态的名字 */
getStatusLabel(name: string): string
getStatusLabel<K extends keyof HeroStatus>(name: K): string
/**
* 1
* flag: '__'+name+'_buff__'
@ -457,30 +517,30 @@ declare class control {
* @param name NaN
* @param value 1
*/
setBuff(name: string, value?: number): void
setBuff<K extends keyof HeroStatus>(name: K, value?: HeroStatus[K]): void
/**
* core.setBuff(name, core.getBuff(name) + value)
* @example core.addBuff('atk', -0.1); // 主角获得一层“攻击力减一成”的负面效果
* @param name NaN
* @param value
*/
addBuff(name: string, value: number): void
addBuff<K extends keyof HeroStatus>(name: K, value: HeroStatus[K]): void
/**
* 1
* @example core.getBuff('atk'); // 主角当前能发挥出多大比例的攻击力
* @param name
*/
getBuff(name: string): number
getBuff<K extends keyof HeroStatus>(name: HeroStatus[K]): number
/**
*
* @param action 'get''remove'
* @param type
*/
triggerDebuff(action: string, type: string|string[]): void
triggerDebuff(action: string, type: string | string[]): void
/**
*
* 使使
@ -492,7 +552,7 @@ declare class control {
*/
setHeroLoc(name: 'x' | 'y', value: number, noGather?: boolean): void
setHeroLoc(name: 'direction', value: direction, noGather?: boolean): void
/**
* /
* @example core.getHeroLoc(); // 读取主角的位置和朝向
@ -502,7 +562,7 @@ declare class control {
getHeroLoc(): { x: number, y: number, direction: direction }
getHeroLoc(name: 'x' | 'y'): number
getHeroLoc(name: 'direction'): direction
/**
*
* @example core.getLvName(); // 获取主角当前级别的名称,如“下级佣兵”
@ -510,13 +570,13 @@ declare class control {
* @returns
*/
getLvName(lv?: number): string | number
/**
*
*
* null
*/
getNextLvUpNeed() : number
getNextLvUpNeed(): number
/**
* flag变量
@ -525,7 +585,7 @@ declare class control {
* @param value null视为删除
*/
setFlag(name: string, value?: any): void
/**
* flag变量 core.setFlag(name, core.getFlag(name, 0) + value)
* @example core.addFlag('hatred', 1); // 增加1点仇恨值
@ -533,7 +593,7 @@ declare class control {
* @param value
*/
addFlag(name: string, value: number | string): void
/**
* flag变量
* @param name
@ -541,7 +601,7 @@ declare class control {
* @returns flags[name] ?? defaultValue
*/
getFlag(name: string, defaultValue?: any): any
/**
* flag变量是否存在且不为false0''nullundefined和NaN
* @example core.hasFlag('poison'); // 判断主角当前是否中毒
@ -549,20 +609,20 @@ declare class control {
* @returns !!core.getFlag(name)
*/
hasFlag(name: string): boolean
/**
* 使core.events._action_setWeather()
* @example core.setWeather('fog', 10); // 设置十级大雾天
* @param type
* @param level 105
*/
setWeather(type?: 'rain' | 'snow' | 'sun' | 'fog' | 'cloud', level?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10): void
setWeather(type?: 'rain' | 'snow' | 'sun' | 'fog' | 'cloud' | string, level?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10): void
/** 注册一个天气 */
registerWeather(name: string, initFunc: (level: number) => void, frameFunc?: (timestamp: number, level: number) => void): void
/** 注销一个天气 */
unregisterWeather(name: string) : void;
unregisterWeather(name: string): void;
/**
* 使core.events._action_setCurtain()
@ -572,7 +632,7 @@ declare class control {
* @param callback core.doAction
*/
setCurtain(color?: [number, number, number, number?], time?: number, moveMode?: string, callback?: () => void): void
/**
*
* @example core.screenFlash([255, 0, 0, 1], 3); // 红屏一闪而过
@ -581,8 +641,8 @@ declare class control {
* @param times 01
* @param callback
*/
screenFlash(color: [number, number, number, number], time: number, times?: number, moveMode?: string, callback?: () => void): void
screenFlash(color: [number, number, number, number?], time: number, times?: number, moveMode?: string, callback?: () => void): void
/**
* flags.__bgm__
* @example core.playBgm('bgm.mp3', 30); // 播放bgm.mp3并跳过前半分钟
@ -596,7 +656,7 @@ declare class control {
* @param name 使
* @param needPlaying
* @param func timestamp
*/
*/
registerAnimationFrame(name: string, needPlaying: boolean, func?: (timestamp: number) => void): void
/** 注销一个animationFrame */
@ -841,7 +901,7 @@ declare class events {
* @param callback
*/
startGame(hard: string, seed: number, route: string, callback?: () => void): void
/**
*
* @example core.gameOver(); // 游戏失败
@ -850,7 +910,7 @@ declare class events {
* @param norank true表示不计入榜单
*/
gameOver(ending?: string, fromReplay?: boolean, norank?: boolean): void
/**
*
* @example core.battle('greenSlime'); // 和从天而降的绿头怪战斗(如果打得过)
@ -861,7 +921,7 @@ declare class events {
* @param callback
*/
battle(id: string, x?: number, y?: number, force?: boolean, callback?: () => void): void
/**
*
* @example core.openDoor(0, 0, true, core.jumpHero); // 打开左上角的门,需要钥匙,然后主角原地跳跃半秒
@ -871,7 +931,7 @@ declare class events {
* @param callback
*/
openDoor(x: number, y: number, needKey?: boolean, callback?: () => void): void
/**
*
* @example core.getItem('book'); // 获得敌人手册并提示
@ -882,7 +942,7 @@ declare class events {
* @param callback
*/
getItem(id: string, num?: number, x?: number, y?: number, callback?: () => void): void
/**
*
* @example core.changeFloor('MT0'); // 传送到主塔0层主角坐标和朝向不变黑屏时间取用户设置值
@ -893,14 +953,14 @@ declare class events {
* @param callback
*/
changeFloor(floorId: string, stair?: string, heroLoc?: { x?: number, y?: number, direction?: direction }, time?: number, callback?: () => void): void
/**
*
* @example core.setCurtain([0,0,0,1], undefined, null, core.doAction); // 事件中的原生脚本,配合勾选“不自动执行下一个事件”来达到此改变色调只持续到下次场景切换的效果
* @param keepUI true表示不清除UI画布和选择光标
*/
doAction(keepUI?: true): void
/**
* core.insertCommonEvent
* @example core.insertAction('一段文字'); // 插入一个显示文章
@ -910,8 +970,8 @@ declare class events {
* @param callback
* @param addToLast true表示插入到末尾
*/
insertAction(action: string | MotaAction | MotaAction[], x?: number, y?: number, callback?: () => void, addToLast?: boolean): void
insertAction(action: Events, x?: number, y?: number, callback?: () => void, addToLast?: boolean): void
/**
*
* @example core.setEnemy('greenSlime', 'def', 0); // 把绿头怪的防御设为0
@ -922,7 +982,7 @@ declare class events {
* @param prefix
*/
setEnemy<K extends keyof Enemy>(id: string, name: K, value?: Enemy[K], operator?: string, prefix?: string): void
/** 设置某个点的敌人属性 */
setEnemyOnPoint<K extends keyof Enemy>(x: number, y: number, floorId: string, name: K, value?: Enemy[K], operator?: string, prefix?: string): void
@ -941,7 +1001,7 @@ declare class events {
* @param prefix
*/
setFloorInfo<K extends keyof Floor>(name: K, values?: Floor[K] | boolean | number | string | [number, number] | [string, number?] | Array<string | [number, number, string, number?, number?]>, floorId?: string, prefix?: string): void
/**
*
* @example core.setGlobalFlag('steelDoorWithoutKey', true); // 使全塔的所有铁门都不再需要钥匙就能打开
@ -949,7 +1009,7 @@ declare class events {
* @param value !core.flags[name]
*/
setGlobalFlag(name: keyof SystemFlags, value: boolean): void
/**
*
* @example core.closeDoor(0, 0, 'yellowWall', core.jumpHero); // 在左上角关掉一堵黄墙,然后主角原地跳跃半秒
@ -959,7 +1019,7 @@ declare class events {
* @param callback
*/
closeDoor(x: number, y: number, id: string, callback?: () => void): void
/**
*
* @example core.showImage(1, core.material.images.images['winskin.png'], [0,0,128,128], [0,0,416,416], 0.5, 1000); // 裁剪winskin.png的最左边128×128px放大到铺满整个视野1秒内淡入到50%透明编号为1
@ -972,7 +1032,7 @@ declare class events {
* @param callback
*/
showImage(code: number, image: string | HTMLImageElement, sloc?: Array<number>, loc?: Array<number>, opacityVal?: number, time?: number, callback?: () => void): void
/**
*
* @example core.hideImage(1, 1000, core.jumpHero); // 1秒内淡出1号图片然后主角原地跳跃半秒
@ -981,7 +1041,7 @@ declare class events {
* @param callback
*/
hideImage(code: number, time?: number, callback?: () => void): void
/**
* /
* @example core.moveImage(1, null, 0.5); // 1秒内把1号图片变为50%透明
@ -1016,7 +1076,7 @@ declare class events {
* @param y
*/
showGif(name?: string, x?: number, y?: number): void
/**
* bgm的音量
* @example core.setVolume(0, 100, core.jumpHero); // 0.1秒内淡出bgm然后主角原地跳跃半秒
@ -1025,7 +1085,7 @@ declare class events {
* @param callback
*/
setVolume(value: number, time?: number, callback?: () => void): void
/**
*
* @example core.vibrate(); // 视野左右抖动1秒
@ -1045,7 +1105,7 @@ declare class events {
* @param callback
*/
eventMoveHero(steps: step[], time?: number, callback?: () => void): void
/**
* ex和ey为目标点的坐标null表示原地跳跃time为总跳跃时间
* @example core.jumpHero(); // 主角原地跳跃半秒
@ -1055,7 +1115,7 @@ declare class events {
* @param callback
*/
jumpHero(ex?: number, ey?: number, time?: number, callback?: () => void): void
/**
*
* @example core.setHeroIcon('npc48.png', true); // 把主角从阳光变成样板0层左下角的小姐姐但不立即刷新
@ -1063,7 +1123,7 @@ declare class events {
* @param noDraw true表示不立即刷新
*/
setHeroIcon(name: string, noDraw?: boolean): void
/**
* 使
* @example core.tryUseItem('pickaxe'); // 尝试使用破墙镐
@ -1072,7 +1132,7 @@ declare class events {
tryUseItem(itemId: string): void
/** 初始化游戏 */
resetGame(hero?: any, hard?: any, floorId?: string, maps?: any, values?: any): void
resetGame(hero?: HeroStatus, hard?: any, floorId?: string, maps?: any, values?: any): void
/** 游戏获胜事件 */
win(reason?: string, norank?: boolean, noexit?: boolean): void
@ -1468,7 +1528,7 @@ declare class maps {
* @returns project\maps.jsproject\icons.js中的
*/
getNumberById(id: string): number
/**
*
* @example core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵隐藏的图块视为0
@ -1480,7 +1540,7 @@ declare class maps {
/** 判定图块的事件层数字不存在为0 */
getMapNumber(floorId?: string, noCache?: boolean): number
/**
*
* @example core.getBgMapArray('MT0'); // 生成主塔0层的背景层矩阵使用缓存
@ -1489,7 +1549,7 @@ declare class maps {
* @returns 访[y][x]
*/
getBgMapArray(floorId?: string, noCache?: boolean): number[][]
/**
*
* @example core.getFgMapArray('MT0'); // 生成主塔0层的前景层矩阵使用缓存
@ -1498,7 +1558,7 @@ declare class maps {
* @returns 访[y][x]
*/
getFgMapArray(floorId?: string, noCache?: boolean): number[][]
/**
*
* @example core.getBgNumber(); // 判断主角脚下的背景层图块的数字
@ -1508,7 +1568,7 @@ declare class maps {
* @param true表示不使用缓存而强制重算
*/
getBgNumber(x?: number, y?: number, floorId?: string, noCache?: boolean): number
/**
*
* @example core.getFgNumber(); // 判断主角脚下的前景层图块的数字
@ -1518,7 +1578,7 @@ declare class maps {
* @param true表示不使用缓存而强制重算
*/
getFgNumber(x?: number, y?: number, floorId?: string, noCache?: boolean): number
/**
*
* @example core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动
@ -1526,7 +1586,7 @@ declare class maps {
* @returns
*/
generateMovableArray(floorId?: string): Array<Array<Array<direction>>>
/**
*
* @exmaple core.canMoveHero(); // 判断主角是否可以前进一步
@ -1537,7 +1597,7 @@ declare class maps {
* @returns true表示可移动false表示不可移动
*/
canMoveHero(x?: number, y?: number, direction?: direction, floorId?: string): boolean
/**
*
* @example core.canMoveDirectly(0, 0); // 能否瞬移到地图左上角
@ -1546,7 +1606,7 @@ declare class maps {
* @returns -1
*/
canMoveDirectly(destX: number, destY: number): number
/**
*
* @example core.automaticRoute(0, 0); // 自动寻路到地图左上角
@ -1555,7 +1615,7 @@ declare class maps {
* @returns loc属性组成的一维数组
*/
automaticRoute(destX: number, destY: number): Array<{ direction: direction, x: number, y: number }>
/**
*
* @example core.drawMap(); // 重绘当前地图,常用于更改贴图后或自动元件的刷新
@ -1563,7 +1623,7 @@ declare class maps {
* @param callback
*/
drawMap(floorId?: string, callback?: () => void): void
/**
*
* @example core.drawBg(); // 绘制当前地图的背景层
@ -1571,7 +1631,7 @@ declare class maps {
* @param ctx ctx
*/
drawBg(floorId?: string, ctx?: CanvasRenderingContext2D): void
/**
*
* @example core.drawEvents(); // 绘制当前地图的事件层
@ -1580,7 +1640,7 @@ declare class maps {
* @param ctx ctx
*/
drawEvents(floorId?: string, blocks?: Block[], ctx?: CanvasRenderingContext2D): void
/**
*
* @example core.drawFg(); // 绘制当前地图的前景层
@ -1588,7 +1648,7 @@ declare class maps {
* @param ctx ctx
*/
drawFg(floorId?: string, ctx?: CanvasRenderingContext2D): void
/**
*
* @example core.drawThumbnail(); // 绘制当前地图的缩略图
@ -1597,7 +1657,7 @@ declare class maps {
* @param options flags用于存读档
*/
drawThumbnail(floorId?: string, blocks?: Block[], options?: object): void
/**
* cannotIn属性
* @example core.noPass(0, 0); // 判断地图左上角能否被踏入
@ -1607,7 +1667,7 @@ declare class maps {
* @returns true表示可踏入
*/
noPass(x: number, y: number, floorId?: string): boolean
/**
* id
* @example if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门
@ -1618,7 +1678,7 @@ declare class maps {
* @returns idnull
*/
getBlockId(x: number, y: number, floorId?: string, showDisable?: boolean): string | null
/** 判定某个点的图块数字空图块为0 */
getBlockNumber(x: number, y: number, floorId?: string, showDisable?: boolean): number
@ -1632,7 +1692,7 @@ declare class maps {
* @returns npcnpc
*/
getBlockCls(x: number, y: number, floorId?: string, showDisable?: boolean): 'terrains' | 'animates' | 'enemys' | 'enemy48' | 'items' | 'npcs' | 'npc48' | 'autotile' | 'tileset' | null
/**
* ,
* @example core.searchBlock('*Door'); // 搜索当前地图的所有门
@ -1641,8 +1701,8 @@ declare class maps {
* @param showDisable true表示计入
* @returns
*/
searchBlock(id: string, floorId?: string|Array<string>, showDisable?: boolean): Array<{ floorId: string, index: number, x: number, y: number, block: Block }>
searchBlock(id: string, floorId?: string | Array<string>, showDisable?: boolean): Array<{ floorId: string, index: number, x: number, y: number, block: Block }>
/**
*
* @example core.searchBlockWithFilter(function (block) { return block.event.id.endsWith('Door'); }); // 搜索当前地图的所有门
@ -1651,7 +1711,7 @@ declare class maps {
* @param showDisable true表示计入
* @returns
*/
searchBlockWithFilter(blockFilter: (Block) => boolean, floorId?: string|Array<string>, showDisable?: boolean): Array<{ floorId: string, index: number, x: number, y: number, block: Block }>
searchBlockWithFilter(blockFilter: (Block) => boolean, floorId?: string | Array<string>, showDisable?: boolean): Array<{ floorId: string, index: number, x: number, y: number, block: Block }>
/**
* /
@ -1661,7 +1721,7 @@ declare class maps {
* @param floorId id
*/
showBlock(x: number, y: number, floorId?: string): void
/**
*
* @example core.hideBlock(0, 0); // 隐藏地图左上角的图块
@ -1670,7 +1730,7 @@ declare class maps {
* @param floorId id
*/
hideBlock(x: number, y: number, floorId?: string): void
/**
*
* @example core.removeBlock(0, 0); // 尝试删除地图左上角的图块
@ -1679,7 +1739,7 @@ declare class maps {
* @param floorId id
*/
removeBlock(x: number, y: number, floorId?: string): void
/**
* /
* @example core.maps._triggerBgFgMap('show', 'fg', [0, 0]); // 显示地图左上角的前景层图块
@ -1690,7 +1750,7 @@ declare class maps {
* @param callback
*/
//_triggerBgFgMap(type: 'show' | 'hide', name: 'bg' | 'fg', loc: [number, number] | Array<[number, number]>, floorId?: string, callback?: () => void): void
/**
*
* @example core.maps._triggerFloorImage('show', [0, 0]); // 显示当前地图以左上角为左上角的贴图
@ -1700,7 +1760,7 @@ declare class maps {
* @param callback
*/
//_triggerFloorImage(type: 'show' | 'hide', loc: [number, number] | Array<[number, number]>, floorId?: string, callback?: () => void): void
/**
*
* @example core.setBlock(1, 0, 0); // 把地图左上角变成黄墙
@ -1710,7 +1770,7 @@ declare class maps {
* @param floorId id
*/
setBlock(number: number | string, x: number, y: number, floorId?: string): void
/**
*
* @example core.replaceBlock(21, 22, core.floorIds); // 把游戏中地上当前所有的黄钥匙都变成蓝钥匙
@ -1719,7 +1779,7 @@ declare class maps {
* @param floorId id或其数组
*/
replaceBlock(fromNumber: number, toNumber: number, floorId?: string | Array<string>): void
/**
*
* @example core.setBgFgBlock('bg', 167, 6, 6); // 把当前地图背景层的中心块改为滑冰
@ -1730,7 +1790,7 @@ declare class maps {
* @param floorId id
*/
setBgFgBlock(name: 'bg' | 'fg', number: number | string, x: number, y: number, floorId?: string): void
/**
*
* @example core.moveBlock(0, 0, ['down']); // 令地图左上角的图块下移一格,用时半秒,再花半秒淡出
@ -1742,7 +1802,7 @@ declare class maps {
* @param callback
*/
moveBlock(x: number, y: number, steps: step[], time?: number, keep?: boolean, callback?: () => void): void
/**
* V2.7
* @example core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出
@ -1755,7 +1815,7 @@ declare class maps {
* @param callback
*/
jumpBlock(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: boolean, callback?: () => void): void
/**
* 使使core.drawHeroAnimate(name, callback)
* @example core.drawAnimate('attack', core.nextX(), core.nextY(), false, core.vibrate); // 在主角面前一格播放普攻动画动画停止后视野左右抖动1秒
@ -1781,10 +1841,10 @@ declare class maps {
* @param id drawAnimate或drawHeroAnimate返回值
* @param doCallback
*/
stopAnimate(id?: number, doCallback?: boolean): void
stopAnimate(id?: number, doCallback?: boolean): void
/** 获得当前正在播放的所有指定动画的id列表 */
getPlayingAnimates(name?: string) : Array<number>
getPlayingAnimates(name?: string): Array<number>
/** 加载某个楼层(从剧本或存档中) */
loadFloor(floorId?: string, map?: any): any
@ -1910,7 +1970,7 @@ declare class maps {
/** @file loader.js 主要负责资源的加载 */
declare class loader {
/** 加载一系列图片 */
loadImages(dir: any, names: any, toSave: any, callback?: () => any) : any
loadImages(dir: any, names: any, toSave: any, callback?: () => any): any
/** 加载某一张图片 */
loadImage(dir: any, imgName?: any, callback?: () => any): any
@ -2055,7 +2115,7 @@ declare class items {
* @param beComparedEquipId id
* @returns 0
*/
compareEquipment(compareEquipId: string, beComparedEquipId: string): { [key: string]: number}
compareEquipment(compareEquipId: string, beComparedEquipId: string): { [key: string]: number }
/**
*
@ -2090,7 +2150,7 @@ declare class items {
* @param operator +=
* @param prefix
*/
setEquip(equipId: string, valueType: string, name: string, value: any, operator?: string, prefix?: string): void
setEquip(equipId: string, valueType: string, name: string, value: any, operator?: string, prefix?: string): void
}
/** @file ui.js 主要用来进行UI窗口的绘制如对话框、怪物手册、楼传器、存读档界面等等。*/
@ -2246,7 +2306,7 @@ declare class ui {
drawUIEventSelector(code: number, background: string, x: number, y: number, w: number, h: number, z?: number): void
/** 清除一个或多个选择光标 */
clearUIEventSelector(code: number|number[]): void
clearUIEventSelector(code: number | number[]): void
/** 绘制一个确认框 */
drawConfirmBox(text: string, yesCallback?: () => void, noCallback?: () => void): void
@ -2265,7 +2325,7 @@ declare class ui {
* left, topmaxWidthcoloralign
* fontSizelineHeighttimefont
* @returns
*/
*/
drawTextContent(ctx: string | CanvasRenderingContext2D, content: string, config: any): any
/** 获得某段文字的预计绘制高度;参见 drawTextContent */
@ -2412,7 +2472,7 @@ declare class utils {
clone<T>(data?: T, filter?: (name: string, value: any) => boolean, recursion?: boolean): T
/** 深拷贝一个1D或2D的数组 */
cloneArray(data?: Array<number>|Array<Array<number>>): Array<number>|Array<Array<number>>
cloneArray(data?: Array<number> | Array<Array<number>>): Array<number> | Array<Array<number>>
/**
*
@ -2557,7 +2617,7 @@ declare class utils {
* @exmaple 1 + core.rand2(6); // 随机生成一个小于7的正整数模拟骰子的效果
* @param num 02147483648
* @returns [0, num)
*/
*/
rand2(num?: number): number
/**
@ -2601,7 +2661,7 @@ declare class utils {
*
*/
copy(data: string): void
/**
* HTTP请求 []
* @param type