'use strict'; game.import('mode',function(lib,game,ui,get,ai,_status){ return { name:'doudizhu', start:function(){ "step 0" var playback=localStorage.getItem(lib.configprefix+'playback'); if(playback){ ui.create.me(); ui.arena.style.display='none'; ui.system.style.display='none'; _status.playback=playback; localStorage.removeItem(lib.configprefix+'playback'); var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); store.get(parseInt(playback)).onsuccess=function(e){ if(e.target.result){ game.playVideoContent(e.target.result.video); } else{ alert('播放失败:找不到录像'); game.reload(); } } event.finish(); } else if(!_status.connectMode){ game.prepareArena(3); } "step 1" _status.mode=get.config('doudizhu_mode'); if(_status.connectMode){ _status.mode=lib.configOL.doudizhu_mode; game.waitForPlayer(function(){ lib.configOL.number=3; }); } "step 2" if(_status.connectMode){ if(lib.configOL.number<3){ lib.configOL.number=3; } game.randomMapOL(); } else{ for(var i=0;i'; } } lib.config.gameRecord.doudizhu.str=str; game.saveConfig('gameRecord',lib.config.gameRecord); } }, getState:function(){ var state={}; for(var i in lib.playerOL){ var player=lib.playerOL[i]; state[i]={identity:player.identity}; } return state; }, updateState:function(state){ for(var i in state){ var player=lib.playerOL[i]; if(player){ player.identity=state[i].identity; } } }, getRoomInfo:function(uiintro){ uiintro.add('
双将模式:'+(lib.configOL.double_character?'开启':'关闭')); // uiintro.add('
屏蔽弱将:'+(lib.configOL.ban_weak?'开启':'关闭')); // var last=uiintro.add('
屏蔽强将:'+(lib.configOL.ban_strong?'开启':'关闭')); if(lib.configOL.banned.length){ uiintro.add('
禁用武将:'+get.translation(lib.configOL.banned)); } if(lib.configOL.bannedcards.length){ uiintro.add('
禁用卡牌:'+get.translation(lib.configOL.bannedcards)); } uiintro.style.paddingBottom='8px'; }, getVideoName:function(){ var str=get.translation(game.me.name); if(game.me.name2){ str+='/'+get.translation(game.me.name2); } var name=[ str, '欢乐斗地主'+' - '+lib.translate[game.me.identity+'2'] ]; return name; }, showIdentity:function(me){ for(var i=0;i1) return; if(me==game.zhu){ game.over(true); } else{ game.over(false); } } else { if(me==game.zhu){ game.over(false); } else{ game.over(true); } } }, checkOnlineResult:function(player){ if(game.zhu.isAlive()){ return player.identity=='zhu'; } else return player.identity=='fan'; }, chooseCharacterHuanle:function(){ var next=game.createEvent('chooseCharacter',false); next.setContent(function(){ "step 0" ui.arena.classList.add('choose-character'); var i; event.list=[]; event.list2=[]; var list4=[]; if(!event.map) event.map={}; for(i in lib.characterReplace){ var ix=lib.characterReplace[i]; for(var j=0;j0.5?'不叫':'叫地主'; }); if(event.current==game.me){ event.dialog.content.childNodes[0].innerHTML='是否抢地主?'; } "step 2" event.current.chat(result.control); if(result.control=='叫地主'||event.current==event.start.next){ game.zhu=result.control=='叫地主'?event.current:event.current.next; for(var player of game.players){ player.identity=player==game.zhu?'zhu':'fan'; player.showIdentity(); } event.dialog.close(); event.map[game.zhu.playerid].addArray(event.list.randomRemove(3)); } else{ event.current=event.current.next; event.goto(1); game.delay(1.5); } "step 3" game.me.chooseButton(['请选择你的武将',[event.map[game.me.playerid],'character']],true); "step 4" game.me.init(result.links[0]); for(var player of game.players){ if(player!=game.me) player.init(event.map[player.playerid].randomGet()); } game.zhu.hp++; game.zhu.maxHp++; game.zhu.update(); for(var i=0;i'; td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){ if(_status.dragged) return; if(_status.justdragged) return; _status.tempNoButton=true; setTimeout(function(){ _status.tempNoButton=false; },500); var link=this.link; if(game.zhu.name){ if(link!='random'){ _status.event.parent.fixedseat=get.distance(game.me,game.zhu,'absolute'); } game.zhu.uninit(); delete game.zhu.isZhu; delete game.zhu.identityShown; } var current=this.parentNode.querySelector('.bluebg'); if(current){ current.classList.remove('bluebg'); } current=seats.querySelector('.bluebg'); if(current){ current.classList.remove('bluebg'); } if(link=='random'){ link=['zhu','fan'].randomGet(); for(var i=0;i0.5?'不叫':'叫地主'; }); "step 2" event.current.chat(result.control); if(result.control=='叫地主'||event.current==event.start.next){ game.zhu=result.control=='叫地主'?event.current:event.current.next; for(var player of game.players){ player.identity=player==game.zhu?'zhu':'fan'; player.showIdentity(); player.identityShown=true; } game.broadcastAll('closeDialog',event.videoId) event.map[game.zhu.playerid].addArray(event.list.randomRemove(3)); } else{ event.current=event.current.next; event.goto(1); } "step 3" var list=[]; var str='选择角色'; for(var i=0;i5){ num=5; } if(num2>2){ num2=2; } for(var i=0;i0; }, content:function(){ 'step 0' player.gainPlayerCard(target,[1,2],'he',true); target.storage.kaihei=true; 'step 1' if(!result.bool||!result.cards.length){ event.finish();return; } var num=result.cards.length; var hs=player.getCards('he'); if(hs.length){ if(hs.length<=num) event._result={bool:true,cards:hs}; else player.chooseCard('he',true,num,'选择交给'+get.translation(target)+get.cnNumber(num)+'张牌'); } else event.finish(); 'step 2' if(result.bool&&result.cards&&result.cards.length) target.gain(result.cards,player,'giveAuto'); }, ai:{ viewHandcard:true, skillTagFilter:function(player,tag,target){ if(player==target||player.identity!='fan'||target.identity!='fan') return false; }, }, }, _feiyang:{ trigger:{player:'phaseJudgeBegin'}, direct:true, filter:function(event,player){ return player==game.zhu&&player.countCards('j')&&player.countCards('h')>1; }, content:function(){ "step 0" player.chooseToDiscard('h',2,'是否发动【飞扬】,弃置两张手牌并弃置自己判定区的一张牌?').set('logSkill','_feiyang').ai=function(card){ return 6-get.value(card); }; "step 1" if(result.bool){ player.discardPlayerCard(player,'j',true); } }, }, _bahu:{ trigger:{player:'phaseZhunbeiBegin'}, forced:true, filter:function(event,player){ return player==game.zhu; }, content:function(){ player.draw(); }, mod:{ cardUsable:function(card,player,num){ if(player==game.zhu&&card.name=='sha') return num+1; }, }, }, _dieAfterDraw:{ trigger:{global:'dieAfter'}, forced:true, silent:true, popup:false, filter:function(event,player){ return event.player.identity==player.identity; }, content:function(){ player.chooseDrawRecover(2); player.showGiveup(); }, }, }, help:{ '斗地主':'
游戏规则
  • 游戏人数
    游戏人数为3人(地主x1 + 农民x2)。
  • 胜利条件
    农民:地主死亡。
    地主:所有农民死亡且自己存活。'+ '
  • 死亡奖惩
    当有农民死亡时,若另一名农民存活,则其可以选择摸两张牌或回复一点体力。
  • 地主专属技能
    地主可以使用专属技能【飞扬】和【跋扈】。
    【飞扬】判定阶段开始时,若你的判定区有牌,则你可以弃置两张手牌,然后弃置你判定区的一张牌。每回合限一次。
    【跋扈】锁定技,准备阶段开始时,你摸一张牌。出牌阶段,你可以多使用一张【杀】。
', } }; });