mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-10-29 02:12:58 +08:00
fix: 游戏结束
This commit is contained in:
parent
90671fa6dd
commit
991d94568b
@ -590,6 +590,10 @@ export class HeroMover extends ObjectMoverBase {
|
||||
// 中毒处理
|
||||
if (core.hasFlag('poison')) {
|
||||
core.status.hero.hp -= core.values.poisonDamage;
|
||||
if (core.status.hero.hp <= 0) {
|
||||
core.status.hero.hp = 0;
|
||||
core.events.lose();
|
||||
}
|
||||
core.updateStatusBar();
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,6 @@ interface PortResponse {
|
||||
core.status.maps[data].enemy?.calRealAttribute();
|
||||
core.updateStatusBar(true, true);
|
||||
}
|
||||
Mota.require('@user/client-modules').Shadow.update(true);
|
||||
const Binder = Mota.require(
|
||||
'@user/client-modules'
|
||||
).LayerGroupFloorBinder;
|
||||
|
||||
@ -388,12 +388,6 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
|
||||
|
||||
core.status.holdingKeys = [];
|
||||
switch (core.status.event.id) {
|
||||
case 'text':
|
||||
ok() && core.drawText();
|
||||
break;
|
||||
case 'confirmBox':
|
||||
this._keyUpConfirmBox(keyCode);
|
||||
break;
|
||||
case 'action':
|
||||
this._keyUpAction(keyCode);
|
||||
break;
|
||||
@ -530,9 +524,6 @@ actions.prototype._sys_ondown_lockControl = function (x, y, px, py) {
|
||||
case 'action':
|
||||
this._clickAction(x, y, px, py);
|
||||
break;
|
||||
case 'text':
|
||||
core.drawText();
|
||||
break;
|
||||
case 'notes':
|
||||
this._clickNotes(x, y, px, py);
|
||||
break;
|
||||
@ -822,10 +813,6 @@ actions.prototype.keyDownCtrl = function () {
|
||||
};
|
||||
|
||||
actions.prototype._sys_keyDownCtrl = function () {
|
||||
if (core.status.event.id == 'text') {
|
||||
core.drawText();
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
core.status.event.id == 'action' &&
|
||||
core.status.event.data.type == 'text'
|
||||
@ -855,10 +842,6 @@ actions.prototype.longClick = function (x, y, px, py) {
|
||||
|
||||
actions.prototype._sys_longClick_lockControl = function (x, y, px, py) {
|
||||
if (!core.status.lockControl) return false;
|
||||
if (core.status.event.id == 'text') {
|
||||
core.drawText();
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
core.status.event.id == 'action' &&
|
||||
core.status.event.data.type == 'text'
|
||||
|
||||
@ -2214,140 +2214,20 @@ control.prototype.syncSave = function (type) {
|
||||
};
|
||||
|
||||
control.prototype._syncSave_http = function (type, saves) {
|
||||
if (!saves) return core.drawText('没有要同步的存档');
|
||||
var formData = new FormData();
|
||||
formData.append('type', 'save');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('data', LZString.compressToBase64(JSON.stringify(saves)));
|
||||
formData.append('shorten', '1');
|
||||
|
||||
core.http(
|
||||
'POST',
|
||||
'/games/sync.php',
|
||||
formData,
|
||||
function (data) {
|
||||
var response = JSON.parse(data);
|
||||
if (response.code < 0) {
|
||||
core.drawText(
|
||||
'出错啦!\n无法同步存档到服务器。\n错误原因:' +
|
||||
response.msg
|
||||
);
|
||||
} else {
|
||||
core.drawText(
|
||||
(type == 'all'
|
||||
? '所有存档'
|
||||
: '存档' + core.saves.saveIndex) +
|
||||
'同步成功!\n\n您的存档编号+密码: \r[yellow]' +
|
||||
response.code +
|
||||
response.msg +
|
||||
'\r\n\n请牢记以上信息(如截图等),在从服务器\n同步存档时使用。\n\r[yellow]另外请注意,存档同步只会保存一个月的时间。\r'
|
||||
);
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
core.drawText('出错啦!\n无法同步存档到服务器。\n错误原因:' + e);
|
||||
}
|
||||
);
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
////// 从服务器加载存档 //////
|
||||
control.prototype.syncLoad = function () {
|
||||
core.myprompt('请输入存档编号+密码', null, function (idpassword) {
|
||||
if (!idpassword) return core.ui._drawSyncSave();
|
||||
if (
|
||||
!/^\d{6}\w{4}$/.test(idpassword) &&
|
||||
!/^\d{4}\w{3}$/.test(idpassword)
|
||||
) {
|
||||
core.drawText('不合法的存档编号+密码!');
|
||||
return;
|
||||
}
|
||||
core.ui.drawWaiting('正在同步,请稍候...');
|
||||
if (idpassword.length == 7) {
|
||||
core.control._syncLoad_http(
|
||||
idpassword.substring(0, 4),
|
||||
idpassword.substring(4)
|
||||
);
|
||||
} else {
|
||||
core.control._syncLoad_http(
|
||||
idpassword.substring(0, 6),
|
||||
idpassword.substring(6)
|
||||
);
|
||||
}
|
||||
});
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
control.prototype._syncLoad_http = function (id, password) {
|
||||
var formData = new FormData();
|
||||
formData.append('type', 'load');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('id', id);
|
||||
formData.append('password', password);
|
||||
|
||||
core.http(
|
||||
'POST',
|
||||
'/games/sync.php',
|
||||
formData,
|
||||
function (data) {
|
||||
var response = JSON.parse(data);
|
||||
if (response.code == 0) {
|
||||
var msg = null;
|
||||
try {
|
||||
msg = JSON.parse(
|
||||
LZString.decompressFromBase64(response.msg)
|
||||
);
|
||||
} catch (e) {}
|
||||
if (!msg) {
|
||||
try {
|
||||
msg = JSON.parse(response.msg);
|
||||
} catch (e) {}
|
||||
}
|
||||
if (msg) {
|
||||
core.control._syncLoad_write(msg);
|
||||
} else {
|
||||
core.drawText('出错啦!\n存档解析失败!');
|
||||
}
|
||||
} else {
|
||||
core.drawText(
|
||||
'出错啦!\n无法从服务器同步存档。\n错误原因:' +
|
||||
response.msg
|
||||
);
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
core.drawText('出错啦!\n无法从服务器同步存档。\n错误原因:' + e);
|
||||
}
|
||||
);
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
control.prototype._syncLoad_write = function (data) {
|
||||
if (data instanceof Array) {
|
||||
core.status.event.selection = 1;
|
||||
core.ui.drawConfirmBox(
|
||||
'所有本地存档都将被覆盖,确认?',
|
||||
function () {
|
||||
for (var i = 1; i <= 5 * (main.savePages || 30); i++) {
|
||||
if (i <= data.length)
|
||||
core.setLocalForage('save' + i, data[i - 1]);
|
||||
else if (core.saves.ids[i])
|
||||
core.removeLocalForage('save' + i);
|
||||
}
|
||||
core.ui.closePanel();
|
||||
core.drawText('同步成功!\n你的本地所有存档均已被覆盖。');
|
||||
},
|
||||
function () {
|
||||
core.status.event.selection = 0;
|
||||
core.ui._drawSyncSave();
|
||||
},
|
||||
true
|
||||
);
|
||||
} else {
|
||||
// 只覆盖单存档
|
||||
core.setLocalForage('save' + core.saves.saveIndex, data, function () {
|
||||
core.drawText(
|
||||
'同步成功!\n单存档已覆盖至存档' + core.saves.saveIndex
|
||||
);
|
||||
});
|
||||
}
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
////// 存档到本地 //////
|
||||
@ -2744,9 +2624,7 @@ control.prototype.unlockControl = function () {
|
||||
////// 开启debug模式 //////
|
||||
control.prototype.debug = function () {
|
||||
core.setFlag('debug', true);
|
||||
core.drawText(
|
||||
'\t[调试模式开启]此模式下按住Ctrl键(或Ctrl+Shift键)可以穿墙并忽略一切事件。\n此模式下将无法上传成绩。'
|
||||
);
|
||||
core.drawTip('[调试模式开启]此模式下按住Ctrl键可以穿墙并忽略一切事件');
|
||||
};
|
||||
|
||||
control.prototype._bindRoutePush = function () {
|
||||
|
||||
@ -120,7 +120,6 @@ events.prototype._startGame_upload = function () {
|
||||
|
||||
////// 游戏获胜事件 //////
|
||||
events.prototype.win = function (reason, norank, noexit) {
|
||||
if (!noexit) core.status.gameOver = true;
|
||||
return this.eventdata.win(reason, norank, noexit);
|
||||
};
|
||||
|
||||
@ -130,7 +129,6 @@ events.prototype.lose = function (reason) {
|
||||
return core.control._replay_error(reason, function () {
|
||||
core.lose(reason);
|
||||
});
|
||||
core.status.gameOver = true;
|
||||
return this.eventdata.lose(reason);
|
||||
};
|
||||
|
||||
|
||||
@ -295,6 +295,7 @@ main.floors.sample1=
|
||||
},
|
||||
{
|
||||
"type": "hide",
|
||||
"remove": true,
|
||||
"time": 500
|
||||
}
|
||||
],
|
||||
|
||||
@ -99,19 +99,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
var replaying = core.isReplaying();
|
||||
if (replaying) core.stopReplay();
|
||||
core.waitHeroToStop(function () {
|
||||
if (!noexit) {
|
||||
core.clearMap('all'); // 清空全地图
|
||||
core.deleteAllCanvas(); // 删除所有创建的画布
|
||||
}
|
||||
reason = core.replaceText(reason);
|
||||
core.drawText(
|
||||
[
|
||||
'\t[' +
|
||||
(reason || '恭喜通关') +
|
||||
']你的分数是${status:hp}。'
|
||||
],
|
||||
function () {
|
||||
core.events.gameOver(reason || '', replaying, norank);
|
||||
core.insertAction(
|
||||
{
|
||||
type: 'text',
|
||||
text: '你的分数是' + core.status.hero.hp,
|
||||
title: reason ?? '恭喜通关'
|
||||
},
|
||||
void 0,
|
||||
void 0,
|
||||
() => {
|
||||
core.events.gameOver(reason ?? '', replaying, norank);
|
||||
if (!noexit) core.status.gameOver = true;
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -122,10 +121,17 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
var replaying = core.isReplaying();
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function () {
|
||||
core.drawText(
|
||||
['\t[' + (reason || '结局1') + ']你死了。\n如题。'],
|
||||
function () {
|
||||
core.insertAction(
|
||||
{
|
||||
type: 'text',
|
||||
text: '你死了。\n如题。',
|
||||
title: reason ?? '结局1'
|
||||
},
|
||||
void 0,
|
||||
void 0,
|
||||
() => {
|
||||
core.events.gameOver(null, replaying);
|
||||
core.status.gameOver = true;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user