战棋模式

This commit is contained in:
libccy 2015-05-08 16:07:38 +08:00
parent 314a9006a9
commit 7cbd9ec9ec
14 changed files with 1474 additions and 174 deletions

View File

@ -65,7 +65,7 @@ card.extra={
type:'trick',
enable:true,
filterTarget:function(card,player,target){
if(player!=game.me&&player.num('h')<3) return false;
if(player!=game.me&&player.num('h')<2) return false;
return target.num('h')>0;
},
content:function(){

View File

@ -24,13 +24,16 @@ character.jiange={
trigger:{player:'phaseUseBegin'},
direct:true,
filter:function(event,player){
return player.hp<=Math.floor(game.players.length/3);
if(game.players.length>=6){
return player.hp<=2;
}
return player.hp<=1;
},
content:function(){
"step 0"
player.chooseTarget('是否发动【控魂】?',function(card,player,target){
return player!=target;
},[1,Math.floor((game.players.length-1)/2)]).ai=function(target){
},[1,Math.min(4,Math.floor((game.players.length-1)/2))]).ai=function(target){
return ai.get.damageEffect(target,player,player,'thunder')+1;
}
"step 1"
@ -559,7 +562,7 @@ character.jiange={
sfanshi:'反噬',
sfanshi_info:'锁定技结束阶段你失去1点体力',
konghun:'控魂',
konghun_info:'出牌阶段开始时若你的体力值不大于1场上存活角色数不小于6时改为2你可以对至多X名角色各造成1点雷电伤害然后你恢复等量体力X为场上其他存活角色数的一半向下取整',
konghun_info:'出牌阶段开始时若你的体力值不大于1场上存活角色数不小于6时改为2你可以对至多X名角色各造成1点雷电伤害然后你恢复等量体力X为场上其他存活角色数的一半向下取整且至多为4',
jizhen_info:'结束阶段,你可以令所至多两名已受伤角色摸一张牌',
// biantian2_info:'已获得大雾标记',
// biantian3_info:'已获得狂风标记',

View File

@ -3206,7 +3206,7 @@ character.yijiang={
xinjujian:'举荐',
luoying:'落英',
luoying1:'落英',
luoying2:'落英',
luoying2:'落英·判定',
jiushi:'酒诗',
jiushi1:'酒诗',
jiushi2:'酒诗',

View File

@ -6,9 +6,10 @@ window.config={
'xiahouyuan','huangzhong','weiyan','dianwei','gongsunzan'],
forbidversus:['swd_kangnalishi'],
forbidstone:['zhugedan','pal_xuanxiao'],
forbidchess:['hetaihou'],
forbiddouble:['zhugedan','swd_kangnalishi','swd_nicole','dongzhuo','jg_simayi'],
all:{
mode:['identity','guozhan','versus','stone'],
mode:['identity','guozhan','versus','boss','chess','stone'],
characters:['standard','wind','fire','woods','mountain','extra','sp','yijiang','refresh','guozhan','jiange','zhuogui','diy','yxs','swd','xswd','gujian','xianjian'],
cards:['standard','ex','extra','refresh','guozhan','zhenfa','qimou','yibao','shenbing','wanxiang','swd','shenqi','compensate'],
plays:['character','soldier','wuxing'],
@ -32,6 +33,8 @@ window.config={
stone:'炉石',
changjing:'场景',
mowang:'魔王',
boss:'挑战',
chess:'战棋',
infinity:'无限',
qunyingzhuan:'群英',
swd:'剧情',

View File

@ -175,6 +175,9 @@ window.play={};
lib.init.js('character',lib.config.all.characters);
lib.init.js('play',lib.config.plays);
ui.css={};
if(lib.config.mode=='chess'){
lib.config.layout='newlayout';
}
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout');
if(!lib.config.touchscreen){
if(lib.config.show_scrollbar) ui.css.scrollbar=lib.init.css('layout/default','scrollbar');
@ -350,17 +353,7 @@ window.play={};
if(player.node.judges.childElementCount){
event.card=player.node.judges.firstChild;
player.lose(event.card);
var clone=event.card.copy('thrown',ui.arena).animate('judgestart');
clone.style.opacity=0.6;
clone.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*50+'px)';
clone.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*40+'px)';
game.delay();
game.linexy([
clone.offsetLeft+clone.offsetWidth/2,
clone.offsetTop+clone.offsetHeight/2,
player.offsetLeft+player.offsetWidth/2,
player.offsetTop+player.offsetHeight/2
],{opacity:0.5,dashed:true});
player.$phaseJudge(event.card);
event.cancelled=false;
event.trigger('phaseJudge');
}
@ -577,6 +570,7 @@ window.play={};
}
}
else if(get.itemtype(event.dialog)=='dialog'){
event.dialog.style.display='';
event.dialog.open();
}
}
@ -673,6 +667,7 @@ window.play={};
"step 0"
if(event.dialog==undefined) event.dialog=ui.dialog;
if(event.isMine()){
event.dialog.style.display='';
event.dialog.open();
}
game.check();
@ -1133,7 +1128,7 @@ window.play={};
}
if(lib.config.background_audio){
var sex=player.sex=='female'?'female':'male';
if(lib.card[card.name].audio){
if(lib.card[card.name].audio||lib.config.background_ogg){
if(card.name=='sha'&&(card.nature=='fire'||card.nature=='thunder')){
game.playAudio('card',sex,card.name+'_'+card.nature);
}
@ -1142,12 +1137,7 @@ window.play={};
}
}
else{
if(lib.config.background_ogg){
game.playAudioOgg('card',sex,card.name);
}
else{
game.playAudio('card/default');
}
game.playAudio('card/default');
}
}
if(event.animate!=false){
@ -1290,7 +1280,7 @@ window.play={};
game.playAudio('skill',event.skill,Math.ceil(info.audio*Math.random()));
}
else if(lib.config.background_ogg){
game.playAudioOgg('skill',event.skill);
game.playAudio('skill',event.skill);
}
else{
game.playAudio('skill','default',
@ -1454,13 +1444,10 @@ window.play={};
if(event.parent.parent.parent.name=='useCard'){
if(lib.config.background_audio){
var sex=player.sex=='female'?'female':'male';
if(lib.card[card.name].audio){
if(lib.card[card.name].audio||lib.config.background_ogg){
game.playAudio('card',sex,card.name);
}
else{
if(lib.config.background_ogg){
game.playAudioOgg('card',sex,card.name);
}
game.playAudio('card/default');
}
}
@ -1512,7 +1499,12 @@ window.play={};
cards[num].animate('start');
if(lib.config.strict_sort){
j=0;
position=sort>0?player.node.handcards1:player.node.handcards2;
if(game.singleHandcard){
position=sort>0?player.node.handcards1:player.node.handcards2;
}
else{
position=player.node.handcards1;
}
for(j=0;j<position.childNodes.length;j++){
if(lib.config.reverse_sort){
if(sort<lib.config.sort_card(position.childNodes[j])) break;
@ -1558,7 +1550,7 @@ window.play={};
}
}
else{
if(sort>0) frag1.appendChild(cards[num]);
if(game.singleHandcard||sort>0) frag1.appendChild(cards[num]);
else frag2.appendChild(cards[num]);
}
}
@ -1838,7 +1830,7 @@ window.play={};
game.playAudio('die',player.name);
}
else if(lib.config.background_ogg){
game.playAudioOgg('die',player.name);
game.playAudio('die',player.name);
}
}
if(lib.config.background_audio){
@ -1992,7 +1984,7 @@ window.play={};
var info=lib.character[character];
var skills=info[3];
this.skills.length=0;
if(lib.config.layout=='newlayout'&&info[4]&&info[4].contains('fullskin')){
if(!game.minskin&&lib.config.layout=='newlayout'&&info[4]&&info[4].contains('fullskin')){
this.classList.remove('minskin');
this.classList.add('fullskin');
this.node.avatar.style.backgroundImage='url("image/character/fullskin/'+character+'.jpg")';
@ -2004,6 +1996,9 @@ window.play={};
if(info[4]&&info[4].contains('minskin')){
this.classList.add('minskin');
}
else if(game.minskin){
this.classList.add('minskin');
}
}
this.node.avatar.show();
@ -2146,17 +2141,27 @@ window.play={};
hp.childNodes[i].classList.add('lost');
}
}
if(this.maxHp>9){
this.node.hp.classList.add('longlong');
if(this.classList.contains('minskin')){
if(this.maxHp>5){
this.node.hp.classList.add('longlong');
}
else{
this.node.hp.classList.remove('longlong');
}
}
else{
this.node.hp.classList.remove('longlong');
}
if(this.maxHp==9||this.maxHp>=17){
this.node.hp.classList.add('long');
}
else{
this.node.hp.classList.remove('long');
if(this.maxHp>9){
this.node.hp.classList.add('longlong');
}
else{
this.node.hp.classList.remove('longlong');
}
if(this.maxHp==9||this.maxHp>=17){
this.node.hp.classList.add('long');
}
else{
this.node.hp.classList.remove('long');
}
}
}
@ -2232,7 +2237,7 @@ window.play={};
this.offsetTop+this.offsetHeight/2,
target.offsetLeft+target.offsetWidth/2,
target.offsetTop+target.offsetHeight/2
],config);
],config,true);
}
},
line2:function(targets,config){
@ -3449,11 +3454,16 @@ window.play={};
}
else{
if(lib.config.background_ogg){
game.playAudioOgg('skill',name);
game.playAudio('skill',name);
}
else{
game.playAudio('skill','default',Math.ceil(Math.random()*5));
}
game.playAudio('skill','default',Math.ceil(Math.random()*5));
}
}
if(lib.config.mode=='chess'){
this.chessFocus();
}
},
unprompt:function(){
if(this.node.prompt){
@ -3469,7 +3479,7 @@ window.play={};
node.className='popup';
}
else{
node=ui.create.div('.popup',ui.arena);
node=ui.create.div('.popup',this.parentNode);
this.node.prompt=node;
}
node.dataset.position=this.dataset.position;
@ -3488,7 +3498,7 @@ window.play={};
},
popup:function(name,className){
var name2=get.translation(name);
var node=ui.create.div('.popup',ui.arena);
var node=ui.create.div('.popup',this.parentNode);
node.dataset.position=this.dataset.position;
if(this.dataset.position==0||parseInt(this.dataset.position)==parseInt(ui.arena.dataset.number)/2||
typeof name2=='number'||this.classList.contains('minskin')){
@ -3792,15 +3802,19 @@ window.play={};
return this.classList.contains('out');
},
isMin:function(){
return this.classList.contains('minskin');
return this.classList.contains('minskin')&&lib.config.mode!='chess';
},
isIn:function(){
return this.classList.contains('dead')==false&&this.classList.contains('out')==false&&!this.removed;
},
isUnderControl:function(){
if(this===game.me) return false;
if(lib.config.mode=='versus'){
return ui.autoreplace&&ui.autoreplace.classList.contains('on')&&
this!=game.me&&this.side==game.me.side;
this.side==game.me.side;
}
else if(lib.config.mode=='chess'){
return this.side==game.me.side;
}
return false;
},
@ -3861,7 +3875,7 @@ window.play={};
}
node.fixed=true;
node.dataset.position=this.dataset.position;
ui.arena.appendChild(node);
this.parentNode.appendChild(node);
setTimeout(function(){
node.remove();
},1000);
@ -3884,7 +3898,6 @@ window.play={};
);
node1.classList.add('infohidden');
node1.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)';
// ui.refresh(node1);
setTimeout(function(){
setTimeout(function(){
node1.style.transition='all ease-in 0.3s';
@ -3903,7 +3916,6 @@ window.play={};
);
node2.classList.add('infohidden');
node2.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)';
// ui.refresh(node2);
setTimeout(function(){
node2.style.transition='all ease-in 0.3s';
node2.style.webkitTransform='perspective(600px) rotateY(270deg) translateX(52px)';
@ -3959,15 +3971,25 @@ window.play={};
}
game.log(str);
}
for(var i=0;i<card.length;i++){
this.$give(card[i],player,false);
if(this.$givemod){
this.$givemod(card,player);
}
else{
for(var i=0;i<card.length;i++){
this.$give(card[i],player,false);
}
}
}
else if(typeof card=='number'&&card>=0){
if(log!=false){
game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
while(card--) this.$give('',player,false);
if(this.$givemod){
this.$givemod(card,player);
}
else{
while(card--) this.$give('',player,false);
}
}
else{
if(log!=false){
@ -3978,31 +4000,36 @@ window.play={};
game.log(get.translation(player)+'从'+get.translation(this)+'获得了一张牌');
}
}
var node;
if(get.itemtype(card)=='card'){
node=card.copy('card','thrown',false);
if(this.$givemod){
this.$givemod(card,player);
}
else{
node=ui.create.div('.card.thrown');
var node;
if(get.itemtype(card)=='card'){
node=card.copy('card','thrown',false);
}
else{
node=ui.create.div('.card.thrown');
}
node.dataset.position=this.dataset.position;
node.fixed=true;
node.hide();
node.style.transitionProperty='left,top,opacity';
node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)';
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)';
setTimeout(function(){
node.removeAttribute('style');
node.dataset.position=player.dataset.position;
node.delete();
},700);
}
node.dataset.position=this.dataset.position;
node.fixed=true;
ui.arena.appendChild(node);
node.hide();
node.style.transitionProperty='left,top,opacity';
node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)';
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)';
setTimeout(function(){
node.removeAttribute('style');
node.dataset.position=player.dataset.position;
node.delete();
},700);
}
},
$gain:function(card,log){
@ -4014,43 +4041,58 @@ window.play={};
}
game.log(str);
}
for(var i=0;i<card.length;i++){
this.$gain(card[i],false);
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i<card.length;i++){
this.$gain(card[i],false);
}
}
}
else if(typeof card=='number'&&card>1){
if(log!=false){
game.log(get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
for(var i=0;i<card;i++){
this.$gain(1,false);
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i<card;i++){
this.$gain(1,false);
}
}
}
else{
if(get.itemtype(card)=='card'&&log!=false){
game.log(get.translation(this)+'获得了'+get.translation(card));
}
var node;
if(get.itemtype(card)=='card'){
node=card.copy('thrown',false);
if(this.$gainmod){
this.$gainmod(card);
}
else{
node=ui.create.div('.card.thrown');
node.moveTo=lib.element.card.moveTo;
var node;
if(get.itemtype(card)=='card'){
node=card.copy('thrown',false);
}
else{
node=ui.create.div('.card.thrown');
node.moveTo=lib.element.card.moveTo;
}
node.fixed=true;
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.webkitTransform='scale(0)';
var player=this;
node.hide();
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.webkitTransform='';
setTimeout(function(){
node.moveTo(player).delete();
},700);
}
node.fixed=true;
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.webkitTransform='scale(0)';
var player=this;
node.hide();
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.webkitTransform='';
setTimeout(function(){
node.moveTo(player).delete();
},700);
}
},
$gain2:function(cards,log){
@ -4058,7 +4100,7 @@ window.play={};
else if(get.itemtype(cards)!='cards') return;
var list=[];
for(var i=0;i<cards.length;i++){
if(cards[i].clone&&cards[i].clone.parentNode==ui.arena&&
if(cards[i].clone&&cards[i].clone.parentNode==this.parentNode&&
getComputedStyle(cards[0].clone).opacity){
cards[i].clone.moveTo(this).delete();
}
@ -4112,6 +4154,20 @@ window.play={};
((Math.random()-0.5<0)?'rotateX(180deg)':'rotateY(180deg)');
this.queue(false);
},
$phaseJudge:function(card){
var clone=card.copy('thrown',ui.arena).animate('judgestart');
var player=this;
clone.style.opacity=0.6;
clone.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*50+'px)';
clone.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*40+'px)';
game.delay();
game.linexy([
clone.offsetLeft+clone.offsetWidth/2,
clone.offsetTop+clone.offsetHeight/2,
player.offsetLeft+player.offsetWidth/2,
player.offsetTop+player.offsetHeight/2
],{opacity:0.5,dashed:true});
}
},
card:{
init:function(card){
@ -5102,7 +5158,7 @@ window.play={};
else if(color=='green'){
color=[141, 255, 216];
}
game.draw(function(time,ctx){
var drawfunc=function(time,ctx){
var current;
if(time<total/3){
ctx.strokeStyle='rgba('+color.toString()+','+opacity*(time/(total/3))+')';
@ -5128,7 +5184,13 @@ window.play={};
ctx.moveTo(from[0],from[1]);
ctx.lineTo(current[0],current[1]);
ctx.stroke();
});
};
if(arguments[2]&&lib.config.mode=='chess'){
game.draw2(drawfunc);
}
else{
game.draw(drawfunc);
}
},
createEvent:function(name,trigger){
var next={
@ -5586,8 +5648,14 @@ window.play={};
range=get.select(event.selectTarget);
if(range[0]!=range[1]||range[0]>1) auto=false;
for(i=0;i<game.players.length;i++){
var nochess=true;
if(lib.config.mode=='chess'){
if(player&&get.distance(player,game.players[i],'pure')>7){
nochess=false;
}
}
if(event.filterTarget(card,player,game.players[i])&&
(game.players[i].isOut()==false||event.includeOutTarget)){
(game.players[i].isOut()==false||event.includeOutTarget)&&nochess){
if(ui.selected.targets.length<range[1]){
game.players[i].classList.add('selectable');
}
@ -5760,19 +5828,21 @@ window.play={};
player1.dataset.position=player2.dataset.position;
player2.dataset.position=temp1;
game.arrangePlayers();
if(player1.dataset.position=='0'||player2.dataset.position=='0'){
pos=parseInt(player1.dataset.position);
if(pos==0) pos=parseInt(player2.dataset.position);
num=game.players.length+game.dead.length;
for(i=0;i<game.players.length;i++){
temp1=parseInt(game.players[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.players[i].dataset.position=temp1;
}
for(i=0;i<game.dead.length;i++){
temp1=parseInt(game.dead[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.dead[i].dataset.position=temp1;
if(lib.config.mode!='chess'){
if(player1.dataset.position=='0'||player2.dataset.position=='0'){
pos=parseInt(player1.dataset.position);
if(pos==0) pos=parseInt(player2.dataset.position);
num=game.players.length+game.dead.length;
for(i=0;i<game.players.length;i++){
temp1=parseInt(game.players[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.players[i].dataset.position=temp1;
}
for(i=0;i<game.dead.length;i++){
temp1=parseInt(game.dead[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.dead[i].dataset.position=temp1;
}
}
}
if(prompt!=false){
@ -6802,7 +6872,19 @@ window.play={};
ui.configbg.oncontextmenu=ui.click.config2;
ui.config=ui.create.div('#sidebar2.content');
ui.config.listen(function(){
// _status.clicked=true;
if(_status.reloading) return;
if(_status.choosing){
if(!_status.choosing.expand){
_status.choosing.parentNode.style.height='';
_status.choosing.nextSibling.delete();
_status.choosing.previousSibling.show();
delete _status.choosing;
}
}
_status.clicked=true;
if(ui.arena.classList.contains('selecting')){
game.check();
}
});
ui.config.oncontextmenu=function(e){
e.stopPropagation();
@ -6930,7 +7012,14 @@ window.play={};
case 'player_number':
modeconfig.push(ui.create.switcher('player_number',[2,3,4,5,6,7,8],get.config('player_number'),ui.click.sidebar.player_number));break;
case 'battle_number':
modeconfig.push(ui.create.switcher('battle_number',[1,2,3,5,8,16],get.config('battle_number'),ui.click.sidebar.battle_number));break;
var battle_number;
if(lib.config.mode=='chess'){
battle_number=[2,3,4,6,8];
}
else{
battle_number=[1,2,3,5,8,16];
}
modeconfig.push(ui.create.switcher('battle_number',battle_number,get.config('battle_number'),ui.click.sidebar.battle_number));break;
case 'double_character':
modeconfig.push(ui.create.switcher('double_character',get.config('double_character'),ui.click.sidebar.local));break;
case 'double_hp':
@ -7567,7 +7656,7 @@ window.play={};
}
ui.config2=ui.create.system('选项',ui.click.config);
if(!lib.config.touchscreen){
lib.setPopped(ui.config2,ui.click.pauseconfig,190);
lib.setPopped(ui.config2,ui.click.pauseconfig,170);
}
ui.wuxie=ui.create.system('不询问无懈',ui.click.wuxie,true);
ui.auto=ui.create.system('托管',ui.click.auto);
@ -7602,7 +7691,7 @@ window.play={};
_status.identityShown=true;
}
},true);
if(!lib.config.show_playerids||lib.config.mode=='versus'){
if(!lib.config.show_playerids||!game.showIdentity){
ui.playerids.style.display='none';
}
if(!lib.config.show_replay){
@ -7818,6 +7907,9 @@ window.play={};
return node;
},
players:function(num){
if(num===0){
return;
}
if(num==undefined) num=lib.config.mode_config[lib.config.mode].player_number;
if(num==undefined) num=5;
for(var i=0;i<num;i++){
@ -7845,12 +7937,14 @@ window.play={};
me:function(){
ui.mebg=ui.create.div('#mebg',ui.arena);
ui.me=ui.create.div('#me',ui.arena).animate('start');
game.me=game.players[0];
ui.handcards1=game.me.node.handcards1;
ui.handcards2=game.me.node.handcards2;
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
ui.updateh(true);
if(game.players.length){
game.me=game.players[0];
ui.handcards1=game.me.node.handcards1;
ui.handcards2=game.me.node.handcards2;
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
ui.updateh(true);
}
},
card:function(position,info,noclick){
var node=ui.create.div('.card',position);
@ -7907,20 +8001,24 @@ window.play={};
if(!lib.config.auto_popped) return;
if(!ui.config.childNodes.length) return;
var uiintro=ui.create.dialog('hidden');
var node=ui.create.div('.newgame');
for(var i=0;i<lib.config.all.mode.length;i++){
var thismode=lib.config.all.mode[i];
var div=ui.create.div(thismode==lib.config.mode?'.underlinenode.on':'.underlinenode',node);
div.innerHTML=lib.translate[thismode];
div.link=thismode;
div.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
game.saveConfig('mode',this.link);
game.reload();
});
var rows=Math.ceil(lib.config.all.mode.length/3);
for(var k=0;k<rows;k++){
var node=ui.create.div('.newgame');
for(var i=0;i<3&&i+k*3<lib.config.all.mode.length;i++){
var thismode=lib.config.all.mode[i+k*3];
var div=ui.create.div(thismode==lib.config.mode?'.underlinenode.on':'.underlinenode',node);
div.innerHTML=lib.translate[thismode];
div.link=thismode;
div.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
game.saveConfig('mode',this.link);
game.reload();
});
}
uiintro.add(node);
}
uiintro.add(node);
var auto=null;
var ng=null;
var sks=[];
var autoskill=ui.autoskill;
if(game.players){
@ -7933,6 +8031,11 @@ window.play={};
for(var i=0;i<autoskill.length-1;i++){
if(sks.contains(autoskill[i].link)){
if(!auto){
ng=ui.create.div('.text');
ng.style.marginBottom=0;
ng.innerHTML='新游戏';
uiintro.content.insertBefore(ng,uiintro.content.firstChild);
auto=ui.create.div('.text');
auto.style.marginBottom=0;
auto.innerHTML='自动发动';
@ -8115,6 +8218,7 @@ window.play={};
var node=_status.currentmouseenter;
if(_status.mousedragging){
e.preventDefault();
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
@ -8168,6 +8272,11 @@ window.play={};
var item=e.path[i];
var ex=e.x-ui.arena.offsetLeft;
var ey=e.y-ui.arena.offsetTop;
var exx=ex,eyy=ey;
if(lib.config.mode=='chess'){
ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft;
ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop;
}
if(itemtype!='player'||(ex>item.offsetLeft&&ex<item.offsetLeft+item.offsetWidth&&
ey>item.offsetTop&&ey<item.offsetTop+item.offsetHeight)){
if(item.classList.contains('selectable')&&_status.dragstatuschanged!=item){
@ -8179,7 +8288,7 @@ window.play={};
if(item.classList.contains('selected')){
if(notbefore){
_status.lastdragchange.push(item);
e.path[i]._lastdragchange=[ex,ey];
e.path[i]._lastdragchange=[exx,eyy];
}
}
else{
@ -8236,6 +8345,15 @@ window.play={};
}
},hoveration);
}
if(_status.draggingdialog){
var ddialog=_status.draggingdialog;
if(ddialog._dragorigin&&ddialog._dragtransform){
var translate=ddialog._dragtransform.slice(0);
translate[0]+=e.x-ddialog._dragorigin.x;
translate[1]+=e.y-ddialog._dragorigin.y;
ddialog.style.webkitTransform='translate('+translate[0]+'px,'+translate[1]+'px)'
}
}
}
},
windowmousedown:function(e){
@ -8245,6 +8363,21 @@ window.play={};
for(var i=0;i<dialogs.length;i++){
dialogs[i].delete();
}
for(var i=0;i<e.path.length;i++){
var itemtype=get.itemtype(e.path[i]);
if(itemtype=='button') break;
if(itemtype=='dialog'){
var ddialog=e.path[i];
_status.draggingdialog=ddialog;
ddialog._dragorigin=e;
if(!ddialog._dragtransform){
ddialog._dragtransform=[0,0];
}
return;
}
}
var evt=_status.event;
if(!lib.config.enable_drag) return;
if(!ui.arena.classList.contains('selecting')) return;
@ -8271,6 +8404,17 @@ window.play={};
}
},
windowmouseup:function(e){
if(_status.draggingdialog){
var ddialog=_status.draggingdialog;
if(ddialog._dragorigin&&ddialog._dragtransform){
var translate=ddialog._dragtransform;
translate[0]+=e.x-ddialog._dragorigin.x;
translate[1]+=e.y-ddialog._dragorigin.y;
ddialog.style.webkitTransform='translate('+translate[0]+'px,'+translate[1]+'px)';
delete ddialog._dragorigin;
}
delete _status.draggingdialog;
}
if(e.button==2){
if(_status.mousedragging){
_status.mousedragging=null;
@ -9003,6 +9147,10 @@ window.play={};
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
},
change_identity:function(bool){
@ -9091,13 +9239,15 @@ window.play={};
},
layout:function(layout){
game.saveConfig('layout',layout);
ui.arena.hide();
setTimeout(function(){
var layout=ui.css.layout;
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout',layout);
if(lib.config.mode!='chess'){
ui.arena.hide();
setTimeout(function(){
var layout=ui.css.layout;
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout',layout);
setTimeout(function(){layout.remove();ui.arena.show();},100);
},500);
setTimeout(function(){layout.remove();ui.arena.show();},100);
},500);
}
},
image_background:function(background){
var animate=lib.config.image_background=='default';
@ -9355,12 +9505,14 @@ window.play={};
if(get.config('reverse_sort')) return lib.config.sort_card(a)-lib.config.sort_card(b);
return lib.config.sort_card(b)-lib.config.sort_card(a);
});
for(i=0;i<cards.length;i++){
if(lib.config.sort_card(cards[i])>0){
game.me.node.handcards1.appendChild(cards[i]);
}
else{
game.me.node.handcards2.appendChild(cards[i]);
if(!game.singleHandcard){
for(i=0;i<cards.length;i++){
if(lib.config.sort_card(cards[i])>0){
game.me.node.handcards1.appendChild(cards[i]);
}
else{
game.me.node.handcards2.appendChild(cards[i]);
}
}
}
},
@ -9375,13 +9527,15 @@ window.play={};
for(i=0;i<game.me.node.handcards2.childNodes.length;i++){
cards2.unshift(game.me.node.handcards2.childNodes[i]);
}
var cards=game.me.num('h');
for(var i=0;i<cards.length;i++) cards[i].remove();
for(i=0;i<cards1.length;i++){
game.me.node.handcards2.appendChild(cards1[i]);
}
for(i=0;i<cards2.length;i++){
game.me.node.handcards1.appendChild(cards2[i]);
if(!game.singleHandcard){
var cards=game.me.num('h');
for(var i=0;i<cards.length;i++) cards[i].remove();
for(i=0;i<cards1.length;i++){
game.me.node.handcards2.appendChild(cards1[i]);
}
for(i=0;i<cards2.length;i++){
game.me.node.handcards1.appendChild(cards2[i]);
}
}
}
},
@ -9431,6 +9585,7 @@ window.play={};
ui.updateh(true);
},
updateh:function(compute){
if(!game.me) return;
if(compute){
game.me.node.handcards1._handcardsWidth=game.me.node.handcards1.offsetWidth;
game.me.node.handcards2._handcardsWidth=game.me.node.handcards2.offsetWidth;
@ -9463,6 +9618,14 @@ window.play={};
ui.updates[i]();
}
if(ui.dialog){
if(lib.config.mode=='chess'){
if(ui.dialog.content.offsetHeight<240){
ui.dialog.style.height=ui.dialog.content.offsetHeight+'px';
}
else{
ui.dialog.style.height='';
}
}
if(ui.dialog.content.offsetHeight<=240||
ui.dialog.contentContainer.offsetHeight>=ui.dialog.content.offsetHeight){
ui.dialog.classList.remove('scroll1');
@ -9656,8 +9819,15 @@ window.play={};
if(!game.players.contains(from)&&!game.dead.contains(from)) return Infinity;
if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity;
var player=from,m,n=1,i;
if(to.isMin()||from.isMin()){
if(method=='raw'||method=='pure') return 1;
var fxy,txy;
if(lib.config.mode=='chess'){
fxy=from.getXY();
txy=to.getXY();
n=Math.abs(fxy[0]-txy[0])+Math.abs(fxy[1]-txy[1]);
if(method=='raw'||method=='pure'||method=='absolute') return n;
}
else if(to.isMin()||from.isMin()){
if(method=='raw'||method=='pure'||method=='absolute') return 1;
}
else{
var length=game.players.length;
@ -9678,7 +9848,7 @@ window.play={};
if(from.isDead()) length++;
if(to.isDead()) length++;
n=Math.min(n,length-n);
if(method=='pure') return n;
if(method=='raw'||method=='pure') return n;
}
n=game.checkMod(from,to,n,'globalFrom',from.get('s'));

View File

@ -116,6 +116,7 @@ body>.background{z-index:-2}
.dialog{text-align: center;}
.dialog{width: calc(90% - 420px);height: calc(100% / 3 - 160px / 3 + 120px);}
.dialog.fullheight{height:calc(100% - 80px) !important;top:40px !important}
.dialog.fullwidth{left:calc(5% + 60px) !important;width:calc(90% - 120px) !important}
.dialog{top:calc(100% / 3 - 100px / 3);left: calc(5% + 210px);}
#window>.dialog.popped{
@ -171,6 +172,7 @@ margin-bottom: 5px;
.toggle{right: 16px;left: auto !important;min-width: 16px;text-align: right !important;}
.switcher{width: 88%;position: relative;}
.caption{padding-top: 8px;font-size: 20px;display: block;}
.caption:only-child{padding-bottom:8px;}
.caption:not(.normal)>div{text-align: left;display: block;width: 100%;}
.caption>div{position: relative;}
.caption>.text{font-size:16px;text-align:left}
@ -485,7 +487,7 @@ div:hover>.intro{opacity: 1;}
}
.newgame{
width:170px;
width:calc(100% - 16px);
display:flex;
}
.newgame>div{
@ -686,6 +688,7 @@ div[data-nature='soil']{
@-webkit-keyframes replaceme{from {opacity: 0;-webkit-transform:translateY(120px)}}
@-webkit-keyframes replaceenemy{from {opacity: 0;-webkit-transform:translateY(-120px)}}
@-webkit-keyframes drawing{0% {opacity: 0;left:calc(50% - 52px);top:calc(50% - 52px);}50%{opacity: 1}100%{opacity: 0}}
@-webkit-keyframes drawing2{0% {opacity: 0}50%{opacity: 1}100%{opacity: 0}}
@-webkit-keyframes card_start{from {opacity: 0;-webkit-transform:scale(0);}}
@-webkit-keyframes card_start2{from {opacity: 0;-webkit-transform:scale(0);margin-left: -52px;margin-right: -52px;}}
@-webkit-keyframes card_judgestart{from {opacity: 0;-webkit-transform:scale(0) rotateY(-180deg) perspective(600px);}}

100
layout/mode/chess.css Normal file
View File

@ -0,0 +1,100 @@
#arena.chess{
width:100%;
height:100%;
left:0;
top:0;
transition:all 0s !important;
}
#arena.chess>#me,
#arena.chess>#mebg{
bottom:0;
top:auto;
border-radius:0;
}
#chess-container{
width:100%;
height :calc(100% - 120px);
left:0;
top:0;
overflow:scroll;
text-align:center;
}
#chess{
margin-top:36px;
position:relative;
}
#arena .card.thrown{
z-index:4;
}
#handcards1{
height:120px;
padding:0;
top:calc(100% - 120px);
width:calc(100% - 240px);
left:120px;
}
#handcards2{
display:none;
}
#mebg,#me{
height:120px;
}
#system{
z-index:5;
}
#arena>.dialog{
width:400px;
height:240px;
left:calc(50% - 200px);
top:calc(50% - 120px);
background: rgba(0,0,0,0.2);
box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px;
border-radius:8px;
}
#control{
top:calc(100% - 155px);
}
.fakeme{
width:120px;
height:120px;
border-radius:0px;
top:0;
}
.fakeme.avatar{
left:0;
background-size:cover;
}
.fakeme.player{
left:calc(100% - 120px);
overflow:scroll;
text-align:center;
}
.fakeme.player>div{
width:45px;
height:45px;
background-size:cover;
border-radius:4px;
position:relative;
left:0;
top:8px;
margin-left: 4px;
margin-right: 4px;
margin-bottom: 8px;
}
.fakeme.player>.dead{
-webkit-filter:grayscale(1);
opacity:0.5;
}
.card.drawing{
-webkit-animation: drawing2 1s;
-webkit-animation-fill-mode: forwards;
}
.player.playergrid{
background: rgba(0,0,0,0.2);
box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px;
border-radius:8px;
}

View File

@ -19,6 +19,9 @@
.player.minskin .hp{
left:86px;
}
.player.minskin .hp.longlong{
left:74px;
}
.player .avatar2{
width:52px;
height:52px;
@ -76,7 +79,7 @@
max-height:148px;
left:auto;
}
.player.minskin .judges{
.player.noidentity .judges{
top:14px;
}
.player .marks>div,
@ -103,6 +106,10 @@
left:12px;
text-align:left;
}
.player.minskin .equips{
-webkit-transform:scale(0.73);
-webkit-transform-origin:bottom left;
}
.player .equips>.card{
position:relative;
width:100%;
@ -282,6 +289,9 @@
-webkit-transform:rotate(90deg) translate(-150px,-6px);
-webkit-transform-origin:bottom left;
}
.player.minskin.linked .equips{
-webkit-transform:rotate(90deg) translate(-90px,-6px) scale(0.73);
}
.player.linked div:not(.equips) .card,
.player.linked .identity{
-webkit-transform:rotate(90deg);

21
mode/boss.js Normal file
View File

@ -0,0 +1,21 @@
'use strict';
mode.boss={
game:{
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
ui.create.arena();
var dialog=ui.create.dialog('还没完工~');
dialog.style.height='52px';
dialog.style.background=' rgba(0,0,0,0.2)';
dialog.style.boxShadow=' rgba(0, 0, 0, 0.3) 0 0 0 1px';
dialog.style.borderRadius='8px';
dialog.style.top='calc(50% - 52px)';
game.pause();
"step 1"
console.log(1);
}
}
}
}

974
mode/chess.js Normal file
View File

@ -0,0 +1,974 @@
'use strict';
mode.chess={
canvasUpdates2:[],
element:{
card:{
moveTo:function(player,method){
this.fixed=true;
if(this.parentNode==ui.arena){
var rect=player.getBoundingClientRect();
this.style.left=(rect.left+8)+'px';
this.style.top=(rect.top+8)+'px';
}
else{
this.style.left='';
this.style.top='';
this.dataset.position=player.dataset.position;
}
if(method=='flip'){
this.style.transition='all 0.5s';
this.style.webkitTransform='rotate'+(Math.random()<0.5?'X':'Y')+'(180deg) perspective(1000px)';
}
else if(method=='rotate'){
this.style.transition='all 0.5s';
this.style.webkitTransform='rotate(180deg)';
}
return this;
},
},
player:{
chooseToMove:function(num){
var next=game.createEvent('chooseToMove');
next.num=num||1;
next.player=this;
next.content=lib.element.playerproto.chooseToMove;
return next;
},
move:function(x,y){
var xy=this.getXY();
return this.moveTo(x+xy[0],y+xy[1]);
},
moveTo:function(x,y){
if(x>=ui.chesswidth){
x=ui.chesswidth-1;
}
if(y>=ui.chessheight){
y=ui.chessheight-1;
}
// console.log(x,y);
var pos=y*ui.chesswidth+x;
if(!lib.posmap[pos]){
delete lib.posmap[this.dataset.position];
this.dataset.position=pos;
lib.posmap[pos]=this;
this.chessFocus();
}
return this;
},
chessFocus:function(){
if(ui.chess._chessdrag) return;
var player=this;
var dx=0,dy=0;
if(player.offsetLeft-ui.chessContainer.scrollLeft<14){
dx=player.offsetLeft-ui.chessContainer.scrollLeft-14;
}
else if(player.offsetLeft-ui.chessContainer.scrollLeft>ui.chessContainer.offsetWidth-134){
dx=player.offsetLeft-ui.chessContainer.scrollLeft-ui.chessContainer.offsetWidth+134;
}
if(player.offsetTop-ui.chessContainer.scrollTop<14){
dy=player.offsetTop-ui.chessContainer.scrollTop-14;
}
else if(player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop>ui.chessContainer.offsetHeight-134){
dy=player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop-ui.chessContainer.offsetHeight+134;
}
if(_status.currentChessFocus){
clearInterval(_status.currentChessFocus);
}
var count=12;
var ddx=Math.floor(dx/12);
var ddy=Math.floor(dy/12);
if(dx||dy){
_status.currentChessFocus=setInterval(function(){
if(count--){
ui.chessContainer.scrollLeft+=ddx;
ui.chessContainer.scrollTop+=ddy;
}
else{
ui.chessContainer.scrollLeft+=dx%12;
ui.chessContainer.scrollTop+=dy%12;
clearInterval(_status.currentChessFocus);
delete _status.currentChessFocus;
}
},16);
}
},
getXY:function(){
var pos=parseInt(this.dataset.position);
var x=pos%ui.chesswidth;
var y=Math.floor(pos/ui.chesswidth);
return [x,y];
},
getDataPos:function(x,y){
var xy=this.getXY();
if(typeof x!='number') x=0;
if(typeof y!='number') y=0;
x+=xy[0];
y+=xy[1];
return x+y*ui.chesswidth;
},
getNeighbour:function(x,y){
return lib.posmap[this.getDataPos(x,y)]||null;
},
movable:function(x,y){
var xy=this.getXY();
if(xy[0]+x<0) return false;
if(xy[1]+y<0) return false;
if(xy[0]+x>=ui.chesswidth) return false;
if(xy[1]+y>=ui.chessheight) return false;
return !this.getNeighbour(x,y);
},
moveRight:function(){
if(this.movable(1,0)){
this.move(1,0);
return true;
}
return false;
},
moveLeft:function(){
if(this.movable(-1,0)){
this.move(-1,0);
return true;
}
return false;
},
moveUp:function(){
if(this.movable(0,-1)){
this.move(0,-1);
return true;
}
return false;
},
moveDown:function(){
if(this.movable(0,1)){
this.move(0,1);
return true;
}
return false;
},
dieAfter:function(){
var player=this;
delete lib.posmap[player.dataset.position];
setTimeout(function(){
player.delete();
},500);
for(var i=0;i<ui.phasequeue.length;i++){
if(ui.phasequeue[i].link==player){
ui.phasequeue[i].classList.remove('glow2');
ui.phasequeue[i].classList.add('dead');
break;
}
}
for(var i=1;i<game.players.length;i++){
if(game.players[i].side!=game.players[0].side){
return;
}
}
game.over(game.me.side==game.players[0].side);
},
$draw:function(num){
var cards,node;
if(get.itemtype(num)=='cards'){
cards=num;
num=cards.length;
}
else if(get.itemtype(num)=='card'){
cards=[num];
num=1;
}
if(cards){
cards=cards.slice(0);
node=cards.shift().copy('drawing','thrown');
}
else{
node=ui.create.div('.card.drawing.thrown');
}
node.fixed=true;
game.$randomMove(this,node,100,30);
node.dataset.position=this.dataset.position;
this.parentNode.appendChild(node);
ui.refresh(node);
node.style.webkitTransform='';
setTimeout(function(){
node.remove();
},1000);
var that=this;
if(num&&num>1){
if(cards){
that.$draw(cards)
}
else{
that.$draw(num-1)
}
}
},
$gainmod:function(num){
var cards,node;
if(get.itemtype(num)=='cards'){
cards=num;
num=cards.length;
}
else if(get.itemtype(num)=='card'){
cards=[num];
num=1;
}
if(cards){
cards=cards.slice(0);
node=cards.shift().copy('thrown','hidden');
}
else{
node=ui.create.div('.card.thrown.hidden');
}
node.fixed=true;
game.$randomMove(this,node,100,30);
var ot=node.style.webkitTransform;
node.style.webkitTransform+='scale(0.6)';
node.dataset.position=this.dataset.position;
this.parentNode.appendChild(node);
ui.refresh(node);
node.show();
node.style.webkitTransform=ot;
setTimeout(function(){
node.style.webkitTransform='';
node.delete();
},500);
var that=this;
if(num&&num>1){
if(cards){
that.$gain(cards)
}
else{
that.$gain(num-1)
}
}
},
$throw:function(card,time){
this.chessFocus();
if(get.itemtype(card)=='cards'){
for(var i=0;i<card.length;i++){
this.$throw(card[i],time);
}
}
else{
if(card==undefined||card.length==0) return;
var node=card.copy('thrown','hidden');
node.dataset.position=this.dataset.position;
this.parentNode.appendChild(node);
ui.refresh(node);
node.show();
game.$randomMove(this,node,100,30);
if(time!=undefined){
node.fixed=true;
setTimeout(function(){node.delete()},time);
}
}
},
$givemod:function(card,player){
this.chessFocus();
var from=this;
if(get.itemtype(card)=='cards'){
for(var i=0;i<card.length;i++){
from.$givemod(card[i],player);
}
}
else if(typeof card=='number'&&card>=0){
for(var i=0;i<card;i++){
from.$givemod('',player);
}
}
else{
var node;
if(get.itemtype(card)=='card'){
node=card.copy('card','thrown',false);
}
else{
node=ui.create.div('.card.thrown');
}
node.dataset.position=this.dataset.position;
node.fixed=true;
node.hide();
this.parentNode.appendChild(node);
ui.refresh(node);
node.show();
game.$randomMove(this,node,100,30);
setTimeout(function(){
node.removeAttribute('style');
node.dataset.position=player.dataset.position;
node.delete();
},700);
}
},
$throwxy:function(card,left,top,transform){
var node=card.copy('thrown');
var rect=this.getBoundingClientRect();
node.style.left=(rect.left+8)+'px';
node.style.top=(rect.top+8)+'px';
node.hide();
node.style.transitionProperty='left,top,opacity';
if(transform){
node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)';
}
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.left=left;
node.style.top=top;
return node;
},
$phaseJudge:function(card){
var clone=card.copy('thrown',this.parentNode).animate('judgestart');
var player=this;
clone.style.opacity=0.6;
clone.style.left=(Math.random()*100-50+ui.chessContainer.scrollLeft+ui.chessContainer.offsetWidth/2-52)+'px';
clone.style.top=(Math.random()*80-40+ui.chessContainer.scrollTop+ui.chessContainer.offsetHeight/2-52-ui.chessContainer.offsetTop)+'px';
game.delay();
game.linexy([
clone.offsetLeft+clone.offsetWidth/2,
clone.offsetTop+clone.offsetHeight/2,
player.offsetLeft+player.offsetWidth/2,
player.offsetTop+player.offsetHeight/2
],{opacity:0.5,dashed:true},true);
}
},
playerproto:{
chooseToMove:function(){
"step 0"
event.switchToAuto=function(){
if(ui.movegrids){
while(ui.movegrids.length){
ui.movegrids.shift().delete();
}
}
var list=[];
var randomMove=['moveUp','moveDown','moveLeft','moveRight'];
for(var iwhile=0;iwhile<num;iwhile++){
var targets=[];
for(var i=0;i<game.players.length;i++){
if(game.players[i].side!=player.side){
targets.push(game.players[i]);
}
}
targets.sort(function(a,b){
return get.distance(player,a)-get.distance(player,b);
});
while(targets.length){
var target=targets.shift();
var txy=target.getXY();
var pxy=player.getXY();
if(Math.random()<0.5){
if(txy[0]>pxy[0]&&randomMove.contains('moveRight')){
if(player.moveRight()){
event.moved=true;break;
}
}
else if(txy[0]<pxy[0]&&randomMove.contains('moveLeft')){
if(player.moveLeft()){
event.moved=true;break;
}
}
if(txy[1]>pxy[1]&&randomMove.contains('moveDown')){
if(player.moveDown()){
event.moved=true;break;
}
}
else if(txy[1]<pxy[1]&&randomMove.contains('moveUp')){
if(player.moveUp()){
event.moved=true;break;
}
}
}
else{
if(txy[1]>pxy[1]&&randomMove.contains('moveDown')){
if(player.moveDown()){
event.moved=true;break;
}
}
else if(txy[1]<pxy[1]&&randomMove.contains('moveUp')){
if(player.moveUp()){
event.moved=true;break;
}
}
if(txy[0]>pxy[0]&&randomMove.contains('moveRight')){
if(player.moveRight()){
event.moved=true;break;
}
}
else if(txy[0]<pxy[0]&&randomMove.contains('moveLeft')){
if(player.moveLeft()){
event.moved=true;break;
}
}
}
if(targets.length==0){
if(randomMove.length){
var list=randomMove.slice(0);
var randomMoved=false;
while(list.length){
var thismove=list.randomRemove();
if(player[thismove]()){
event.moved=true;
switch(thismove){
case 'moveUp':randomMove.remove('moveDown');break;
case 'moveDown':randomMove.remove('moveUp');break;
case 'moveLeft':randomMove.remove('moveRight');break;
case 'moveRight':randomMove.remove('moveLeft');break;
}
break;
}
}
if(!event.moved) return;
}
else{
return;
}
}
}
if(lib.skill._chessmove.ai.result.player(player)<=0) break;
}
};
if(event.isMine()){
game.pause();
ui.movegrids=[];
num++;
for(var i=1-num;i<num;i++){
for(var j=1-num+Math.abs(i);j<num-Math.abs(i);j++){
if(player.movable(i,j)){
ui.movegrids.push(ui.create.playergrid(player,i,j));
}
}
}
for(var i=0;i<ui.movegrids.length;i++){
var grid=ui.movegrids[i];
if(game.isChessNeighbour(grid,player)) continue;
for(var j=0;j<ui.movegrids.length;j++){
if(game.isChessNeighbour(grid,ui.movegrids[j])) break;
}
if(j==ui.movegrids.length) grid.remove();
}
}
else{
event.switchToAuto();
}
"step 1"
if(event.moved){
game.delay();
}
}
}
},
game:{
minskin:true,
singleHandcard:true,
isChessNeighbour:function(a,b){
if(a&&a.dataset){
a=a.dataset.position;
}
if(b&&b.dataset){
b=b.dataset.position;
}
var ax=a%ui.chesswidth;
var ay=Math.floor(a/ui.chesswidth);
var bx=b%ui.chesswidth;
var by=Math.floor(b/ui.chesswidth);
if(ax==bx&&Math.abs(ay-by)==1) return true;
if(ay==by&&Math.abs(ax-bx)==1) return true;
return false;
},
$randomMove:function(player,node,length,rand){
length=length+Math.random()*rand;
var ang=Math.random()*360;
ang*=Math.PI/180;
var tx=length*Math.cos(ang);
var ty=length*Math.sin(ang);
var rect=player.getBoundingClientRect();
if(rect.left<=80){
tx=Math.abs(tx);
}
else if(rect.left+rect.width+80>=ui.chessContainer.offsetWidth){
tx=-Math.abs(tx);
}
if(rect.top<=80){
ty=Math.abs(ty);
}
else if(rect.top+rect.height+80>=ui.chessContainer.offsetHeight){
ty=-Math.abs(ty);
}
node.style.webkitTransform='translate('+tx+'px,'+ty+'px)';
},
draw2:function(func){
lib.canvasUpdates2.push(func);
if(!lib.status.canvas2){
lib.status.canvas2=true;
game.update(game.updateCanvas2);
}
},
updateCanvas2:function(time){
if(lib.canvasUpdates2.length===0){
lib.status.canvas2=false;
return false;
}
ui.canvas2.width=ui.chess.offsetWidth;
ui.canvas2.height=ui.chess.offsetHeight;
ui.canvas2.style.left=0;
ui.canvas2.style.top=0;
var ctx=ui.ctx2;
ctx.shadowBlur=5;
ctx.shadowColor='rgba(0,0,0,0.3)';
ctx.fillStyle='white';
ctx.strokeStyle='white';
ctx.lineWidth=3;
ctx.save();
for(var i=0;i<lib.canvasUpdates2.length;i++){
ctx.restore();
ctx.save();
var update=lib.canvasUpdates2[i];
if(!update.starttime){
update.starttime=time;
}
if(update(time-update.starttime,ctx)===false){
lib.canvasUpdates2.splice(i--,1);
}
}
},
start:function(){
var next=game.createEvent('game',false);
next.content=function(){
"step 0"
for(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','chess');
ui.chesssheet=document.createElement('style');
document.head.appendChild(ui.chesssheet);
ui.create.arena();
ui.chessContainer=ui.create.div('#chess-container',ui.arena);
ui.chess=ui.create.div('#chess',ui.chessContainer);
ui.canvas2=document.createElement('canvas');
ui.chess.appendChild(ui.canvas2);
ui.ctx2=ui.canvas2.getContext('2d');
game.me=ui.create.player();
game.chooseCharacter();
"step 1"
ui.arena.classList.add('chess');
var num=get.config('battle_number');
var double=get.config('double_character');
var friend,enemy;
var side=Math.random()<0.5;
switch(num){
case 2:ui.chessheight=5;break;
case 3:ui.chessheight=5;break;
case 4:ui.chessheight=6;break;
case 6:ui.chessheight=7;break;
case 8:ui.chessheight=8;break;
}
ui.chesswidth=Math.round(ui.chessheight*1.5);
ui.chess.style.height=148*ui.chessheight+'px';
ui.chess.style.width=148*ui.chesswidth+'px';
ui.chess.addEventListener('mousedown',function(e){
if(Array.isArray(e.path)){
for(var i=0;i<e.path.length;i++){
var itemtype=get.itemtype(e.path[i]);
if(itemtype=='button'||itemtype=='card'||itemtype=='player'){
return;
}
}
}
this._chessdrag=[e,this.parentNode.scrollLeft,this.parentNode.scrollTop];
});
ui.chess.addEventListener('mouseleave',function(e){
this._chessdrag=null;
});
ui.chess.addEventListener('mouseup',function(e){
this._chessdrag=null;
});
ui.chess.addEventListener('mousemove',function(e){
if(this._chessdrag){
this.parentNode.scrollLeft=this._chessdrag[1]-e.x+this._chessdrag[0].x;
this.parentNode.scrollTop=this._chessdrag[2]-e.y+this._chessdrag[0].y;
}
e.preventDefault();
});
ui.chessContainer.addEventListener('mousewheel',function(e){
if(_status.currentChessFocus){
clearInterval(_status.currentChessFocus);
delete _status.currentChessFocus;
}
});
for(var i=0;i<ui.chesswidth;i++){
for(var j=0;j<ui.chessheight;j++){
var pos='[data-position="'+(i+j*ui.chesswidth)+'"]';
ui.chesssheet.sheet.insertRule('#arena.chess #chess>.player'+pos+
'{left:'+(14+i*148)+'px;top:'+(14+j*148)+'px}',0);
ui.chesssheet.sheet.insertRule('#arena.chess #chess>.card'+pos+
'{left:'+(22+i*148)+'px;top:'+(22+j*148)+'px}',0);
if(j==ui.chessheight-1){
ui.chesssheet.sheet.insertRule('#arena.chess #chess>.popup'+pos+
'{left:'+(19+i*148)+'px;top:'+(-19+j*148)+'px}',0);
}
else{
ui.chesssheet.sheet.insertRule('#arena.chess #chess>.popup'+pos+
'{left:'+(19+i*148)+'px;top:'+(142+j*148)+'px}',0);
}
}
}
var grids=[];
var gridnum=ui.chessheight*ui.chesswidth;
for(var i=0;i<gridnum;i++){
grids.push(i);
}
for(var i=0;i<num;i++){
friend=ui.create.player().animate('start');
enemy=ui.create.player().animate('start');
if(double){
friend.init(_status.mylist.shift(),_status.mylist.shift());
enemy.init(_status.enemylist.shift(),_status.enemylist.shift());
}
else{
friend.init(_status.mylist.shift());
enemy.init(_status.enemylist.shift());
}
friend.side=side;
enemy.side=!side;
friend.setIdentity('friend');
enemy.setIdentity('enemy');
friend.node.identity.dataset.color=get.translation(side+'Color');
enemy.node.identity.dataset.color=get.translation(!side+'Color');
game.players.push(friend);
game.players.push(enemy);
ui.chess.appendChild(friend);
ui.chess.appendChild(enemy);
friend.dataset.position=grids.randomRemove();
enemy.dataset.position=grids.randomRemove();
lib.posmap[friend.dataset.position]=friend;
lib.posmap[enemy.dataset.position]=enemy;
}
lib.setPopped(ui.create.system('查看手牌',null,true),function(e){
var uiintro=ui.create.dialog('hidden');
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==game.me.side&&game.players[i]!=game.me){
uiintro.add(get.translation(game.players[i]));
var cards=game.players[i].get('h');
if(cards.length){
uiintro.add(cards,true);
}
else{
uiintro.add('(无)');
}
}
}
return uiintro;
});
ui.create.me();
ui.create.fakeme();
ui.create.cards();
ui.chessinfo=ui.create.div('.fakeme.player',ui.me);
ui.phasequeue=[];
game.finishCards();
game.arrangePlayers();
"step 2"
var p;
for(var i=0;i<game.players.length;i++){
if(game.players[i].side){
p=game.players[i];
break;
}
}
game.gameDraw(p);
game.phaseLoop(p);
for(var i=0;i<game.players.length;i++){
var node=ui.create.div('.avatar',ui.chessinfo);
node.style.backgroundImage=p.node.avatar.style.backgroundImage;
node.link=p;
ui.phasequeue.push(node);
p=p.next;
}
}
},
chooseCharacter:function(){
var next=game.createEvent('chooseCharacter',false);
next.showConfig=true;
next.ai=function(player,list){
if(get.config('double_character')){
player.init(list[0],list[1]);
}
else{
player.init(list[0]);
}
}
next.content=function(){
"step 0"
var i;
var list=[];
event.list=list;
for(i in lib.character){
if(lib.character[i][4]&&lib.character[i][4].contains('minskin')) continue;
if(lib.config.forbidai.contains(i)) continue;
if(lib.config.forbidall.contains(i)) continue;
if(lib.config.forbidchess.contains(i)) continue;
if(!get.config('double_character')&&get.config('ban_weak')&&lib.config.forbidsingle.contains(i)) continue;
list.push(i);
}
list.randomSort();
var dialog=ui.create.dialog('选择出场角色'+(get.config('double_character')?'(双将)':''));
dialog.classList.add('fullwidth');
dialog.classList.add('fullheight');
dialog.add('0/'+(get.config('double_character')?2:1)*get.config('battle_number'));
dialog.add([list.slice(0,get.config('battle_number')*4+5),'character']);
ui.control.style.transition='all 0s';
ui.control.style.top='calc(100% - 30px)';
var next=game.me.chooseButton(dialog,true);
next.selectButton=function(){
return (get.config('double_character')?2:1)*get.config('battle_number');
};
next.custom.add.button=function(){
if(ui.cheat2&&ui.cheat2.backup) return;
_status.event.dialog.content.childNodes[0].innerHTML=
'选择出场角色'+(get.config('double_character')?'(双将)':'');
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.buttons.length+'/'+_status.event.selectButton();
};
event.changeDialog=function(){
if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){
return;
}
list.randomSort();
_status.event.dialog.close();
_status.event.dialog=ui.create.dialog('选择出场角色'+(get.config('double_character')?'(双将)':''));
_status.event.dialog.classList.add('fullwidth');
_status.event.dialog.classList.add('fullheight');
_status.event.dialog.add('0/'+(get.config('double_character')?2:1)*get.config('battle_number'));
_status.event.dialog.add([list.slice(0,get.config('battle_number')*4+5),'character']);
game.uncheck();
game.check();
};
ui.create.cheat=function(){
ui.cheat=ui.create.control('更换',event.changeDialog);
};
event.dialogxx=ui.create.characterDialog();
event.dialogxx.classList.add('fullwidth');
event.dialogxx.classList.add('fullheight');
ui.create.cheat2=function(){
ui.cheat2=ui.create.control('自由选将',function(){
if(this.dialog==_status.event.dialog){
this.dialog.close();
_status.event.dialog=this.backup;
this.backup.open();
delete this.backup;
game.uncheck();
game.check();
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2x;
}
}
else{
ui.cheat2x=ui.create.groupControl(_status.event.parent.dialogxx);
this.backup=_status.event.dialog;
_status.event.dialog.close();
_status.event.dialog=_status.event.parent.dialogxx;
this.dialog=_status.event.dialog;
this.dialog.open();
game.uncheck();
game.check();
}
});
}
if(!ui.cheat&&get.config('change_choice'))
ui.create.cheat();
if(!ui.cheat2&&get.config('free_choose'))
ui.create.cheat2();
"step 1"
if(ui.cheat){
ui.cheat.close();
delete ui.cheat;
}
if(ui.cheat2){
ui.cheat2.close();
delete ui.cheat2;
}
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2x;
}
ui.control.style.top='';
ui.control.style.transition='';
_status.mylist=result.links.slice(0);
for(var i=0;i<result.links.length;i++){
event.list.remove(result.links[i]);
}
event.list.randomSort();
_status.enemylist=event.list.slice(0,result.links.length);
_status.double_character=get.config('double_character');
}
},
modeSwapPlayer:function(player){
game.me.node.avatar.classList.remove('glow2');
player.node.avatar.classList.add('glow2');
game.swapControl(player);
ui.create.fakeme();
}
},
skill:{
_phasequeue:{
trigger:{player:'phaseBegin'},
forced:true,
popup:false,
content:function(){
var current=ui.chessinfo.querySelector('.glow2');
if(current){
current.classList.remove('glow2');
}
for(var i=0;i<ui.phasequeue.length;i++){
if(ui.phasequeue[i].link==player){
ui.phasequeue[i].classList.add('glow2');
ui.chessinfo.scrollTop=ui.phasequeue[i].offsetTop-8;
break;
}
}
}
},
_chessmove:{
enable:'phaseUse',
usable:1,
direct:true,
delay:false,
content:function(){
player.chooseToMove(2);
},
ai:{
order:5,
result:{
player:function(player){
var range=get.attackRange(player)>1;
var nh=player.num('h');
if(nh<=Math.min(3,player.hp)) return Math.random()-0.3;
else if(nh<=Math.min(3,player.hp)) return Math.random()-0.4;
if(!player.num('h','sha')&&
!player.num('h','shunshou')&&
!player.num('h','bingliang')) return Math.random()-0.5;
var neighbour;
neighbour=player.getNeighbour(0,1);
if(neighbour&&neighbour.side!=player.side){
return range?1:0;
}
neighbour=player.getNeighbour(0,-1);
if(neighbour&&neighbour.side!=player.side){
return range?1:0;
}
neighbour=player.getNeighbour(1,0);
if(neighbour&&neighbour.side!=player.side){
return range?1:0;
}
neighbour=player.getNeighbour(-1,0);
if(neighbour&&neighbour.side!=player.side){
return range?1:0;
}
return 1;
}
}
}
},
_chessswap:{
trigger:{player:['phaseBegin','chooseToUseBegin','chooseToRespondBegin','chooseToDiscardBegin','chooseToCompareBegin',
'chooseButtonBegin','chooseCardBegin','chooseTargetBegin','chooseCardTargetBegin','chooseControlBegin',
'chooseBoolBegin','choosePlayerCardBegin','discardPlayerCardBegin','gainPlayerCardBegin']},
forced:true,
priority:100,
popup:false,
filter:function(event,player){
if(event.autochoose&&event.autochoose()) return false;
return !_status.auto&&player.isUnderControl();
},
content:function(){
game.modeSwapPlayer(player);
},
},
_chesscenter:{
trigger:{player:['phaseBegin','useCardBegin','useSkillBegin','respondBegin','damageBegin','loseHpBegin'],
target:'useCardToBegin'},
forced:true,
priority:100,
popup:false,
content:function(){
player.chessFocus();
},
},
},
translate:{
friend:'友',
enemy:'敌',
trueColor:"zhu",
falseColor:"wei",
_chessmove:'移动',
},
ui:{
create:{
playergrid:function(player,x,y){
var node=ui.create.div('.player.minskin.playergrid',player.parentNode);
node.listen(ui.click.playergrid);
node.link=player;
node.dataset.position=player.getDataPos(x,y);
return node;
},
fakeme:function(){
if(ui.fakeme){
ui.fakeme.delete();
}
ui.fakeme=ui.create.div('.fakeme.avatar',ui.me);
ui.fakeme.style.backgroundImage=game.me.node.avatar.style.backgroundImage;
}
},
click:{
playergrid:function(){
if(!_status.paused) return;
delete lib.posmap[this.link.dataset.position];
this.link.dataset.position=this.dataset.position;
lib.posmap[this.link.dataset.position]=this.link;
if(ui.movegrids){
while(ui.movegrids.length){
ui.movegrids.shift().delete();
}
}
game.resume();
}
}
},
ai:{
get:{
attitude:function(from,to){
return (from.side==to.side?1:-1)*5;
}
}
},
posmap:{},
config:['battle_number','ban_weak','free_choose','change_choice'],
}

View File

@ -204,6 +204,9 @@ mode.guozhan={
}
ui.create.cheat=function(){
ui.cheat=ui.create.control('更换',function(){
if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){
return;
}
event.list=event.list.concat(list);
event.list.randomSort();
list=event.list.splice(0,7);

View File

@ -355,6 +355,9 @@ mode.identity={
};
ui.create.cheat=function(){
ui.cheat=ui.create.control('更换',function(){
if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){
return;
}
if(game.zhu!=game.me){
event.list=event.list.concat(list);
event.list.randomSort();

View File

@ -106,6 +106,7 @@ mode.stone={
game.additionaldead.push(this);
setTimeout(function(){
var player=ui.create.player();
player.classList.add('noidentity');
player.dataset.position=dead.dataset.position;
player.side=dead.side;
player.actcharacterlist=dead.actcharacterlist;
@ -140,6 +141,7 @@ mode.stone={
game.additionaldead.push(this);
setTimeout(function(){
var player=ui.create.player();
player.classList.add('noidentity');
player.dataset.position=dead.dataset.position;
player.side=dead.side;
player.actcharacterlist=dead.actcharacterlist;
@ -179,7 +181,6 @@ mode.stone={
},
game:{
reserveDead:true,
layoutFixed:true,
updateStatusCount:function(){
_status.friendCount.innerHTML='我方兵力:'+get.cnNumber(1+_status.mylist.length/(_status.double_character?2:1),true);
_status.enemyCount.innerHTML='敌方兵力:'+get.cnNumber(1+_status.enemylist.length/(_status.double_character?2:1),true);
@ -211,7 +212,7 @@ mode.stone={
}
},
initStone:function(){
var list=[];
var list=[],list2=[];
var i,j,name;
for(i in lib.character){
if(lib.character[i][4]&&lib.character[i][4].contains('minskin')&&lib.character[i][4].contains('stone')){
@ -219,7 +220,12 @@ mode.stone={
lib.character[i][3].add('stoneshan');
lib.character[i][3].add('stonedraw');
name=i+'_stonecharacter';
list.push(name);
if(lib.character[i][5][0]<3){
list.push(name);
}
else{
list2.push(name);
}
lib.card[name]={
image:'character/default/'+i,
stoneact:lib.character[i][5][0]
@ -231,16 +237,13 @@ mode.stone={
lib.translate[name+'_info']=get.skillintro(i);
}
}
var totallength=Math.ceil(lib.card.list.length/40);
var addedcardcount=Math.ceil(lib.card.list.length/80);
var addedcardcount2=Math.ceil(lib.card.list.length/160);
var suit=['heart','diamond','club','spade'];
while(totallength--){
while(addedcardcount--){
for(i=0;i<list.length;i++){
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),list[i]]);
}
}
while(addedcardcount--){
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'shengerpingdeng']);
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'konghunshi']);
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'emofengdi']);
@ -253,6 +256,9 @@ mode.stone={
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'fengraozhijiao']);
}
while(addedcardcount2--){
for(i=0;i<list2.length;i++){
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),list2[i]]);
}
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'liumangxingzhen']);
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'dianhaishenzhu']);
lib.card.list.push([suit.randomGet(),Math.ceil(Math.random()*13),'yesushengxue']);
@ -290,6 +296,9 @@ mode.stone={
ui.arena.classList.add('stone');
game.delay();
"step 1"
for(var i=0;i<game.players.length;i++){
game.players[i].classList.add('noidentity');
}
game.enemy=game.me.next;
game.chooseCharacter();
"step 2"
@ -376,6 +385,9 @@ mode.stone={
ui.selected.buttons.length+'/'+_status.event.selectButton();
};
event.changeDialog=function(){
if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){
return;
}
list.randomSort();
_status.event.dialog.close();
_status.event.dialog=ui.create.dialog('按顺序选择出场角色'+(get.config('double_character')?'(双将)':''));

View File

@ -58,10 +58,8 @@ mode.versus={
next.content=function(){
"step 0"
event.check=function(){
this.dialog.style.top='40px';
this.dialog.style.left='calc(5% + 60px)';
this.dialog.style.width='calc(90% - 120px)';
this.dialog.style.height='calc(100% - 80px)';
this.dialog.classList.add('fullwidth');
this.dialog.classList.add('fullheight');
this.dialog.classList.add('noslide');
for(var i=0;i<this.dialog.buttons.length;i++) this.dialog.buttons[i].style.opacity=1;
this.dialog.add('选项');
@ -83,7 +81,7 @@ mode.versus={
this.dialog.versus_control_all=this.dialog.add(ui.create.switcher('versus_control_all',lib.storage.control_all)).querySelector('.toggle');
this.dialog.versus_die_stop=this.dialog.add(ui.create.switcher('versus_die_stop',lib.storage.die_stop)).querySelector('.toggle');
this.dialog.versus_number=this.dialog.add(ui.create.switcher('versus_number',[1,2,3],lib.storage.number)).querySelector('.toggle');
this.dialog.replace_number=this.dialog.add(ui.create.switcher('replace_number',[0,1,2,3,4,5,7,9,17],lib.storage.replace_number)).querySelector('.toggle');
this.dialog.replace_number=this.dialog.add(ui.create.switcher('replace_number',[0,1,2,3,5,7,9,17],lib.storage.replace_number)).querySelector('.toggle');
this.dialog.choice=this.dialog.add(ui.create.switcher('choice',[12,16,20,24,40,'∞'],lib.storage.choice)).querySelector('.toggle');
};
event.confirm=function(){