Merge branch 'PR-Branch' of https://github.com/PZ157/noname into PR-Branch
This commit is contained in:
commit
f24531d42a
|
@ -8078,60 +8078,41 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
audio:2,
|
||||
trigger:{player:'phaseJieshuBegin'},
|
||||
direct:true,
|
||||
content:function(){
|
||||
'step 0'
|
||||
async content(event,trigger,player){
|
||||
var num=player.hp;
|
||||
if(!player.hasSkill('yanzhu')){
|
||||
num=player.maxHp;
|
||||
}
|
||||
player.chooseTarget([1,num],get.prompt2('xingxue')).set('ai',function(target){
|
||||
const {result:{targets,bool}}=
|
||||
await player.chooseTarget([1,num],get.prompt2('xingxue')).set('ai',function(target){
|
||||
var att=get.attitude(_status.event.player,target);
|
||||
if(target.countCards('he')) return att;
|
||||
return att/10;
|
||||
});
|
||||
'step 1'
|
||||
if(result.bool){
|
||||
player.logSkill('xingxue',result.targets);
|
||||
event.targets=result.targets;
|
||||
event.targets.sort(lib.sort.seat);
|
||||
if(bool){
|
||||
player.logSkill('xingxue',targets);
|
||||
const chooseToPutCard = async function(target){
|
||||
await target.draw();
|
||||
if(target.countCards('he')){
|
||||
const {result:{cards,bool}} =
|
||||
await target.chooseCard('选择一张牌置于牌堆顶','he',true);
|
||||
if(bool){
|
||||
await target.lose(cards,ui.cardPile,'insert');
|
||||
}
|
||||
game.broadcastAll(function(player){
|
||||
var cardx=ui.create.card();
|
||||
cardx.classList.add('infohidden');
|
||||
cardx.classList.add('infoflip');
|
||||
player.$throw(cardx,1000,'nobroadcast');
|
||||
},target);
|
||||
if(player == game.me){
|
||||
game.delay(0.5);
|
||||
}
|
||||
}
|
||||
};
|
||||
await game.doAsyncInOrder(targets,chooseToPutCard);
|
||||
}
|
||||
else{
|
||||
event.finish();
|
||||
}
|
||||
'step 2'
|
||||
if(event.targets.length){
|
||||
var target=event.targets.shift();
|
||||
target.draw();
|
||||
event.current=target;
|
||||
}
|
||||
else{
|
||||
event.finish();
|
||||
}
|
||||
'step 3'
|
||||
if(event.current&&event.current.countCards('he')){
|
||||
event.current.chooseCard('选择一张牌置于牌堆顶','he',true);
|
||||
}
|
||||
else{
|
||||
event.goto(2);
|
||||
}
|
||||
'step 4'
|
||||
if(result&&result.cards){
|
||||
event.card=result.cards[0];
|
||||
event.current.lose(result.cards,ui.cardPile,'insert');
|
||||
game.broadcastAll(function(player){
|
||||
var cardx=ui.create.card();
|
||||
cardx.classList.add('infohidden');
|
||||
cardx.classList.add('infoflip');
|
||||
player.$throw(cardx,1000,'nobroadcast');
|
||||
},event.current);
|
||||
}
|
||||
else{
|
||||
event.card=null;
|
||||
}
|
||||
'step 5'
|
||||
if(event.current==game.me) game.delay(0.5);
|
||||
event.goto(2);
|
||||
}
|
||||
},
|
||||
},
|
||||
yanzhu:{
|
||||
audio:2,
|
||||
|
|
|
@ -8434,6 +8434,21 @@ export class Game extends Uninstantable {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 此方法用于对所有targets按顺序执行一个async函数。
|
||||
*
|
||||
* @param { Player[] } targets 需要执行async方法的目标
|
||||
* @param { AsyncFunction } asyncFunc 需要执行的async方法
|
||||
* @param { sort } function 排序器,默认为lib.sort.seat
|
||||
*/
|
||||
static async doAsyncInOrder(targets,asyncFunc,sort){
|
||||
if(!sort)sort = lib.sort.seat;
|
||||
let sortedTargets = targets.sort(sort);
|
||||
for(let i=0;i<sortedTargets.length;i++){
|
||||
let target = sortedTargets[i];
|
||||
await Promise.resolve(asyncFunc(target,i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const game = Game;
|
||||
|
|
|
@ -864,7 +864,13 @@ async function setOnError() {
|
|||
}
|
||||
//解析parsex里的content fun内容(通常是技能content)
|
||||
// @ts-ignore
|
||||
else if (err && err.stack && ['at Object.eval [as content]', 'at Proxy.content'].some(str => err.stack.split('\n')[1].trim().startsWith(str))) {
|
||||
else if (err && err.stack && ['at Object.eval [as content]', 'at Proxy.content'].some(str =>{
|
||||
let stackSplit1 = err.stack.split('\n')[1];
|
||||
if(stackSplit1){
|
||||
return stackSplit1.trim().startsWith(str);
|
||||
}
|
||||
return false;
|
||||
})) {
|
||||
const codes = _status.event.content;
|
||||
if (typeof codes == 'function') {
|
||||
const lines = codes.toString().split("\n");
|
||||
|
|
|
@ -129,12 +129,16 @@ export class ChromePromiseErrorHandler {
|
|||
}
|
||||
// 反之我们只能不考虑报错文件信息,直接调用onerror
|
||||
else {
|
||||
// @ts-ignore
|
||||
let [_, src = void 0, line = void 0, column = void 0] = /at\s+.*\s+\((.*):(\d*):(\d*)\)/i.exec(error.stack.split('\n')[1])
|
||||
if (typeof line == 'string') line = Number(line);
|
||||
if (typeof column == 'string') column = Number(column);
|
||||
// @ts-ignore
|
||||
window.onerror(error.message, src, line, column, error);
|
||||
try{
|
||||
// @ts-ignore
|
||||
let [_, src = void 0, line = void 0, column = void 0] = /at\s+.*\s+\((.*):(\d*):(\d*)\)/i.exec(error.stack.split('\n')[1])
|
||||
if (typeof line == 'string') line = Number(line);
|
||||
if (typeof column == 'string') column = Number(column);
|
||||
// @ts-ignore
|
||||
window.onerror(error.message, src, line, column, error);
|
||||
}catch(e){
|
||||
window.onerror(error.message,'',0,0, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue