From 3208e381d4609529f6c1864aab8dd16049edca44 Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Sun, 8 Oct 2023 08:02:29 -0700 Subject: [PATCH] Add Player class. --- game/game.js | 1791 ++++++++++++++++++++++++++------------------------ 1 file changed, 918 insertions(+), 873 deletions(-) diff --git a/game/game.js b/game/game.js index 10edcdc6f..61b7a043f 100644 --- a/game/game.js +++ b/game/game.js @@ -78,7 +78,7 @@ clicked:false, auto:false, /** - * @type {typeof lib.element.Event} + * @type {InstanceType} */ event:null, ai:{}, @@ -20464,7 +20464,102 @@ game.delayx(); }, }, - player:{ + Player:class{ + /** + * @param {HTMLDivElement} [position] + * @param {true} [noclick] + */ + constructor(position,noclick){ + const player=ui.create.div('.player',position); + Object.setPrototypeOf(player,lib.element.Player.prototype); + const node=this.node=player.node={ + avatar:ui.create.div('.avatar',player,ui.click.avatar).hide(), + avatar2:ui.create.div('.avatar2',player,ui.click.avatar2).hide(), + turnedover:ui.create.div('.turned','
翻面
',player), + framebg:ui.create.div('.framebg',player), + intro:ui.create.div('.intro',player), + identity:ui.create.div('.identity',player), + hp:ui.create.div('.hp',player), + name:ui.create.div('.name',player), + name2:ui.create.div('.name.name2',player), + nameol:ui.create.div('.nameol',player), + count:ui.create.div('.count',player).hide(), + equips:ui.create.div('.equips',player).hide(), + judges:ui.create.div('.judges',player), + marks:ui.create.div('.marks',player), + chain:ui.create.div('.chain','
',player), + handcards1:ui.create.div('.handcards'), + handcards2:ui.create.div('.handcards'), + expansions:ui.create.div('.expansions') + }; + node.expansions.style.display='none'; + const chainLength=game.layout=='default'?64:40; + for(let repetition=0;repetitiontarget.hp?-1:0; if(target.hasSkillTag('nogain')) return 0; return Math.max(1,get.value(card,this)-get.value(card,target)); - }, - getGiftEffect:function(card,target){ + } + getGiftEffect(card,target){ return this.getGiftAIResultTarget(card,target)*get.attitude(this,target); - }, + } //Recast //重铸 - recast:function(cards,recastingLose,recastingGain){ + recast(cards,recastingLose,recastingGain){ const recast=game.createEvent('recast'); recast.player=this; const isArray=Array.isArray(cards); @@ -20751,16 +20846,16 @@ recast.setContent('recast'); recast._args=Array.from(arguments); return recast; - }, + } //Check if the player can recast the card //检测角色是否能重铸此牌 - canRecast:function(card,source,strict){ + canRecast(card,source,strict){ return lib.filter.cardRecastable(card,this,source,strict); - }, + } //装备栏相关 //判断一名角色的某个区域是否被废除 //type为要判断的区域 若为空 则判断玩家是否有任意一个被废除的区域 - hasDisabledSlot:function(type){ + hasDisabledSlot(type){ var player=this; if(type=='horse'||type=='equip3_4'){ return player.hasDisabledSlot(3)&&(get.is.mountCombined()||player.hasDisabledSlot(4)); @@ -20769,10 +20864,10 @@ return false; } return player.countDisabledSlot(type)>0; - }, + } //判断一名角色的某个区域被废除的数量 //用法同上 - countDisabledSlot:function(type){ + countDisabledSlot(type){ var player=this; var map=(player.disabledSlots||{}); if(type==undefined){ @@ -20791,9 +20886,9 @@ if(typeof num=='number'&&num>0) return num; return 0; } - }, + } //判断一名角色是否有某个装备栏空着 - hasEmptySlot:function(type){ + hasEmptySlot(type){ var player=this; if(type=='horse'||type=='equip3_4'){ return player.hasEmptySlot(3)&&(get.is.mountCombined()||player.hasEmptySlot(4)); @@ -20802,9 +20897,9 @@ return false; } return player.countEmptySlot(type)>0; - }, + } //判断一名角色的某个装备栏空位的数量 - countEmptySlot:function(type){ + countEmptySlot(type){ if(!type) return 0; var player=this; if(typeof type=='number') type=('equip'+type); @@ -20815,15 +20910,15 @@ var types=get.subtypes(card,false); return num+get.numOf(types,type); },0)) - }, + } //判断一名角色是否有可以用于装备新装备牌的区域(排除金箍棒和六龙等“不可被替换装备”) //用法同下 - hasEquipableSlot:function(type){ + hasEquipableSlot(type){ return this.countEquipableSlot(type)>0; - }, + } //统计一名角色有多少个可以用于装备新的装备牌的区域 //用法同下 - countEquipableSlot:function(type){ + countEquipableSlot(type){ if(!type) return 0; var player=this; if(typeof type=='number') type=('equip'+type); @@ -20838,10 +20933,10 @@ if(!lib.filter.canBeReplaced(card,player)) num+=get.numOf(types,type); return num; },0)) - }, + } //判断一名角色是否拥有未被废除的某个区域 //type为要判断的区域 若为空 则判断玩家是否有任意一个未被废除的区域 - hasEnabledSlot:function(type){ + hasEnabledSlot(type){ var player=this; if(type=='horse'||type=='equip3_4'){ return player.hasEnabledSlot(3)&&(get.is.mountCombined()||player.hasEnabledSlot(4)); @@ -20853,10 +20948,10 @@ return false; } return player.countEnabledSlot(type)>0; - }, + } //判断一名角色的某个区域未被废除的数量 //用法同上 - countEnabledSlot:function(type){ + countEnabledSlot(type){ var player=this; var map=(player.expandedSlots||{}); if(!type){ @@ -20877,10 +20972,10 @@ slots-=player.countDisabledSlot(type); return slots; } - }, + } //获取一名角色装备区内某种类型的装备牌 //参数可以为数字/区域字符串/实体牌/虚拟牌/牌名 - getEquips:function(subtype){ + getEquips(subtype){ var type=(typeof subtype); switch(type){ case 'string': @@ -20910,10 +21005,10 @@ return this.getCards('e',function(card){ return get.subtypes(card,false).contains(subtype); }) - }, + } //新的废除装备区/恢复装备区/扩展装备区 //参数:废除来源角色(不写默认当前事件角色),废除区域(数字/区域字符串/数组,可以写多个,重复废除) - disableEquip:function(){ + disableEquip(){ var next=game.createEvent('disableEquip'); next.player=this; next.slots=[]; @@ -20944,8 +21039,8 @@ } next.setContent('disableEquip'); return next; - }, - enableEquip:function(){ + } + enableEquip(){ var next=game.createEvent('enableEquip'); next.player=this; next.slots=[]; @@ -20976,8 +21071,8 @@ } next.setContent('enableEquip'); return next; - }, - expandEquip:function(){ + } + expandEquip(){ var next=game.createEvent('expandEquip'); next.player=this; next.slots=[]; @@ -21008,13 +21103,13 @@ } next.setContent('expandEquip'); return next; - }, + } //判断判定区是否被废除 - isDisabledJudge:function(){ + isDisabledJudge(){ return Boolean(this.storage._disableJudge); - }, + } //同步显示扩展装备区状态 - $syncExpand:function(map){ + $syncExpand(map){ var player=this; if(!map){ map=(player.expandedSlots||{}); @@ -21025,9 +21120,9 @@ player.$syncExpand(map); },player,map); player.markSkill('expandedSlots'); - }, + } //同步装备区废除牌显示状态 - $syncDisable:function(map){ + $syncDisable(map){ const player=this; const suits={equip3:'+1马栏',equip4:'-1马栏',equip6:'特殊栏'}; if(get.is.mountCombined()) suits.equip3='坐骑栏'; @@ -21086,9 +21181,9 @@ } } } - }, + } //以下函数涉及到本次更新内容而进行修改 - canEquip:function(name,replace){ + canEquip(name,replace){ const ranges=get.subtypes(name),rangex=[],player=this,combined=get.is.mountCombined(); if(combined){ ranges.forEach(type=>{ @@ -21106,22 +21201,22 @@ if(numthis.getEquips(num).length; - }, + } //以下函数将被废弃 - $disableEquip:function(){}, - $enableEquip:function(){}, + $disableEquip(){} + $enableEquip(){} //装备区End - chooseToDebate:function(){ + chooseToDebate(){ var next=game.createEvent('chooseToDebate'); next.player=this; next._args=[]; @@ -21135,8 +21230,8 @@ } next.setContent('chooseToDebate'); return next; - }, - cooperationWith:function(target,type,reason){ + } + cooperationWith(target,type,reason){ var player=this; if(!player.storage.cooperation) player.storage.cooperation=[]; var info={ @@ -21148,8 +21243,8 @@ player.addTempSkill('cooperation',{player:'dieAfter'}); player.addSkill('cooperation_'+type,{player:'dieAfter'}); game.log(player,'向',target,'发起了“协力”,合作类型是','#g'+get.translation('cooperation_'+type)); - }, - chooseCooperationFor:function(){ + } + chooseCooperationFor(){ var next=game.createEvent('chooseCooperationFor'); next.player=this; for(var i=0;i'; - lib.element.player.say.call(this,str); + this.say(str); game.broadcast(function(id,str){ if(lib.playerOL[id]){ lib.playerOL[id].say(str); @@ -22247,16 +22342,16 @@ else if(game.connectPlayers){ for(var i=0;i=this.maxHp) this.hp=this.maxHp; game.broadcast(function(player,hp,maxHp,hujia){ @@ -22501,8 +22596,8 @@ player.$update(); },this,this.hp,this.maxHp,this.hujia); this.$update(); - }, - $update:function(){ + } + $update(){ if(this.hp>=this.maxHp) this.hp=this.maxHp; var hp=this.node.hp; hp.style.transition='none'; @@ -22609,8 +22704,8 @@ this.node.count.innerHTML=numh; } if(this.updates){ - for(var i=0;i0) this.removeMark(i,num,log) - }, - removeMark:function(i,num,log){ + } + removeMark(i,num,log){ if(typeof num!='number'||!num) num=1; if(typeof this.storage[i]!='number'||!this.storage[i]) return; if(num>this.storage[i]) num=this.storage[i]; @@ -22637,8 +22732,8 @@ } this.syncStorage(i); this[(this.storage[i]||(lib.skill[i]&&lib.skill[i].mark))?'markSkill':'unmarkSkill'](i); - }, - addMark:function(i,num,log){ + } + addMark(i,num,log){ if(typeof num!='number'||!num) num=1; if(typeof this.storage[i]!='number') this.storage[i]=0; this.storage[i]+=num; @@ -22651,22 +22746,22 @@ } this.syncStorage(i); this.markSkill(i); - }, - setMark:function(name,num,log){ + } + setMark(name,num,log){ const count=this.countMark(name); if(count>num)this.removeMark(name,count-num,log); else if(count0; - }, - updateMark:function(i,storage){ + } + updateMark(i,storage){ if(!this.marks[i]){ if(lib.skill[i]&&lib.skill[i].intro&&(this.storage[i]||lib.skill[i].intro.markcount)){ this.markSkill(i); @@ -22723,8 +22818,8 @@ } } return this; - }, - updateMarks:function(connect){ + } + updateMarks(connect){ if(typeof connect=='string'&&_status.connectMode&&!game.online){ game.broadcast(function(player,storage,skill){ player.storage[skill]=storage; @@ -22734,8 +22829,8 @@ for(var i in this.marks){ this.updateMark(i); } - }, - num:function(arg1,arg2,arg3){ + } + num(arg1,arg2,arg3){ if(get.itemtype(arg1)=='position'){ return this.get(arg1,arg2,arg3).length; } @@ -22747,8 +22842,8 @@ return game.expandSkills(this.getSkills().concat(lib.skill.global)).contains(arg2); } } - }, - line:function(target,config){ + } + line(target,config){ if(get.itemtype(target)=='players'){ for(var i=0;i0||this.isDying()) return; var next=game.createEvent('dying'); next.player=this; @@ -25366,16 +25461,16 @@ } }; return next; - }, - die:function(reason){ + } + die(reason){ var next=game.createEvent('die'); next.player=this; next.reason=reason; if(reason) next.source=reason.source; next.setContent('die'); return next; - }, - revive:function(hp,log){ + } + revive(hp,log){ if(log!==false) game.log(this,'复活'); if(this.maxHp<1) this.maxHp=1; if(hp) this.hp=hp; @@ -25426,11 +25521,11 @@ delete ui.continue_game; } } - }, - isMad:function(){ + } + isMad(){ return this.hasSkill('mad'); - }, - goMad:function(end){ + } + goMad(end){ if(end){ this.addTempSkill('mad',end); } @@ -25438,14 +25533,14 @@ this.addSkill('mad'); } game.log(this,'进入混乱状态'); - }, - unMad:function(){ + } + unMad(){ this.removeSkill('mad'); - }, - tempHide:function(){ + } + tempHide(){ this.addTempSkill('qianxing',{player:'phaseBeginStart'}); - }, - addExpose:function(num){ + } + addExpose(num){ if(typeof this.ai.shown=='number'&&!this.identityShown&&this.ai.shown<1){ this.ai.shown+=num; if(this.ai.shown>0.95){ @@ -25453,8 +25548,8 @@ } } return this; - }, - equip:function(card,draw){ + } + equip(card,draw){ var next=game.createEvent('equip'); next.card=card; next.player=this; @@ -25506,8 +25601,8 @@ return map; }; return next; - }, - addJudge:function(card,cards){ + } + addJudge(card,cards){ var next=game.createEvent('addJudge'); if(get.itemtype(card)=='card'){ next.card=card; @@ -25565,8 +25660,8 @@ return map; }; return next; - }, - canAddJudge:function(card){ + } + canAddJudge(card){ if(this.isDisabledJudge()) return false; var name; if(typeof card=='string'){ @@ -25581,8 +25676,8 @@ var mod=game.checkMod(card,this,this,'unchanged','targetEnabled',this); if(mod!='unchanged') return mod; return true; - }, - addJudgeNext:function(card,unlimited){ + } + addJudgeNext(card,unlimited){ if(!card.expired){ let target=this.next; const name=card.viewAs||card.name; @@ -25617,8 +25712,8 @@ else{ card.expired=false; } - }, - judge:function(){ + } + judge(){ var next=game.createEvent('judge'); next.player=this; for(var i=0;i0?'markSkill':'unmarkSkill'](name); } } - }, - unmarkAuto:function(name,info){ + } + unmarkAuto(name,info){ var storage=this.storage[name] if(Array.isArray(info)&&Array.isArray(storage)){ storage.removeArray(info.slice(0)); this.markAuto(name); } - }, - getExpansions:function(tag){ + } + getExpansions(tag){ return this.getCards('x',(card)=>card.hasGaintag(tag)); - }, - countExpansions:function(tag){ + } + countExpansions(tag){ return this.getExpansions(tag).length; - }, - hasExpansions:function(tag){ + } + hasExpansions(tag){ return this.countExpansions(tag)>0; - }, - setStorage:function(name,value,mark){ + } + setStorage(name,value,mark){ this.storage[name]=value; if(mark) this.markAuto(name); return value; - }, - getStorage:function(name){ + } + getStorage(name){ return this.storage[name]||[]; - }, - hasStorage:function(name,value){ + } + hasStorage(name,value){ if(!(name in this.storage)) return false; if(typeof value=="undefined") return true; const storage=this.storage[name]; if(storage===value) return true; return Array.isArray(storage) && storage.includes(value); - }, - hasStorageAny:function(name,values){ + } + hasStorageAny(name,values){ const storage=this.storage[name]; if(!Array.isArray(values)) values=Array.from(arguments).slice(1); if(!storage) return false; if (!Array.isArray(storage)) return values.contains(storage); return values.some(item => storage.contains(item)); - }, - hasStorageAll:function(name,values){ + } + hasStorageAll(name,values){ const storage=this.storage[name]; if(!Array.isArray(values)) values=Array.from(arguments).slice(1); if(!storage) return false; if (!Array.isArray(storage)) return false; return values.every(item => storage.contains(item)); - }, - initStorage:function(name,value,mark){ + } + initStorage(name,value,mark){ return this.hasStorage(name)?this.getStorage(name):this.setStorage(name,value,mark); - }, - updateStorage:function(name,operation,mark){ + } + updateStorage(name,operation,mark){ return this.setStorage(name,operation(this.getStorage(name)),mark); - }, - updateStorageAsync:function(name,operation,mark){ + } + updateStorageAsync(name,operation,mark){ return Promise.resolve(this.getStorage(name)) .then(value=>operation(value)) .then(value=>this.setStorage(name,value,mark)); - }, - removeStorage:function(name,mark){ + } + removeStorage(name,mark){ if(!this.hasStorage(name)) return false; delete this.storage[name] if(mark){ this.unmarkSkill(name); } return true; - }, - markSkill:function(name,info,card,nobroadcast){ + } + markSkill(name,info,card,nobroadcast){ if(info===true){ this.syncStorage(name); info=null; @@ -26209,8 +26304,8 @@ func(this.storage[name],this,name,info,card); if(!nobroadcast) game.broadcast(func,this.storage[name],this,name,info,card); return this; - }, - unmarkSkill:function(name,nobroadcast){ + } + unmarkSkill(name,nobroadcast){ game.addVideo('unmarkSkill',this,name); if(!nobroadcast) game.broadcast(function(player,name){ if(player.marks[name]){ @@ -26242,8 +26337,8 @@ } } return this; - }, - markSkillCharacter:function(id,target,name,content,nobroadcast){ + } + markSkillCharacter(id,target,name,content,nobroadcast){ if(typeof target=='object'){ target=target.name; } @@ -26282,8 +26377,8 @@ func(this,target,name,content,id); if(!nobroadcast) game.broadcast(func,this,target,name,content,id); return this; - }, - markCharacter:function(name,info,learn,learn2){ + } + markCharacter(name,info,learn,learn2){ if(typeof name=='object'){ name=name.name; } @@ -26319,8 +26414,8 @@ } ui.updatem(this); return node; - }, - mark:function(name,info,skill){ + } + mark(name,info,skill){ if(get.itemtype(name)=='cards'){ var marks=[]; for(var i=0;i0; - }, - getUseValue:function(card,distance,includecard){ + } + getUseValue(card,distance,includecard){ if(typeof(card)=='string'){ card={name:card,isCard:true}; } @@ -26484,8 +26579,8 @@ min+=value[i]; } return min; - }, - addSubPlayer:function(cfg){ + } + addSubPlayer(cfg){ var skill='subplayer_'+cfg.name+'_'+get.id(); game.log(this,'获得了随从','#g'+get.translation(cfg.name)) cfg.hs=cfg.hs||[]; @@ -26523,8 +26618,8 @@ game.addVideo('addSubPlayer',this,[skill,lib.skill[skill],lib.character[skill],lib.translate[skill],{name:cfg.name}]); this.addSkill(skill); return skill; - }, - removeSubPlayer:function(name){ + } + removeSubPlayer(name){ if(this.hasSkill('subplayer')&&this.name==name){ this.exitSubPlayer(true); } @@ -26537,8 +26632,8 @@ game.log(player,'牺牲了随从','#g'+name); _status.event.trigger('removeSubPlayer'); } - }, - callSubPlayer:function(){ + } + callSubPlayer(){ if(this.hasSkill('subplayer')) return; var next=game.createEvent('callSubPlayer'); next.player=this; @@ -26549,8 +26644,8 @@ } next.setContent('callSubPlayer'); return next; - }, - toggleSubPlayer:function(){ + } + toggleSubPlayer(){ if(!this.hasSkill('subplayer')) return; var next=game.createEvent('toggleSubPlayer'); next.player=this; @@ -26561,16 +26656,16 @@ } next.setContent('toggleSubPlayer'); return next; - }, - exitSubPlayer:function(remove){ + } + exitSubPlayer(remove){ if(!this.hasSkill('subplayer')) return; var next=game.createEvent('exitSubPlayer'); next.player=this; next.remove=remove; next.setContent('exitSubPlayer'); return next; - }, - getSubPlayers:function(tag){ + } + getSubPlayers(tag){ var skills=this.getSkills(); var list=[]; for(var i=0;i=0;i--){ if(this.actionHistory[i].isMe){ @@ -27262,8 +27357,8 @@ } return history.filter(filter); } - }, - checkAllHistory:function(key,filter,last){ + } + checkAllHistory(key,filter,last){ if(!key||!filter) return; this.actionHistory.forEach((value)=>{ let history=value[key]; @@ -27278,8 +27373,8 @@ history.forEach(filter); } }); - }, - getAllHistory:function(key,filter,last){ + } + getAllHistory(key,filter,last){ const history=[]; this.actionHistory.forEach((value)=>{ if(!key||!value[key]){ @@ -27300,8 +27395,8 @@ return history.filter(filter); } return history; - }, - hasAllHistory:function(key,filter,last){ + } + hasAllHistory(key,filter,last){ return this.actionHistory.some((value)=>{ let history=value[key]; if(last&&history.includes(last)){ @@ -27316,18 +27411,18 @@ } return false; }) - }, - getLastUsed:function(num){ + } + getLastUsed(num){ if(typeof num!='number') num=0; var history=this.getHistory('useCard'); if(history.length<=num) return null; return history[history.length-num-1]; - }, - getStat:function(key){ + } + getStat(key){ if(!key) return this.stat[this.stat.length-1]; return this.stat[this.stat.length-1][key]; - }, - getLastStat:function(key){ + } + getLastStat(key){ var stat=false; for(var i=this.stat.length-1;i>=0;i--){ if(this.stat[i].isMe){ @@ -27337,8 +27432,8 @@ if(!stat) return null if(!key) return stat; return stat[key]; - }, - queue:function(time){ + } + queue(time){ if(time==false){ clearTimeout(this.queueTimeout); this.queueCount=0; @@ -27359,8 +27454,8 @@ if(player==game.me) ui.me.removeAttribute('style'); } },time) - }, - getCardUsable:function(card,pure){ + } + getCardUsable(card,pure){ var player=this; if(typeof card=='string'){ card={name:card}; @@ -27374,8 +27469,8 @@ return num-player.countUsed(card); } return num; - }, - getAttackRange:function(raw){ + } + getAttackRange(raw){ const player=this; let range=0; if(raw){ @@ -27401,8 +27496,8 @@ } range=game.checkMod(player,range,'attackRange',player); return range; - }, - getEquipRange:function(cards){ + } + getEquipRange(cards){ const player=this; if(!cards) cards=player.getCards('e',function(card){ return !ui.selected.cards||!ui.selected.cards.contains(card); @@ -27426,8 +27521,8 @@ else return (isN1?range:newRange); },false); return (typeof range=='number')?range:1; - }, - getGlobalFrom:function(){ + } + getGlobalFrom(){ var player=this; var range=0; range=game.checkMod(player,player,range,'globalFrom',player); @@ -27442,8 +27537,8 @@ } } return (-range); - }, - getGlobalTo:function(){ + } + getGlobalTo(){ var player=this; var range=0; range=game.checkMod(player,player,range,'globalTo',player); @@ -27458,15 +27553,15 @@ } } return (range); - }, - getHandcardLimit:function(){ + } + getHandcardLimit(){ var num=Math.max(this.hp,0); num=game.checkMod(this,num,'maxHandcardBase',this); num=game.checkMod(this,num,'maxHandcard',this); num=game.checkMod(this,num,'maxHandcardFinal',this); return Math.max(0,num); - }, - getEnemies:function(func){ + } + getEnemies(func){ var player=this; var targets; var mode=get.mode(); @@ -27537,8 +27632,8 @@ } targets.remove(player); return targets; - }, - getFriends:function(func){ + } + getFriends(func){ var player=this; var targets; var mode=get.mode(); @@ -27609,11 +27704,11 @@ targets.remove(player); } return targets; - }, - isEnemyOf:function(){ + } + isEnemyOf(){ return !this.isFriendOf.apply(this,arguments); - }, - isFriendOf:function(player){ + } + isFriendOf(player){ if(get.mode()=='guozhan'){ if(this==player) return true; if(this.getStorage('yexinjia_friend').includes(player)||player.getStorage('yexinjia_friend').includes(this)) return true; @@ -27628,111 +27723,111 @@ return this.side==player.side; } return this==player; - }, - isFriendsOf:function(player){ + } + isFriendsOf(player){ return player.getFriends(true).contains(this); - }, - isEnemiesOf:function(player){ + } + isEnemiesOf(player){ return player.getEnemies().contains(this); - }, - isAlive:function(){ + } + isAlive(){ return this.classList.contains('dead')==false; - }, - isDead:function(){ + } + isDead(){ return this.classList.contains('dead'); - }, - isDying:function(){ + } + isDying(){ return _status.dying.contains(this)&&this.hp<=0&&this.isAlive(); - }, - isDamaged:function(){ + } + isDamaged(){ return this.hp=this.maxHp||this.storage.nohp; - }, - isMaxHp:function(only,raw){ + } + isMaxHp(only,raw){ return game.players.every(value=>{ if(value.isOut()||value==this) return true; return only?value.getHp(raw){ if(value.isOut()||value==this) return true; return only?value.getHp(raw)>this.getHp(raw):value.getHp(raw)>=this.getHp(raw); }); - }, - isMaxCard:function(only){ + } + isMaxCard(only){ const numberOfCards=this.countCards('he'); return game.players.every(value=>{ if(value.isOut()||value==this) return true; return only?value.countCards('he'){ if(value.isOut()||value==this) return true; return only?value.countCards('he')>numberOfCards:value.countCards('he')>=numberOfCards; }); - }, - isMaxHandcard:function(only){ + } + isMaxHandcard(only){ const numberOfHandCards=this.countCards('h'); return game.players.every(value=>{ if(value.isOut()||value==this) return true; return only?value.countCards('h'){ if(value.isOut()||value==this) return true; return only?value.countCards('h')>numberOfHandCards:value.countCards('h')>=numberOfHandCards; }); - }, - isMaxEquip:function(only){ + } + isMaxEquip(only){ const numberOfEquipAreaCards=this.countCards('e'); return game.players.every(value=>{ if(value.isOut()||value==this) return true; return only?value.countCards('e'){ if(value.isOut()||value==this) return true; return only?value.countCards('e')>numberOfEquipAreaCards:value.countCards('e')>=numberOfEquipAreaCards; }); - }, - isLinked:function(){ + } + isLinked(){ if(get.is.linked2(this)){ return this.classList.contains('linked2'); } return this.classList.contains('linked'); - }, - isTurnedOver:function(){ + } + isTurnedOver(){ return this.classList.contains('turnedover'); - }, - isOut:function(){ + } + isOut(){ return this.classList.contains('out'); - }, - isMin:function(distance){ + } + isMin(distance){ if(distance&&lib.config.mode!='stone') return false; if(this.forcemin) return true; return this.classList.contains('minskin')&&!game.chess; - }, - isIn:function(){ + } + isIn(){ return this.classList.contains('dead')==false&&this.classList.contains('out')==false&&!this.removed; - }, - isUnseen:function(num){ + } + isUnseen(num){ switch(num){ case 0:return this.classList.contains('unseen'); case 1:return this.classList.contains('unseen2'); case 2:return this.classList.contains('unseen')||this.classList.contains('unseen2'); default:return this.classList.contains('unseen')&&(!this.name2||this.classList.contains('unseen2')); } - }, - isUnderControl:function(self,me){ + } + isUnderControl(self,me){ me=(me||game.me); var that=this._trueMe||this; if(that.isMad()||game.notMe) return false; @@ -27760,26 +27855,26 @@ return this.side==me.side; } return false; - }, - isOnline:function(){ + } + isOnline(){ if(this.ws&&lib.node&&!this.ws.closed&&this.ws.inited&&!this.isAuto){ return true; } return false; - }, - isOnline2:function(){ + } + isOnline2(){ if(this.ws&&lib.node&&!this.ws.closed){ return true; } return false; - }, - isOffline:function(){ + } + isOffline(){ if(this.ws&&lib.node&&this.ws.closed){ return true; } return false; - }, - checkShow:function(skill,showonly){ + } + checkShow(skill,showonly){ var sourceSkill=get.info(skill); var noshow=false; if(sourceSkill&&sourceSkill.sourceSkill){ @@ -27813,24 +27908,24 @@ } } return false; - }, - needsToDiscard:function(num){ + } + needsToDiscard(num){ if(typeof num!='number') num=0; return Math.max(0,num+this.countCards('h',card=>!this.canIgnoreHandcard(card))-this.getHandcardLimit()); - }, - distanceTo:function(target,method){ + } + distanceTo(target,method){ return get.distance(this,target,method); - }, - distanceFrom:function(target,method){ + } + distanceFrom(target,method){ return get.distance(target,this,method); - }, - hasSkill:function(skill,arg2,arg3,arg4){ + } + hasSkill(skill,arg2,arg3,arg4){ return game.expandSkills(this.getSkills(arg2,arg3,arg4)).contains(skill); - }, - hasStockSkill:function(skill,arg1,arg2,arg3){ + } + hasStockSkill(skill,arg1,arg2,arg3){ return game.expandSkills(this.getStockSkills(arg1,arg2,arg3)).contains(skill); - }, - isZhu2:function(){ + } + isZhu2(){ var player=this,mode=get.mode(); if(!this.isZhu) return false; if(mode=='identity'){ @@ -27839,8 +27934,8 @@ } if(mode=='versus'&&(_status.mode=='four'||_status.mode=='guandu')) return true; return false; - }, - hasZhuSkill:function(skill,player){ + } + hasZhuSkill(skill,player){ if(!this.hasSkill(skill)) return false; if(player){ var mode=get.mode(); @@ -27852,8 +27947,8 @@ } } return true; - }, - hasGlobalTag:function(tag,arg){ + } + hasGlobalTag(tag,arg){ var skills=lib.skill.global.slice(0); game.expandSkills(skills); for(var i=0;i0){ @@ -27912,8 +28007,8 @@ } } return false; - }, - hasUnknown:function(num){ + } + hasUnknown(num){ var mode=get.mode(); if(typeof num!='number'){ num=0; @@ -27929,8 +28024,8 @@ } } return false; - }, - isUnknown:function(player){ + } + isUnknown(player){ var mode=get.mode(); if(mode=='identity'||mode=='guozhan'){ if(this.ai.shown==0&&this!=player){ @@ -27938,8 +28033,8 @@ } } return false; - }, - hasWuxie:function(info){ + } + hasWuxie(info){ if(this.countCards('hs','wuxie')) return true; var skills=this.getSkills('invisible').concat(lib.skill.global); game.expandSkills(skills); @@ -27963,21 +28058,21 @@ } } return false; - }, - hasSha:function(respond,noauto){ + } + hasSha(respond,noauto){ if(this.countCards('hs','sha')) return true; if(this.countCards('hs','hufu')) return true; if(!noauto&&this.countCards('hs','yuchanqian')) return true; if(this.hasSkillTag('respondSha',true,respond?'respond':'use',true)) return true; return this.hasUsableCard('sha'); - }, - hasShan:function(){ + } + hasShan(){ if(this.countCards('hs','shan')) return true; if(this.countCards('hs','hufu')) return true; if(this.hasSkillTag('respondShan',true,null,true)) return true; return this.hasUsableCard('shan'); - }, - mayHaveSha:function(viewer,type){ + } + mayHaveSha(viewer,type){ if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',true,type,true)) return true; if(get.itemtype(viewer)!=='player') viewer=_status.event.player; let cards; @@ -27995,8 +28090,8 @@ let hs=this.getCards('hs').removeArray(cards).length; if(hs===0) return false; return Math.pow(hs+(this.isPhaseUsing()?6:4),2)>100*_status.event.getRand('mayHaveSha'); - }, - mayHaveShan:function(viewer,type){ + } + mayHaveShan(viewer,type){ if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondShan',true,type,true)) return true; if(get.itemtype(viewer)!=='player') viewer=_status.event.player; let cards; @@ -28014,8 +28109,8 @@ let hs=this.getCards('hs').removeArray(cards).length; if(hs===0) return false; return Math.pow(hs+(this.isPhaseUsing()?3:5),2)>100*_status.event.getRand('mayHaveShan'); - }, - hasCard:function(name,position){ + } + hasCard(name,position){ if(typeof name=='function'){ var hs=this.getCards(position); for(var i=0;i空房间
'); player.roomindex=i; - player.initRoom=lib.element.player.initRoom; + player.initRoom=lib.element.Player.prototype.initRoom; player.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.connectroom); player.initRoom(i); ui.rooms.push(player); @@ -33754,9 +33858,7 @@ game.getRoomInfo=mode.game.getRoomInfo; } if(mode.element&&mode.element.player){ - for(var i in mode.element.player){ - lib.element.player[i]=mode.element.player[i]; - } + Object.defineProperties(lib.element.Player.prototype,Object.getOwnPropertyDescriptors(mode.element.player)); } if(mode.skill){ for(var i in mode.skill){ @@ -33862,9 +33964,7 @@ game.showIdentity=mode.game.showIdentity; } if(mode.element&&mode.element.player){ - for(var i in mode.element.player){ - lib.element.player[i]=mode.element.player[i]; - } + Object.defineProperties(lib.element.Player.prototype,Object.getOwnPropertyDescriptors(mode.element.player)); } if(mode.skill){ for(var i in mode.skill){ @@ -33966,8 +34066,8 @@ if(lib.config.die_move){ player.$dieflip(); } - if(lib.element.player.$dieAfter){ - lib.element.player.$dieAfter.call(player); + if(player.$dieAfter){ + player.$dieAfter(); } game.dead.push(player); } @@ -42378,7 +42478,7 @@ for(var i=0;i空房间
'); player.roomindex=i; - player.initRoom=lib.element.player.initRoom; + player.initRoom=lib.element.Player.prototype.initRoom; player.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.connectroom); player.initRoom(list[i]); ui.rooms.push(player); @@ -51885,77 +51985,7 @@ dialog.buttons.add(next.firstChild) } }, - player:function(position,noclick){ - var node=ui.create.div('.player',position); - node.node={ - avatar:ui.create.div('.avatar',node,ui.click.avatar).hide(), - avatar2:ui.create.div('.avatar2',node,ui.click.avatar2).hide(), - turnedover:ui.create.div('.turned','
'+get.verticalStr('翻面')+'
',node), - framebg:ui.create.div('.framebg',node), - intro:ui.create.div('.intro',node), - identity:ui.create.div('.identity',node), - hp:ui.create.div('.hp',node), - name:ui.create.div('.name',node), - name2:ui.create.div('.name.name2',node), - nameol:ui.create.div('.nameol',node), - count:ui.create.div('.count',node).hide(), - equips:ui.create.div('.equips',node).hide(), - judges:ui.create.div('.judges',node), - marks:ui.create.div('.marks',node), - chain:ui.create.div('.chain','
',node), - handcards1:ui.create.div('.handcards'), - handcards2:ui.create.div('.handcards'), - expansions:ui.create.div('.expansions'), - }; - node.node.expansions.display='none'; - var chainlength=game.layout=='default'?64:40; - for(var i=0;inew lib.element.Player(position,noclick), connectPlayers:function(ip){ game.connectPlayers=[]; for(var i=0;i<8;i++){ @@ -53213,7 +53243,7 @@ game.send('chat',game.onlineID,str); } else{ - lib.element.player.chat.call(player,str); + player.chat(str); } input.value=''; _status.chatValue=''; @@ -53290,7 +53320,7 @@ game.send('emotion',game.onlineID,this.pack,this.emotionID); } else{ - lib.element.player.emotion.apply(player,[this.pack,this.emotionID]); + player.emotion(this.pack,this.emotionID); } }); emotionButton.emotionID=j; @@ -53341,7 +53371,7 @@ game.send('chat',game.onlineID,str); } else{ - lib.element.player.chat.call(player,str); + player.chat(str); } }); node.innerHTML=lib.quickVoice[i]; @@ -61427,6 +61457,21 @@ }, get:get }; + /** + * @template T + * @param {T} object + */ + const setAllPropertiesEnumerable=object=>{ + Object.getOwnPropertyNames(object).forEach(propertyKey=>{ + if(propertyKey=='constructor') return; + const propertyDescriptor=Object.getOwnPropertyDescriptor(object,propertyKey); + if(!propertyDescriptor.enumerable) propertyDescriptor.enumerable=true; + Object.defineProperty(object,propertyKey,propertyDescriptor); + },{}); + return object; + }; + Object.setPrototypeOf(setAllPropertiesEnumerable(lib.element.Player.prototype),HTMLDivElement.prototype); + setAllPropertiesEnumerable(lib.element.Event.prototype); if('__core-js_shared__' in window) lib.init.init(); else{ const coreJSBundle=document.createElement('script');