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>

View File

@ -18,6 +18,8 @@ control.prototype._init = function () {
this.replayActions = [];
this.weathers = {};
this.resizes = [];
this.needUpdate = false;
this.noAutoEvents = true;
// --- 注册系统的animationFrame
this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime);
this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave);
@ -27,6 +29,7 @@ control.prototype._init = function () {
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
this.registerAnimationFrame("tip", true, this._animateFrame_tip);
this.registerAnimationFrame("parallelDo", false, this._animationFrame_parallelDo);
this.registerAnimationFrame("updateStatusBar", true, this.updateStatusBar_update);
// --- 注册系统的天气
this.registerWeather("rain", this._weather_rain, this._animationFrame_weather_rain);
this.registerWeather("snow", this._weather_snow, this._animationFrame_weather_snow);
@ -1174,9 +1177,11 @@ control.prototype._checkBlock_ambush = function (ambush) {
actions.push({ "type": "waitAsync" });
// 强制战斗
ambush.forEach(function (t) {
actions.push({"type": "function", "function": "function() { "+
actions.push({
"type": "function", "function": "function() { " +
"core.battle('" + t[2] + "', " + t[0] + "," + t[1] + ", true, core.doAction); " +
"}", "async": true});
"}", "async": true
});
});
core.insertAction(actions);
}
@ -1653,11 +1658,13 @@ control.prototype._replay_save = function () {
if (core.status.replay.steps % 40 == 1) {
if (core.status.replay.save.length == 30)
core.status.replay.save.shift();
core.status.replay.save.push({"data": core.saveData(), "replay": {
core.status.replay.save.push({
"data": core.saveData(), "replay": {
"totalList": core.cloneArray(core.status.replay.totalList),
"toReplay": core.cloneArray(core.status.replay.toReplay),
"steps": core.status.replay.steps
}});
}
});
}
}
@ -3041,11 +3048,19 @@ control.prototype.clearStatusBar = function() {
////// 更新状态栏 //////
control.prototype.updateStatusBar = function (doNotCheckAutoEvents) {
this.needUpdate = true;
if (!doNotCheckAutoEvents) this.noAutoEvents = false;
}
control.prototype.updateStatusBar_update = function () {
if (!core.control.needUpdate) return;
if (!core.isPlaying() || core.hasFlag('__statistics__')) return;
this.controldata.updateStatusBar();
if (!doNotCheckAutoEvents) core.checkAutoEvents();
this._updateStatusBar_setToolboxIcon();
core.control.updateStatusBar();
if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon();
core.clearRouteFolding();
core.control.needUpdate = false;
core.control.noAutoEvents = true;
}
control.prototype._updateStatusBar_setToolboxIcon = function () {

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ ui.prototype._init = function () {
////////////////// 地图设置
ui.prototype.getContextByName = function (name) {
if (name instanceof HTMLCanvasElement) return name.getContext('2d');
var canvas = name;
if (typeof name == 'string') {
if (core.canvas[name])
@ -1255,9 +1256,11 @@ ui.prototype._drawTextContent_drawChar = function (tempCtx, content, config, ch)
// 输出
var left = config.offsetX, top = config.offsetY + config.topMargin;
core.fillText(tempCtx, ch, left, top);
config.blocks.push({left: config.offsetX, top: config.offsetY,
config.blocks.push({
left: config.offsetX, top: config.offsetY,
width: charwidth, height: config.currfont + config.lineMargin,
line: config.line, marginLeft: 0});
line: config.line, marginLeft: 0
});
config.offsetX += charwidth;
return true;
}
@ -1367,9 +1370,11 @@ ui.prototype._drawTextContent_drawIcon = function (tempCtx, content, config) {
// 绘制到画布上
core.drawImage(tempCtx, image, 0, 32 * icon, 32, 32, left, top, width, width);
config.blocks.push({left: left, top: config.offsetY,
config.blocks.push({
left: left, top: config.offsetY,
width: width, height: width + config.lineMargin,
line: config.line, marginLeft: 0});
line: config.line, marginLeft: 0
});
config.offsetX += width + 6;
config.index = index2 + 1;
@ -2491,8 +2496,10 @@ ui.prototype._drawBookDetail_drawContent = function (enemy, content, pos) {
core.fillText('data', enemy.name, pos.content_left, pos.top + 30, core.status.globalAttribute.selectColor, this._buildFont(22, true));
var content_top = pos.top + 44;
this.drawTextContent('data', content, {left: pos.content_left, top: content_top, maxWidth: pos.validWidth,
fontSize: 16, lineHeight: 24});
this.drawTextContent('data', content, {
left: pos.content_left, top: content_top, maxWidth: pos.validWidth,
fontSize: 16, lineHeight: 24
});
}
////// 绘制楼层传送器 //////
@ -2638,8 +2645,10 @@ ui.prototype._drawViewMaps_buildData = function (index, x, y) {
x = core.clamp(x, this.HSIZE, mw - this.HSIZE - 1);
y = core.clamp(y, this.HSIZE, mh - this.HSIZE - 1);
core.status.event.data = {index: index, x: x, y: y, floorId: floorId, mw: mw, mh: mh,
damage: damage, all: all };
core.status.event.data = {
index: index, x: x, y: y, floorId: floorId, mw: mw, mh: mh,
damage: damage, all: all
};
return core.status.event.data;
}
@ -2833,8 +2842,10 @@ ui.prototype._drawEquipbox_getInfo = function (index) {
}
core.status.event.selection = index;
core.status.event.data.selectId = selectId;
return { index: index, selectId: selectId, page: page, totalPage: totalPage, allEquips: allEquips,
equipLength: equipLength, equipEquipment: equipEquipment, ownEquipment: ownEquipment};
return {
index: index, selectId: selectId, page: page, totalPage: totalPage, allEquips: allEquips,
equipLength: equipLength, equipEquipment: equipEquipment, ownEquipment: ownEquipment
};
}
ui.prototype._drawEquipbox_description = function (info, max_height) {

View File

@ -565,7 +565,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 已经计算过的光环怪ID列表用于判定叠加
var usedEnemyIds = {};
// 检查光环和支援的缓存
var index = x != null && y != null ? (x + "," + y) : "floor";
var index = x != null && y != null ? (x + "," + y) : floorId;
if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {};
var cache = core.status.checkBlock.cache[index];
if (!cache) {
@ -1037,7 +1037,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
'floorId': core.status.floorId,
'hero': core.clone(core.status.hero),
'hard': core.status.hard,
'maps': core.maps.saveMap(),
'maps': core.clone(core.maps.saveMap()),
'route': core.encodeRoute(core.status.route),
'values': values,
'version': core.firstData.version,

148
runtime.d.ts vendored
View File

@ -8,6 +8,8 @@ type move = 'forward' | direction
type loc = { direction: direction, x: number, y: number }
type rgbarray = [number, number, number, number]
type Events = MotaAction[] | string
type Block = {
x: number,
y: number,
@ -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 = {
@ -150,8 +198,42 @@ 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
@ -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
@ -406,7 +466,7 @@ declare class control {
nearHero(x: number, y: number, n?: number): boolean
/**
*
* 使使core.updateStatusBar()
* @example core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)
* @param floorId id
* @param ctx
@ -445,10 +505,10 @@ declare class control {
* @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
@ -457,7 +517,7 @@ 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)
@ -465,14 +525,14 @@ declare class control {
* @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
/**
*
@ -556,7 +616,7 @@ declare class control {
* @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
@ -581,7 +641,7 @@ 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__
@ -910,7 +970,7 @@ 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
/**
*
@ -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