This commit is contained in:
libccy 2016-03-23 10:34:26 +08:00
parent eb898736f3
commit 9de71bb6b4
8 changed files with 2028 additions and 2053 deletions

View File

@ -3144,7 +3144,10 @@
} }
_status.characterLoaded=true; _status.characterLoaded=true;
if(_status.waitingForCharacters){ if(_status.waitingForCharacters){
game.resume(); game.createEvent('game',false).content=lib.init.start;
delete lib.init.start;
game.loop();
delete _status.waitingForCharacters;
} }
if(lib.onCharacterLoad){ if(lib.onCharacterLoad){
lib.onCharacterLoad(); lib.onCharacterLoad();
@ -12968,7 +12971,7 @@
}, },
gameDraw:function(player,num){ gameDraw:function(player,num){
var next=game.createEvent('gameDraw'); var next=game.createEvent('gameDraw');
next.player=player; next.player=player||game.me;
if(num==undefined) next.num=4; if(num==undefined) next.num=4;
else next.num=num; else next.num=num;
next.content=function(){ next.content=function(){
@ -13387,6 +13390,24 @@
getExtensionConfig:function(extension,key){ getExtensionConfig:function(extension,key){
return lib.config['extension_'+extension+'_'+key]; return lib.config['extension_'+extension+'_'+key];
}, },
clearModeConfig:function(mode){
if(_status.reloading) return;
var config;
try{
config=JSON.parse(localStorage.getItem(lib.configprefix+'config'));
if(!config||typeof config!='object') throw 'err'
}
catch(err){
config={};
}
for(var i in config){
if(i.substr(i.indexOf('_mode_config')+13)==mode){
delete config[i];
}
}
localStorage.setItem(lib.configprefix+'config',JSON.stringify(config));
localStorage.removeItem(lib.configprefix+mode);
},
addPlayer:function(position,character,character2){ addPlayer:function(position,character,character2){
if(position<0||position>game.players.length+game.dead.length||position==undefined){ if(position<0||position>game.players.length+game.dead.length||position==undefined){
position=Math.ceil(Math.random()*(game.players.length+game.dead.length)); position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
@ -22738,6 +22759,7 @@
for(i in mode[lib.config.mode].get){ for(i in mode[lib.config.mode].get){
get[i]=lib.init.eval(mode[lib.config.mode].get[i]); get[i]=lib.init.eval(mode[lib.config.mode].get[i]);
} }
lib.init.start=mode[lib.config.mode].start;
if(game.onwash){ if(game.onwash){
lib.onwash.push(game.onwash); lib.onwash.push(game.onwash);
delete game.onwash; delete game.onwash;
@ -22760,6 +22782,7 @@
if(i=='ui') continue; if(i=='ui') continue;
if(i=='get') continue; if(i=='get') continue;
if(i=='config') continue; if(i=='config') continue;
if(i=='start') continue;
if(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{}; if(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{};
for(j in mode[lib.config.mode][i]){ for(j in mode[lib.config.mode][i]){
lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]); lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]);
@ -23001,8 +23024,14 @@
} }
delete lib.packageReady; delete lib.packageReady;
ui.create.arena(); ui.create.arena();
game.start(); if(lib.db&&!_status.characterLoaded){
game.loop(); _status.waitingForCharacters=true;
}
else{
game.createEvent('game',false).content=lib.init.start;
delete lib.init.start;
game.loop();
}
} }
if(!mode[lib.config.mode]){ if(!mode[lib.config.mode]){

View File

@ -1,5 +1,6 @@
{ {
"name": "noname", "name": "noname",
"xwalk_version": "1.7.11",
"xwalk_app_version": "1.7.11", "xwalk_app_version": "1.7.11",
"xwalk_package_id": "com.widget.noname", "xwalk_package_id": "com.widget.noname",
"xwalk_android_keep_screen_on":true, "xwalk_android_keep_screen_on":true,

View File

@ -1,5 +1,344 @@
'use strict'; 'use strict';
mode.boss={ mode.boss={
start:function(){
"step 0"
if(lib.config.hiddenCharacterPack.contains('boss')){
game.loadPackage('character/boss');
}
"step 1"
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();
return;
}
for(var i in lib.skill){
if(lib.skill[i].changeSeat){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
}
}
lib.init.css('layout/mode','boss');
game.delay(0.1);
"step 2"
var bosslist=ui.create.div('#bosslist.hidden');
event.bosslist=bosslist;
bosslist.ontouchmove = ui.click.touchScroll;
bosslist.style.WebkitOverflowScrolling='touch';
if(!lib.config.touchscreen&&lib.config.mousewheel){
bosslist._scrollspeed=30;
bosslist._scrollnum=10;
bosslist.onmousewheel=ui.click.mousewheel;
}
var bosslistlinks={};
var toggleBoss=function(bool){
game.saveConfig(this._link.config._name,bool,true);
var node=bosslistlinks[this._link.config._name];
if(bool){
node.style.display='';
}
else{
node.style.display='none';
}
};
var onpause=function(){
ui.window.classList.add('bosspaused');
}
var onresume=function(){
ui.window.classList.remove('bosspaused');
}
game.onpause=onpause;
game.onpause2=onpause;
game.onresume=onresume;
game.onresume2=onresume;
ui.create.div(bosslist);
event.current=null;
var list=[];
for(var i in lib.character){
var info=lib.character[i];
if(info[4].contains('boss')&&!lib.config.banned.contains(i)){
var cfg=i+'_bossconfig';
if(get.config(cfg)==undefined){
game.saveConfig(cfg,true,true);
}
lib.translate[cfg+'_config']=lib.translate[i];
lib.config.current_mode.push([cfg,get.config(cfg),toggleBoss]);
lib.mode.boss.config[cfg]={
name:get.translation(i),
onclick:toggleBoss,
init:true,
}
var player=ui.create.player(bosslist).init(i);
list.push(player);
player.node.hp.classList.add('text');
player.node.hp.dataset.condition='';
player.node.hp.innerHTML=info[2];
if(info[2]==Infinity){
player.node.hp.innerHTML='∞';
}
player.setIdentity(player.name);
player.node.identity.dataset.color=info[5];
bosslistlinks[cfg]=player;
player.classList.add('bossplayer');
if(lib.storage.current==i){
event.current=player;
player.classList.add('highlight');
}
if(!get.config(cfg)){
player.style.display='none';
}
}
}
if(!list.length){
alert('挑战模式不可隐藏boss武将包请在选项其它中选择“重置隐藏扩展包”');
event.finish();
_status.over=true;
return;
}
if(!event.current){
event.current=bosslist.childNodes[1];
event.current.classList.add('highlight');
}
ui.create.div(bosslist);
lib.translate.boss_pangtong='涅槃凤雏';
ui.create.cards();
game.finishCards();
ui.arena.dataset.number=8;
ui.control.style.transitionProperty='opacity';
ui.control.classList.add('bosslist');
setTimeout(function(){
ui.control.style.transitionProperty='';
},1000);
ui.window.appendChild(bosslist);
setTimeout(function(){
if(event.current){
var left=event.current.offsetLeft-(ui.window.offsetWidth-180)/2;
if(bosslist.scrollLeft<left){
bosslist.scrollLeft=left;
}
}
bosslist.show();
},200);
game.me=ui.create.player();
if(lib.config.continue_name_boss){
event.noslide=true;
}
else{
game.chooseCharacter(function(target){
if(event.current){
event.current.classList.remove('highlight');
}
event.current=target;
game.save('current',target.name);
target.classList.add('highlight');
});
}
if(lib.storage.test){
event.current.classList.remove('highlight');
if(event.current.nextSibling&&event.current.nextSibling.classList.contains('player')){
event.current=event.current.nextSibling;
}
else{
event.current=event.current.parentNode.childNodes[1];
}
lib.config.game_speed='vfast';
_status.auto=true;
ui.auto.classList.add('glow');
game.save('current',event.current.name);
}
"step 3"
game.bossinfo=lib.boss.global;
for(var i in lib.boss[event.current.name]){
game.bossinfo[i]=lib.boss[event.current.name][i];
}
delete lib.boss;
setTimeout(function(){
ui.control.classList.remove('bosslist');
},500);
var rect=event.current.getBoundingClientRect();
var boss=ui.create.player().init(event.current.name);
game.boss=boss;
boss.side=true;
if(!event.noslide){
// boss.classList.add('bossplayer');
// boss.classList.add('highlight');
boss.animate('bossing');
boss.node.hp.animate('start');
boss.style.left=(rect.left-ui.arena.offsetLeft)+'px';
boss.style.top=(rect.top-ui.arena.offsetTop)+'px';
}
boss.setIdentity('zhu');
boss.identity='zhu';
if(lib.config.continue_name_boss){
result=lib.config.continue_name_boss;
game.saveConfig('continue_name_boss');
}
for(var i=0;i<result.links.length;i++){
var player=ui.create.player(ui.arena).init(result.links[i]).animate('start');
player.setIdentity('cai');
player.identity='cai';
player.side=false;
game.players.push(player);
if(result.boss){
player.dataset.position=(i+1)*2;
}
else{
player.dataset.position=i+1;
}
}
if(result.boss){
game.players.unshift(boss);
boss.dataset.position=0;
}
else{
game.players.push(boss);
boss.dataset.position=7;
}
ui.create.me();
if(game.me!==boss){
game.singleHandcard=true;
ui.arena.classList.add('single-handcard');
ui.fakeme=ui.create.div('.fakeme.avatar',ui.me);
// ui.fakeme.dataset.position=0;
// ui.fakeme.line=lib.element.player.line;
// ui.fakemebg=ui.create.div('.avatar',ui.fakeme).hide();
// ui.refresh(ui.fakemebg);
game.onSwapControl();
// ui.fakemebg.show();
lib.setPopped(ui.create.system('手牌',null,true),function(){
var uiintro=ui.create.dialog('hidden');
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
if(players[i].side==game.me.side&&players[i]!=game.me){
uiintro.add(get.translation(players[i]));
var cards=players[i].get('h');
if(cards.length){
uiintro.addSmall(cards,true);
}
else{
uiintro.add('(无)');
}
}
}
return uiintro;
},220);
}
lib.setPopped(ui.create.system('重整',null,true),function(){
var uiintro=ui.create.dialog('hidden');
uiintro.add('重整');
var table=ui.create.div('.bosschongzheng');
var tr,td,added=false;
for(var i=0;i<game.dead.length;i++){
if(typeof game.dead[i].storage.boss_chongzheng!=='number') continue;
added=true;
tr=ui.create.div(table);
td=ui.create.div(tr);
td.innerHTML=get.translation(game.dead[i]);
td=ui.create.div(tr);
if(game.dead[i].maxHp>0){
td.innerHTML='剩余'+get.cnNumber(game.bossinfo.chongzheng-game.dead[i].storage.boss_chongzheng)+'回合';
}
else{
td.innerHTML='无法重整'
}
}
if(!added){
uiintro.add('<div class="text center">(无重整角色)</div>');
uiintro.add(ui.create.div('.placeholder.slim'))
}
else{
uiintro.add(table);
}
return uiintro;
},180);
ui.single_swap=ui.create.system('换人',function(){
var players=get.players(game.me);
players.remove(game.boss);
if(players.length>1){
if(ui.auto.classList.contains('hidden')){
game.me.popup('请稍后换人');
return;
}
if(_status.event.isMine()){
ui.click.auto();
setTimeout(function(){
ui.click.auto();
},500);
}
game.modeSwapPlayer(players[1]);
}
},true);
if(get.config('single_control')||game.me==game.boss){
ui.single_swap.style.display='none';
}
ui.arena.appendChild(boss);
ui.refresh(boss);
boss.classList.remove('highlight');
boss.classList.remove('bossplayer');
boss.style.left='';
boss.style.top='';
boss.style.position='';
event.bosslist.delete();
game.arrangePlayers();
for(var i=0;i<game.players.length;i++){
game.players[i].node.action.innerHTML='行动';
}
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
identity:players[i].identity,
position:players[i].dataset.position
});
}
_status.videoInited=true,
info.boss=(game.me==game.boss);
game.addVideo('init',null,info);
if(game.bossinfo.init){
game.bossinfo.init();
}
"step 5"
event.trigger('gameStart');
game.gameDraw(game.boss);
game.bossPhaseLoop();
setTimeout(function(){
ui.updatehl();
},200);
},
element:{ element:{
player:{ player:{
dieAfter:function(){ dieAfter:function(){
@ -63,353 +402,6 @@ mode.boss={
var name=[str,str2]; var name=[str,str2];
return name; return name;
}, },
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
if(lib.db&&!_status.characterLoaded){
_status.waitingForCharacters=true;
game.pause();
}
"step 1"
if(lib.config.hiddenCharacterPack.contains('boss')){
game.loadPackage('character/boss');
}
"step 2"
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();
return;
}
for(var i in lib.skill){
if(lib.skill[i].changeSeat){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
}
}
lib.init.css('layout/mode','boss');
game.delay(0.1);
"step 3"
var bosslist=ui.create.div('#bosslist.hidden');
event.bosslist=bosslist;
bosslist.ontouchmove = ui.click.touchScroll;
bosslist.style.WebkitOverflowScrolling='touch';
if(!lib.config.touchscreen&&lib.config.mousewheel){
bosslist._scrollspeed=30;
bosslist._scrollnum=10;
bosslist.onmousewheel=ui.click.mousewheel;
}
var bosslistlinks={};
var toggleBoss=function(bool){
game.saveConfig(this._link.config._name,bool,true);
var node=bosslistlinks[this._link.config._name];
if(bool){
node.style.display='';
}
else{
node.style.display='none';
}
};
var onpause=function(){
ui.window.classList.add('bosspaused');
}
var onresume=function(){
ui.window.classList.remove('bosspaused');
}
game.onpause=onpause;
game.onpause2=onpause;
game.onresume=onresume;
game.onresume2=onresume;
ui.create.div(bosslist);
event.current=null;
var list=[];
for(var i in lib.character){
var info=lib.character[i];
if(info[4].contains('boss')&&!lib.config.banned.contains(i)){
var cfg=i+'_bossconfig';
if(get.config(cfg)==undefined){
game.saveConfig(cfg,true,true);
}
lib.translate[cfg+'_config']=lib.translate[i];
lib.config.current_mode.push([cfg,get.config(cfg),toggleBoss]);
lib.mode.boss.config[cfg]={
name:get.translation(i),
onclick:toggleBoss,
init:true,
}
var player=ui.create.player(bosslist).init(i);
list.push(player);
player.node.hp.classList.add('text');
player.node.hp.dataset.condition='';
player.node.hp.innerHTML=info[2];
if(info[2]==Infinity){
player.node.hp.innerHTML='∞';
}
player.setIdentity(player.name);
player.node.identity.dataset.color=info[5];
bosslistlinks[cfg]=player;
player.classList.add('bossplayer');
if(lib.storage.current==i){
event.current=player;
player.classList.add('highlight');
}
if(!get.config(cfg)){
player.style.display='none';
}
}
}
if(!list.length){
alert('挑战模式不可隐藏boss武将包请在选项其它中选择“重置隐藏扩展包”');
event.finish();
_status.over=true;
return;
}
if(!event.current){
event.current=bosslist.childNodes[1];
event.current.classList.add('highlight');
}
ui.create.div(bosslist);
lib.translate.boss_pangtong='涅槃凤雏';
ui.create.cards();
game.finishCards();
ui.arena.dataset.number=8;
ui.control.style.transitionProperty='opacity';
ui.control.classList.add('bosslist');
setTimeout(function(){
ui.control.style.transitionProperty='';
},1000);
ui.window.appendChild(bosslist);
setTimeout(function(){
if(event.current){
var left=event.current.offsetLeft-(ui.window.offsetWidth-180)/2;
if(bosslist.scrollLeft<left){
bosslist.scrollLeft=left;
}
}
bosslist.show();
},200);
game.me=ui.create.player();
if(lib.config.continue_name_boss){
event.noslide=true;
}
else{
game.chooseCharacter(function(target){
if(event.current){
event.current.classList.remove('highlight');
}
event.current=target;
game.save('current',target.name);
target.classList.add('highlight');
});
}
if(lib.storage.test){
event.current.classList.remove('highlight');
if(event.current.nextSibling&&event.current.nextSibling.classList.contains('player')){
event.current=event.current.nextSibling;
}
else{
event.current=event.current.parentNode.childNodes[1];
}
lib.config.game_speed='vfast';
_status.auto=true;
ui.auto.classList.add('glow');
game.save('current',event.current.name);
}
"step 4"
game.bossinfo=lib.boss.global;
for(var i in lib.boss[event.current.name]){
game.bossinfo[i]=lib.boss[event.current.name][i];
}
delete lib.boss;
setTimeout(function(){
ui.control.classList.remove('bosslist');
},500);
var rect=event.current.getBoundingClientRect();
var boss=ui.create.player().init(event.current.name);
game.boss=boss;
boss.side=true;
if(!event.noslide){
// boss.classList.add('bossplayer');
// boss.classList.add('highlight');
boss.animate('bossing');
boss.node.hp.animate('start');
boss.style.left=(rect.left-ui.arena.offsetLeft)+'px';
boss.style.top=(rect.top-ui.arena.offsetTop)+'px';
}
boss.setIdentity('zhu');
boss.identity='zhu';
if(lib.config.continue_name_boss){
result=lib.config.continue_name_boss;
game.saveConfig('continue_name_boss');
}
for(var i=0;i<result.links.length;i++){
var player=ui.create.player(ui.arena).init(result.links[i]).animate('start');
player.setIdentity('cai');
player.identity='cai';
player.side=false;
game.players.push(player);
if(result.boss){
player.dataset.position=(i+1)*2;
}
else{
player.dataset.position=i+1;
}
}
if(result.boss){
game.players.unshift(boss);
boss.dataset.position=0;
}
else{
game.players.push(boss);
boss.dataset.position=7;
}
ui.create.me();
if(game.me!==boss){
game.singleHandcard=true;
ui.arena.classList.add('single-handcard');
ui.fakeme=ui.create.div('.fakeme.avatar',ui.me);
// ui.fakeme.dataset.position=0;
// ui.fakeme.line=lib.element.player.line;
// ui.fakemebg=ui.create.div('.avatar',ui.fakeme).hide();
// ui.refresh(ui.fakemebg);
game.onSwapControl();
// ui.fakemebg.show();
lib.setPopped(ui.create.system('手牌',null,true),function(){
var uiintro=ui.create.dialog('hidden');
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
if(players[i].side==game.me.side&&players[i]!=game.me){
uiintro.add(get.translation(players[i]));
var cards=players[i].get('h');
if(cards.length){
uiintro.addSmall(cards,true);
}
else{
uiintro.add('(无)');
}
}
}
return uiintro;
},220);
}
lib.setPopped(ui.create.system('重整',null,true),function(){
var uiintro=ui.create.dialog('hidden');
uiintro.add('重整');
var table=ui.create.div('.bosschongzheng');
var tr,td,added=false;
for(var i=0;i<game.dead.length;i++){
if(typeof game.dead[i].storage.boss_chongzheng!=='number') continue;
added=true;
tr=ui.create.div(table);
td=ui.create.div(tr);
td.innerHTML=get.translation(game.dead[i]);
td=ui.create.div(tr);
if(game.dead[i].maxHp>0){
td.innerHTML='剩余'+get.cnNumber(game.bossinfo.chongzheng-game.dead[i].storage.boss_chongzheng)+'回合';
}
else{
td.innerHTML='无法重整'
}
}
if(!added){
uiintro.add('<div class="text center">(无重整角色)</div>');
uiintro.add(ui.create.div('.placeholder.slim'))
}
else{
uiintro.add(table);
}
return uiintro;
},180);
ui.single_swap=ui.create.system('换人',function(){
var players=get.players(game.me);
players.remove(game.boss);
if(players.length>1){
if(ui.auto.classList.contains('hidden')){
game.me.popup('请稍后换人');
return;
}
if(_status.event.isMine()){
ui.click.auto();
setTimeout(function(){
ui.click.auto();
},500);
}
game.modeSwapPlayer(players[1]);
}
},true);
if(get.config('single_control')||game.me==game.boss){
ui.single_swap.style.display='none';
}
ui.arena.appendChild(boss);
ui.refresh(boss);
boss.classList.remove('highlight');
boss.classList.remove('bossplayer');
boss.style.left='';
boss.style.top='';
boss.style.position='';
event.bosslist.delete();
game.arrangePlayers();
for(var i=0;i<game.players.length;i++){
game.players[i].node.action.innerHTML='行动';
}
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
identity:players[i].identity,
position:players[i].dataset.position
});
}
_status.videoInited=true,
info.boss=(game.me==game.boss);
game.addVideo('init',null,info);
if(game.bossinfo.init){
game.bossinfo.init();
}
"step 5"
event.trigger('gameStart');
game.gameDraw(game.boss);
game.bossPhaseLoop();
setTimeout(function(){
ui.updatehl();
},200);
}
},
bossPhaseLoop:function(){ bossPhaseLoop:function(){
var next=game.createEvent('phaseLoop'); var next=game.createEvent('phaseLoop');
next.player=game.boss; next.player=game.boss;
@ -794,5 +786,4 @@ mode.boss={
} }
} }
}, },
config:['ban_weak','change_choice','free_choose','']
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,103 @@
'use strict'; 'use strict';
mode.guozhan={ mode.guozhan={
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{
game.prepareArena();
game.delay();
game.showChangeLog();
}
"step 1"
if(lib.storage.test){
lib.config.game_speed='vfast';
lib.config.low_performance=true;
_status.auto=true;
ui.auto.classList.add('glow');
}
for(var i=0;i<game.players.length;i++){
game.players[i].node.name.hide();
game.players[i].node.name2.hide();
}
game.chooseCharacter();
"step 2"
if(ui.coin){
_status.coinCoeff=get.coinCoeff([game.me.name1,game.me.name2]);
}
if(lib.storage.test){
var str='';
for(var i=0;i<game.players.length;i++){
str+=get.translation(game.players[i].name1)+' '+get.translation(game.players[i].name2)+'; ';
}
console.log(str);
}
var player;
if(_status.cheat_seat){
var seat=_status.cheat_seat.link;
if(seat==0){
player=game.me;
}
else{
player=game.players[game.players.length-seat];
}
if(!player) player=game.me;
delete _status.cheat_seat;
}
else{
player=game.players[Math.floor(Math.random()*game.players.length)];
}
event.trigger('gameStart');
game.gameDraw(player);
for(var i=0;i<game.players.length;i++){
game.players[i].name='unknown'+get.distance(player,game.players[i],'absolute');
game.players[i].node.name_seat=ui.create.div('.name.name_seat',get.verticalStr(lib.translate[game.players[i].name]),game.players[i]);
if(game.players[i]==game.me){
lib.translate[game.players[i].name]+='(你)';
}
}
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:game.players[i].name,
translate:lib.translate[game.players[i].name],
name1:players[i].name1,
name2:players[i].name2,
});
}
_status.videoInited=true,
game.addVideo('init',null,info);
if(get.config('guozhan_mode')=='mingjiang'){
game.showIdentity(true);
}
else{
for(var i=0;i<game.players.length;i++){
game.players[i].ai.shown=0;
}
}
game.phaseLoop(player);
},
game:{ game:{
addRecord:function(bool){ addRecord:function(bool){
if(typeof bool=='boolean'){ if(typeof bool=='boolean'){
@ -69,112 +167,6 @@ mode.guozhan={
var name=[str,str2]; var name=[str,str2];
return name; return name;
}, },
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
if(lib.db&&!_status.characterLoaded){
_status.waitingForCharacters=true;
game.pause();
}
"step 1"
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{
game.prepareArena();
game.delay();
game.showChangeLog();
}
"step 2"
if(lib.storage.test){
lib.config.game_speed='vfast';
lib.config.low_performance=true;
_status.auto=true;
ui.auto.classList.add('glow');
}
for(var i=0;i<game.players.length;i++){
game.players[i].node.name.hide();
game.players[i].node.name2.hide();
}
game.chooseCharacter();
"step 3"
if(ui.coin){
_status.coinCoeff=get.coinCoeff([game.me.name1,game.me.name2]);
}
if(lib.storage.test){
var str='';
for(var i=0;i<game.players.length;i++){
str+=get.translation(game.players[i].name1)+' '+get.translation(game.players[i].name2)+'; ';
}
console.log(str);
}
var player;
if(_status.cheat_seat){
var seat=_status.cheat_seat.link;
if(seat==0){
player=game.me;
}
else{
player=game.players[game.players.length-seat];
}
if(!player) player=game.me;
delete _status.cheat_seat;
}
else{
player=game.players[Math.floor(Math.random()*game.players.length)];
}
event.trigger('gameStart');
game.gameDraw(player);
for(var i=0;i<game.players.length;i++){
game.players[i].name='unknown'+get.distance(player,game.players[i],'absolute');
game.players[i].node.name_seat=ui.create.div('.name.name_seat',get.verticalStr(lib.translate[game.players[i].name]),game.players[i]);
if(game.players[i]==game.me){
lib.translate[game.players[i].name]+='(你)';
}
}
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:game.players[i].name,
translate:lib.translate[game.players[i].name],
name1:players[i].name1,
name2:players[i].name2,
});
}
_status.videoInited=true,
game.addVideo('init',null,info);
if(get.config('guozhan_mode')=='mingjiang'){
game.showIdentity(true);
}
else{
for(var i=0;i<game.players.length;i++){
game.players[i].ai.shown=0;
}
}
game.phaseLoop(player);
}
},
showIdentity:function(started){ showIdentity:function(started){
if(game.phaseNumber==0&&!started) return; if(game.phaseNumber==0&&!started) return;
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
@ -950,7 +942,4 @@ mode.guozhan={
}, },
} }
}, },
config:['player_number','initshow_draw',
'free_choose','change_identity','change_choice','change_card',
'swap','dierestart','revive','double_hp','difficulty']
} }

View File

@ -1,5 +1,208 @@
'use strict'; 'use strict';
mode.identity={ mode.identity={
start:function(){
"step 0"
if(!lib.config.new_tutorial){
ui.arena.classList.add('only_dialog');
}
_status.mode=get.config('identity_mode');
"step 1"
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.mode=='zhong'){
game.prepareArena(8);
}
else{
game.prepareArena();
}
if(!lib.config.new_tutorial){
game.delay();
}
}
"step 2"
if(!lib.config.new_tutorial){
game.saveConfig('version',lib.version);
var clear=function(){
ui.dialog.close();
while(ui.controls.length) ui.controls[0].close();
};
var clear2=function(){
ui.auto.show();
ui.arena.classList.remove('only_dialog');
};
var step1=function(){
ui.create.dialog('欢迎来到无名杀,是否进入新手向导?');
game.saveConfig('new_tutorial',true);
ui.dialog.add('<div class="text center">跳过后,你可以在选项-其它中重置新手向导');
ui.auto.hide();
ui.create.control('跳过向导',function(){
clear();
clear2();
game.resume();
});
ui.create.control('继续',step2);
}
var step2=function(){
if(lib.config.layout!='phone'){
clear();
ui.create.dialog('如果你在使用手机,可能会觉得按钮有点小'+
',将布局改成移动可以使按钮变大');
ui.dialog.add('<div class="text center">你可以在选项-外观-布局中更改此设置');
var lcontrol=ui.create.control('使用移动布局',function(){
if(lib.config.layout=='phone'){
ui.control.firstChild.firstChild.innerHTML='使用移动布局';
lib.init.layout('mobile');
}
else{
ui.control.firstChild.firstChild.innerHTML='使用默认布局';
lib.init.layout('phone');
}
});
ui.create.control('继续',step3);
}
else{
step3();
}
};
var step3=function(){
if(lib.config.touchscreen){
clear();
ui.create.dialog('触屏模式中,下划可以显示菜单,上划可以切换托管,双指单击可以暂停');
ui.dialog.add('<div class="text center">你可以在选项-通用-中更改手势设置');
ui.create.control('继续',step4);
}
else{
step4();
}
};
var step4=function(){
clear();
ui.window.classList.add('noclick_important');
ui.click.configMenu();
ui.control.classList.add('noclick_click_important');
ui.control.style.top='calc(100% - 105px)';
ui.create.control('在菜单中,可以进行各项设置',function(){
ui.click.menuTab('选项');
ui.controls[0].replace('如果你感到游戏较卡,可以开启流畅模式',function(){
ui.controls[0].replace('在技能一栏中,可以设置自动发动或双将禁配的技能',function(){
ui.click.menuTab('武将');
ui.controls[0].replace('在武将或卡牌一栏中,单击武将/卡牌可以将其禁用',function(){
ui.click.menuTab('战局');
ui.controls[0].replace('在战局中可以输入游戏命令,或者管理录像',function(){
ui.click.configMenu();
ui.window.classList.remove('noclick_important');
ui.control.classList.remove('noclick_click_important');
ui.control.style.top='';
step5();
});
});
});
});
})
};
var step5=function(){
clear();
ui.create.dialog('如果还有其它问题,欢迎来到百度无名杀吧进行交流');
ui.create.control('完成',function(){
clear();
clear2();
game.resume();
})
};
game.pause();
step1();
}
else{
game.showChangeLog();
}
"step 3"
if(lib.storage.test){
lib.config.game_speed='vfast';
_status.auto=true;
ui.auto.classList.add('glow');
}
game.chooseCharacter();
"step 4"
if(ui.coin){
_status.coinCoeff=get.coinCoeff([game.me.name]);
}
if(game.players.length==2){
game.showIdentity(true);
}
else{
for(var i=0;i<game.players.length;i++){
game.players[i].ai.shown=0;
}
}
game.zhu.ai.shown=1;
if(game.zhu2){
game.zhong=game.zhu;
game.zhu=game.zhu2;
delete game.zhu2;
}
if(_status.mode!='zhong'&&get.config('enhance_zhu')&&get.population('fan')>=3){
var skill;
switch(game.zhu.name){
case 'liubei':skill='jizhen';break;
case 'dongzhuo':skill='hengzheng';break;
case 'sunquan':skill='batu';break;
case 'sp_zhangjiao':skill='tiangong';break;
case 'liushan':skill='shengxi';break;
case 'sunce':skill='ciqiu';break;
case 'yuanshao':skill='geju';break;
case 're_caocao':skill='dangping';break;
case 'caopi':skill='junxing';break;
case 'liuxie':skill='moukui';break;
default:skill='tianming';break;
}
game.zhu.addSkill(skill);
game.zhu.storage.enhance_zhu=skill;
}
if(lib.storage.test){
var str='';
for(var i=0;i<game.players.length;i++){
str+=get.translation(game.players[i]);
if(game.players[i]==game.zhu) str+='(主)';
str+=' ';
}
console.log(str);
game.showIdentity();
}
event.trigger('gameStart');
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
name2:players[i].name2,
identity:players[i].identity
});
}
_status.videoInited=true,
game.addVideo('init',null,info);
game.gameDraw(game.zhong||game.zhu);
game.phaseLoop(game.zhong||game.zhu);
},
game:{ game:{
getIdentityList:function(player){ getIdentityList:function(player){
if(player.identityShown) return; if(player.identityShown) return;
@ -71,216 +274,6 @@ mode.identity={
game.saveConfig('gameRecord',lib.config.gameRecord); game.saveConfig('gameRecord',lib.config.gameRecord);
} }
}, },
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
if(lib.db&&!_status.characterLoaded){
_status.waitingForCharacters=true;
game.pause();
}
if(!lib.config.new_tutorial){
ui.arena.classList.add('only_dialog');
}
_status.mode=get.config('identity_mode');
"step 1"
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.mode=='zhong'){
game.prepareArena(8);
}
else{
game.prepareArena();
}
if(!lib.config.new_tutorial){
game.delay();
}
}
"step 2"
if(!lib.config.new_tutorial){
game.saveConfig('version',lib.version);
var clear=function(){
ui.dialog.close();
while(ui.controls.length) ui.controls[0].close();
};
var clear2=function(){
ui.auto.show();
ui.arena.classList.remove('only_dialog');
};
var step1=function(){
ui.create.dialog('欢迎来到无名杀,是否进入新手向导?');
game.saveConfig('new_tutorial',true);
ui.dialog.add('<div class="text center">跳过后,你可以在选项-其它中重置新手向导');
ui.auto.hide();
ui.create.control('跳过向导',function(){
clear();
clear2();
game.resume();
});
ui.create.control('继续',step2);
}
var step2=function(){
if(lib.config.layout!='phone'){
clear();
ui.create.dialog('如果你在使用手机,可能会觉得按钮有点小'+
',将布局改成移动可以使按钮变大');
ui.dialog.add('<div class="text center">你可以在选项-外观-布局中更改此设置');
var lcontrol=ui.create.control('使用移动布局',function(){
if(lib.config.layout=='phone'){
ui.control.firstChild.firstChild.innerHTML='使用移动布局';
lib.init.layout('mobile');
}
else{
ui.control.firstChild.firstChild.innerHTML='使用默认布局';
lib.init.layout('phone');
}
});
ui.create.control('继续',step3);
}
else{
step3();
}
};
var step3=function(){
if(lib.config.touchscreen){
clear();
ui.create.dialog('触屏模式中,下划可以显示菜单,上划可以切换托管,双指单击可以暂停');
ui.dialog.add('<div class="text center">你可以在选项-通用-中更改手势设置');
ui.create.control('继续',step4);
}
else{
step4();
}
};
var step4=function(){
clear();
ui.window.classList.add('noclick_important');
ui.click.configMenu();
ui.control.classList.add('noclick_click_important');
ui.control.style.top='calc(100% - 105px)';
ui.create.control('在菜单中,可以进行各项设置',function(){
ui.click.menuTab('选项');
ui.controls[0].replace('如果你感到游戏较卡,可以开启流畅模式',function(){
ui.controls[0].replace('在技能一栏中,可以设置自动发动或双将禁配的技能',function(){
ui.click.menuTab('武将');
ui.controls[0].replace('在武将或卡牌一栏中,单击武将/卡牌可以将其禁用',function(){
ui.click.menuTab('战局');
ui.controls[0].replace('在战局中可以输入游戏命令,或者管理录像',function(){
ui.click.configMenu();
ui.window.classList.remove('noclick_important');
ui.control.classList.remove('noclick_click_important');
ui.control.style.top='';
step5();
});
});
});
});
})
};
var step5=function(){
clear();
ui.create.dialog('如果还有其它问题,欢迎来到百度无名杀吧进行交流');
ui.create.control('完成',function(){
clear();
clear2();
game.resume();
})
};
game.pause();
step1();
}
else{
game.showChangeLog();
}
"step 3"
if(lib.storage.test){
lib.config.game_speed='vfast';
_status.auto=true;
ui.auto.classList.add('glow');
}
game.chooseCharacter();
"step 4"
if(ui.coin){
_status.coinCoeff=get.coinCoeff([game.me.name]);
}
if(game.players.length==2){
game.showIdentity(true);
}
else{
for(var i=0;i<game.players.length;i++){
game.players[i].ai.shown=0;
}
}
game.zhu.ai.shown=1;
if(game.zhu2){
game.zhong=game.zhu;
game.zhu=game.zhu2;
delete game.zhu2;
}
if(_status.mode!='zhong'&&get.config('enhance_zhu')&&get.population('fan')>=3){
var skill;
switch(game.zhu.name){
case 'liubei':skill='jizhen';break;
case 'dongzhuo':skill='hengzheng';break;
case 'sunquan':skill='batu';break;
case 'sp_zhangjiao':skill='tiangong';break;
case 'liushan':skill='shengxi';break;
case 'sunce':skill='ciqiu';break;
case 'yuanshao':skill='geju';break;
case 're_caocao':skill='dangping';break;
case 'caopi':skill='junxing';break;
case 'liuxie':skill='moukui';break;
default:skill='tianming';break;
}
game.zhu.addSkill(skill);
game.zhu.storage.enhance_zhu=skill;
}
if(lib.storage.test){
var str='';
for(var i=0;i<game.players.length;i++){
str+=get.translation(game.players[i]);
if(game.players[i]==game.zhu) str+='(主)';
str+=' ';
}
console.log(str);
game.showIdentity();
}
event.trigger('gameStart');
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
name2:players[i].name2,
identity:players[i].identity
});
}
_status.videoInited=true,
game.addVideo('init',null,info);
game.gameDraw(game.zhong||game.zhu);
game.phaseLoop(game.zhong||game.zhu);
}
},
showIdentity:function(me){ showIdentity:function(me){
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
// if(me===false&&game.players[i]==game.me) continue; // if(me===false&&game.players[i]==game.me) continue;
@ -1236,8 +1229,4 @@ mode.identity={
} }
} }
}, },
config:['player_number','double_character','double_hp',
'ban_weak','enhance_zhu','free_choose','change_identity',
'change_choice','change_card','dierestart','swap','revive',
'auto_identity','ai_strategy','ai_identity','difficulty']
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,250 @@
'use strict'; 'use strict';
mode.versus={ mode.versus={
start:function(){
"step 0"
_status.mode=get.config('versus_mode');
"step 1"
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();
return;
}
if(_status.mode=='jiange'||_status.mode=='four'){
game.prepareArena(8);
// game.pause();
}
else{
if(lib.storage.choice==undefined) game.save('choice',20);
if(lib.storage.zhu==undefined) game.save('zhu',true);
if(lib.storage.noreplace_end==undefined) game.save('noreplace_end',true);
if(get.config('first_less')==undefined) game.saveConfig('first_less',true,true);
if(lib.storage.autoreplaceinnerhtml==undefined) game.save('autoreplaceinnerhtml',true);
if(lib.storage.single_control==undefined) game.save('single_control',true);
if(lib.storage.number==undefined) game.save('number',3);
if(lib.storage.versus_reward==undefined) game.save('versus_reward',3);
if(lib.storage.versus_punish==undefined) game.save('versus_punish','弃牌');
if(lib.storage.replace_number==undefined) game.save('replace_number',3);
switch(lib.storage.seat_order){
case '交叉':lib.storage.cross_seat=true;lib.storage.random_seat=false;break;
case '随机':lib.storage.cross_seat=false;lib.storage.random_seat=true;break;
default:lib.storage.cross_seat=false;lib.storage.random_seat=false;
}
game.save('only_zhu',true);
game.save('control_all',true);
ui.wuxie.hide();
ui.create.cards();
game.finishCards();
}
game.delay();
"step 2"
if(_status.mode=='four'){
var list=['zhu','zhong','zhong','zhong','ezhu','ezhong','ezhong','ezhong'];
list.randomSort();
var side=Math.random()<0.5;
for(var i=0;i<8;i++){
if(list[i][0]=='e'){
game.players[i].side=side;
game.players[i].identity=list[i].slice(1);
}
else{
game.players[i].side=!side;
game.players[i].identity=list[i];
}
if(game.players[i].identity=='zhu'){
game[game.players[i].side+'Zhu']=game.players[i];
game.players[i].isZhu=true;
}
game.players[i].setIdentity(game.players[i].identity);
game.players[i].node.identity.dataset.color=get.translation(game.players[i].side+'Color');
}
game.chooseCharacterFour();
}
else if(_status.mode=='jiange'){
var list=['shumech','shu','shuboss','shu','wei','weiboss','wei','weimech'];
var pos=Math.floor(Math.random()*8);
for(var i=0;i<8;i++){
var j=pos+i;
if(j>=8){
j-=8;
}
if(list[i][0]=='w'){
game.players[j].side=true;
game.players[j].setIdentity('wei');
game.players[j].identity='wei';
}
else{
game.players[j].side=false;
game.players[j].setIdentity('shu');
game.players[j].identity='shu';
}
if(list[i].indexOf('mech')!=-1){
game.players[j].type='mech';
}
else if(list[i].indexOf('boss')!=-1){
game.players[j].type='boss';
}
else{
game.players[j].type='human';
}
}
game.chooseCharacterJiange();
}
else{
game.chooseCharacter();
}
"step 3"
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
name2:players[i].name2,
identity:players[i].node.identity.firstChild.innerHTML,
color:players[i].node.identity.dataset.color
});
}
_status.videoInited=true;
if(_status.mode=='four'||_status.mode=='jiange'){
info.push(false);
}
else{
info.push(lib.storage.single_control&&lib.storage.control_all&&game.players.length>=4);
}
game.addVideo('init',null,info);
event.trigger('gameStart');
if(_status.mode=='four'){
game.gameDraw(_status.firstAct,function(player){
if(player==_status.firstAct.previousSeat){
return 5;
}
return 4;
});
if(game.me==_status.firstAct.previous||game.me==_status.firstAct.previous.previous){
game.me.chooseBool('是否置换手牌?');
event.replaceCard=true;
}
}
else if(_status.mode=='jiange'){
var firstAct;
for(var i=0;i<game.players.length;i++){
if(game.players[i].type=='mech'&&game.players[i].group=='wei'){
firstAct=game.players[i];break;
}
}
_status.actlist=[
firstAct,
firstAct.next,
firstAct.previous,
firstAct.next.next,
firstAct.previous.previous,
firstAct.next.next.next,
firstAct.previous.previous.previous,
firstAct.next.next.next.next
];
game.gameDraw(firstAct);
game.phaseLoopJiange();
}
else{
var firstAct;
if(lib.storage.zhu){
firstAct=(_status.currentSide==game.me.side)?game.friendZhu:game.enemyZhu;
}
else{
if(!lib.storage.cross_seat&&!lib.storage.random_seat&&lib.storage.number>1){
for(var i=0;i<game.players.length-1;i++){
if(game.players[i].side!=game.players[i+1].side){
var actcount;
if(Math.random()<0.5){
actcount=i;
}
else{
if(i>=lib.storage.number){
actcount=i-lib.storage.number;
}
else{
actcount=i+lib.storage.number;
}
}
if(actcount>0){
actcount--;
}
else{
actcount=game.players.length-1;
}
firstAct=game.players[actcount];
break;
}
}
}
else{
firstAct=game.players[Math.floor(Math.random()*game.players.length)];
}
}
game.gameDraw(firstAct,4);
_status.first_less=true;
_status.round=0;
if(lib.storage.single_control){
lib.skill.global.push('versus_swap');
ui.autoreplace=ui.create.div('.caption.normal');
ui.autoreplace.innerHTML='<div class="underline">自动换人</div>';
ui.autoreplace.style.textAlign='center';
if(lib.storage.autoreplaceinnerhtml){
ui.autoreplace.classList.add('on')
}
ui.autoreplace.listen(game.switchAutoreplace);
// ui.versusreplace=ui.create.system('换人',null,true);
// lib.setPopped(ui.versusreplace,game.versusHoverReplace);
if(game.players.length>2){
ui.versushs=ui.create.system('手牌',null,true);
lib.setPopped(ui.versushs,game.versusHoverHandcards,220);
}
}
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(0,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(0,true),null,true);
// _status.friendCount=ui.create.system('友方',null,true);
// _status.enemyCount=ui.create.system('敌方',null,true);
lib.setPopped(_status.friendCount,game.versusHoverFriend);
lib.setPopped(_status.enemyCount,game.versusHoverEnemy);
if(lib.storage.zhu){
_status.currentSide=true;
game.versusPhaseLoop(firstAct);
}
else{
game.versusPhaseLoop(firstAct);
}
}
if(_status.mode!='four'){
event.finish();
}
"step 4"
if(event.replaceCard&&result.bool){
var hs=game.me.get('h');
for(var i=0;i<hs.length;i++){
ui.discardPile.appendChild(hs[i]);
}
game.me.directgain(get.cards(hs.length));
}
game.phaseLoop(_status.firstAct);
},
game:{ game:{
getVideoName:function(){ getVideoName:function(){
var str=get.translation(game.me.name); var str=get.translation(game.me.name);
@ -35,258 +280,6 @@ mode.versus={
game.saveConfig('gameRecord',lib.config.gameRecord); game.saveConfig('gameRecord',lib.config.gameRecord);
} }
}, },
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
if(lib.db&&!_status.characterLoaded){
_status.waitingForCharacters=true;
game.pause();
}
_status.mode=get.config('versus_mode');
"step 1"
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();
return;
}
if(_status.mode=='jiange'||_status.mode=='four'){
game.prepareArena(8);
// game.pause();
}
else{
if(lib.storage.choice==undefined) game.save('choice',20);
if(lib.storage.zhu==undefined) game.save('zhu',true);
if(lib.storage.noreplace_end==undefined) game.save('noreplace_end',true);
if(get.config('first_less')==undefined) game.saveConfig('first_less',true,true);
if(lib.storage.autoreplaceinnerhtml==undefined) game.save('autoreplaceinnerhtml',true);
if(lib.storage.single_control==undefined) game.save('single_control',true);
if(lib.storage.number==undefined) game.save('number',3);
if(lib.storage.versus_reward==undefined) game.save('versus_reward',3);
if(lib.storage.versus_punish==undefined) game.save('versus_punish','弃牌');
if(lib.storage.replace_number==undefined) game.save('replace_number',3);
switch(lib.storage.seat_order){
case '交叉':lib.storage.cross_seat=true;lib.storage.random_seat=false;break;
case '随机':lib.storage.cross_seat=false;lib.storage.random_seat=true;break;
default:lib.storage.cross_seat=false;lib.storage.random_seat=false;
}
game.save('only_zhu',true);
game.save('control_all',true);
ui.wuxie.hide();
ui.create.cards();
game.finishCards();
}
game.delay();
"step 2"
if(_status.mode=='four'){
var list=['zhu','zhong','zhong','zhong','ezhu','ezhong','ezhong','ezhong'];
list.randomSort();
var side=Math.random()<0.5;
for(var i=0;i<8;i++){
if(list[i][0]=='e'){
game.players[i].side=side;
game.players[i].identity=list[i].slice(1);
}
else{
game.players[i].side=!side;
game.players[i].identity=list[i];
}
if(game.players[i].identity=='zhu'){
game[game.players[i].side+'Zhu']=game.players[i];
game.players[i].isZhu=true;
}
game.players[i].setIdentity(game.players[i].identity);
game.players[i].node.identity.dataset.color=get.translation(game.players[i].side+'Color');
}
game.chooseCharacterFour();
}
else if(_status.mode=='jiange'){
var list=['shumech','shu','shuboss','shu','wei','weiboss','wei','weimech'];
var pos=Math.floor(Math.random()*8);
for(var i=0;i<8;i++){
var j=pos+i;
if(j>=8){
j-=8;
}
if(list[i][0]=='w'){
game.players[j].side=true;
game.players[j].setIdentity('wei');
game.players[j].identity='wei';
}
else{
game.players[j].side=false;
game.players[j].setIdentity('shu');
game.players[j].identity='shu';
}
if(list[i].indexOf('mech')!=-1){
game.players[j].type='mech';
}
else if(list[i].indexOf('boss')!=-1){
game.players[j].type='boss';
}
else{
game.players[j].type='human';
}
}
game.chooseCharacterJiange();
}
else{
game.chooseCharacter();
}
"step 3"
var players=get.players(lib.sort.position);
var info=[];
for(var i=0;i<players.length;i++){
info.push({
name:players[i].name,
name2:players[i].name2,
identity:players[i].node.identity.firstChild.innerHTML,
color:players[i].node.identity.dataset.color
});
}
_status.videoInited=true;
if(_status.mode=='four'||_status.mode=='jiange'){
info.push(false);
}
else{
info.push(lib.storage.single_control&&lib.storage.control_all&&game.players.length>=4);
}
game.addVideo('init',null,info);
event.trigger('gameStart');
if(_status.mode=='four'){
game.gameDraw(_status.firstAct,function(player){
if(player==_status.firstAct.previousSeat){
return 5;
}
return 4;
});
if(game.me==_status.firstAct.previous||game.me==_status.firstAct.previous.previous){
game.me.chooseBool('是否置换手牌?');
event.replaceCard=true;
}
}
else if(_status.mode=='jiange'){
var firstAct;
for(var i=0;i<game.players.length;i++){
if(game.players[i].type=='mech'&&game.players[i].group=='wei'){
firstAct=game.players[i];break;
}
}
_status.actlist=[
firstAct,
firstAct.next,
firstAct.previous,
firstAct.next.next,
firstAct.previous.previous,
firstAct.next.next.next,
firstAct.previous.previous.previous,
firstAct.next.next.next.next
];
game.gameDraw(firstAct);
game.phaseLoopJiange();
}
else{
var firstAct;
if(lib.storage.zhu){
firstAct=(_status.currentSide==game.me.side)?game.friendZhu:game.enemyZhu;
}
else{
if(!lib.storage.cross_seat&&!lib.storage.random_seat&&lib.storage.number>1){
for(var i=0;i<game.players.length-1;i++){
if(game.players[i].side!=game.players[i+1].side){
var actcount;
if(Math.random()<0.5){
actcount=i;
}
else{
if(i>=lib.storage.number){
actcount=i-lib.storage.number;
}
else{
actcount=i+lib.storage.number;
}
}
if(actcount>0){
actcount--;
}
else{
actcount=game.players.length-1;
}
firstAct=game.players[actcount];
break;
}
}
}
else{
firstAct=game.players[Math.floor(Math.random()*game.players.length)];
}
}
game.gameDraw(firstAct,4);
_status.first_less=true;
_status.round=0;
if(lib.storage.single_control){
lib.skill.global.push('versus_swap');
ui.autoreplace=ui.create.div('.caption.normal');
ui.autoreplace.innerHTML='<div class="underline">自动换人</div>';
ui.autoreplace.style.textAlign='center';
if(lib.storage.autoreplaceinnerhtml){
ui.autoreplace.classList.add('on')
}
ui.autoreplace.listen(game.switchAutoreplace);
// ui.versusreplace=ui.create.system('换人',null,true);
// lib.setPopped(ui.versusreplace,game.versusHoverReplace);
if(game.players.length>2){
ui.versushs=ui.create.system('手牌',null,true);
lib.setPopped(ui.versushs,game.versusHoverHandcards,220);
}
}
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(0,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(0,true),null,true);
// _status.friendCount=ui.create.system('友方',null,true);
// _status.enemyCount=ui.create.system('敌方',null,true);
lib.setPopped(_status.friendCount,game.versusHoverFriend);
lib.setPopped(_status.enemyCount,game.versusHoverEnemy);
if(lib.storage.zhu){
_status.currentSide=true;
game.versusPhaseLoop(firstAct);
}
else{
game.versusPhaseLoop(firstAct);
}
}
if(_status.mode!='four'){
event.finish();
}
"step 4"
if(event.replaceCard&&result.bool){
var hs=game.me.get('h');
for(var i=0;i<hs.length;i++){
ui.discardPile.appendChild(hs[i]);
}
game.me.directgain(get.cards(hs.length));
}
game.phaseLoop(_status.firstAct);
}
},
chooseCharacterJiange:function(){ chooseCharacterJiange:function(){
var next=game.createEvent('chooseCharacter',false); var next=game.createEvent('chooseCharacter',false);
next.showConfig=true; next.showConfig=true;
@ -1755,5 +1748,4 @@ mode.versus={
}, },
} }
}, },
config:['change_choice','ban_weak']
} }