This commit is contained in:
libccy 2016-04-23 17:34:40 +08:00
parent 2f15643b6d
commit 0e13d77986
11 changed files with 585 additions and 89 deletions

View File

@ -28,11 +28,11 @@ card.extra={
target.node.jiu=ui.create.div('.playerjiu',target.node.avatar);
target.node.jiu2=ui.create.div('.playerjiu',target.node.avatar2);
}
if(card.clone&&card.clone.parentNode==target.parentNode){
if(card.clone&&(card.clone.parentNode==target.parentNode||card.clone.parentNode==ui.arena)){
card.clone.moveDelete(target);
}
},target,card);
if(card.clone&&card.clone.parentNode==target.parentNode){
if(card.clone&&(card.clone.parentNode==target.parentNode||card.clone.parentNode==ui.arena)){
game.addVideo('gain2',target,get.cardsInfo([card]));
}
}

View File

@ -260,7 +260,7 @@ card.swd={
if(target==_status.dying) target.recover();
else{
target.addTempSkill('tianxianjiu',['phaseAfter','shaAfter']);
if(card.clone&&card.clone.parentNode==player.parentNode){
if(card.clone&&(card.clone.parentNode==player.parentNode||card.clone.parentNode==ui.arena)){
card.clone.moveDelete(target);
game.addVideo('gain2',target,get.cardsInfo([card]));
}

View File

@ -1869,6 +1869,7 @@ character.shenhua={
event.current.animate('target');
event.current.chooseToUse('乱舞:使用一张杀或流失一点体力',{name:'sha'},function(card,player,target){
if(player==target) return false;
if(!player.canUse('sha',target)) return false;
if(get.distance(player,target)<=1) return true;
for(var i=0;i<game.players.length;i++){
if(game.players[i]==player) continue;

View File

@ -13,7 +13,7 @@ window.config={
forbiddouble:['zhugedan','swd_kangnalishi','dongzhuo','wutugu','jg_simayi','hs_siwangzhiyi','hs_ronghejuren','hs_shanlingjuren'],
layoutfixed:['chess'],
all:{
stockmode:['identity','guozhan','versus','boss','chess','stone','connect'],
stockmode:['identity','guozhan','versus','boss','chess','stone','connect','story','realtime'],
layout:['default','newlayout'],
theme:['woodden','music','simple'],
card_font:['xiaozhuan','huangcao','caoshu','xingshu'],

View File

@ -2628,7 +2628,7 @@
var node=this;
if(node._clearing){
game.save(get.config('chess_leader_save'),null);
window.location.reload();
game.reload();
return;
}
node._clearing=true;
@ -2746,6 +2746,65 @@
},
}
},
story:{
name:'剧情',
config:{
save:{
name:'选择历程',
init:'save1',
item:{
save1:'一',
save2:'二',
save3:'三',
save4:'四',
save5:'五',
},
restart:true,
frequent:true,
},
clear:{
name:'清除进度',
onclick:function(){
var node=this;
if(node._clearing){
game.save(get.config('save'),null);
game.reload();
return;
}
node._clearing=true;
node.innerHTML='单击以确认 (3)';
setTimeout(function(){
node.innerHTML='单击以确认 (2)';
setTimeout(function(){
node.innerHTML='单击以确认 (1)';
setTimeout(function(){
node.innerHTML='清除进度';
delete node._clearing;
},1000);
},1000);
},1000);
},
clear:true,
frequent:true,
},
chessscroll_speed:{
name:'边缘滚动速度',
init:'20',
item:{
'0':'不滚动',
'10':'10格/秒',
'20':'20格/秒',
'30':'30格/秒',
}
},
}
},
realtime:{
name:'即时',
config:{
}
},
stone:{
name:'炉石',
config:{
@ -2978,7 +3037,7 @@
dialog.style.top=idealtop+'px';
},
isMobileMe:function(player){
return (lib.config.layout=='mobile'||lib.config.layout=='phone')&&lib.config.mode!='chess'&&player.dataset.position==0;
return (lib.config.layout=='mobile'||lib.config.layout=='phone')&&!game.chess&&player.dataset.position==0;
},
isNewLayout:function(){
if(lib.config.layout!='default') return true;
@ -3180,6 +3239,10 @@
if(!lib.config.gameRecord){
lib.config.gameRecord={};
}
if(lib.config.debug){
mode.pack.story='剧情';
mode.pack.realtime='即时';
}
for(i in mode.pack){
if(lib.config.hiddenModePack.indexOf(i)==-1){
lib.config.all.mode.push(i);
@ -5449,7 +5512,7 @@
event.dialog.add('手牌');
var hs=target.get('h');
hs.randomSort();
if(event.visible||target==player){
if(event.visible||target.isUnderControl(true)){
event.dialog.add(hs);
}
else{
@ -5524,7 +5587,7 @@
event.dialog.add('手牌');
var hs=target.get('h');
hs.randomSort();
if(event.visible||target==player){
if(event.visible||target.isUnderControl(true)){
event.dialog.add(hs);
}
else{
@ -5615,7 +5678,7 @@
event.dialog.add('手牌');
var hs=target.get('h');
hs.randomSort();
if(event.visible||target==player){
if(event.visible||target.isUnderControl(true)){
event.dialog.add(hs);
}
else{
@ -6900,12 +6963,12 @@
card.classList.remove('drawinghidden');
card.viewAs=viewAs;
player.node.judges.insertBefore(card,player.node.judges.firstChild);
if(card.clone&&card.clone.parentNode==player.parentNode){
if(card.clone&&(card.clone.parentNode==player.parentNode||card.clone.parentNode==ui.arena)){
card.clone.moveDelete(player);
game.addVideo('gain2',player,get.cardsInfo([card]));
}
},player,cards[0],viewAs);
if(cards[0].clone&&cards[0].clone.parentNode==player.parentNode){
if(cards[0].clone&&(cards[0].clone.parentNode==player.parentNode||cards[0].clone.parentNode==ui.arena)){
cards[0].clone.moveDelete(player);
game.addVideo('gain2',player,get.cardsInfo(cards));
}
@ -6940,7 +7003,7 @@
else{
event=_status.event;
}
if(lib.config.mode=='chess'){
if(game.chess){
event.node=card.copy('thrown','center',ui.arena).animate('start');
}
else{
@ -9036,7 +9099,7 @@
this.checkShow(name);
}
game.trySkillAudio(name,this,true);
if(lib.config.mode=='chess'){
if(game.chess){
this.chessFocus();
}
},
@ -9536,7 +9599,7 @@
isMin:function(distance){
if(distance&&lib.config.mode!='stone') return false;
if(this.forcemin) return true;
return this.classList.contains('minskin')&&lib.config.mode!='chess';
return this.classList.contains('minskin')&&!game.chess;
},
isIn:function(){
return this.classList.contains('dead')==false&&this.classList.contains('out')==false&&!this.removed;
@ -9560,6 +9623,9 @@
if(_status.mode=='combat'&&!get.config('single_control')) return false;
return this.side==game.me.side;
}
else if(lib.config.mode=='story'){
return this.side==game.me.side;
}
return false;
},
isOnline:function(){
@ -9674,15 +9740,30 @@
node.fixed=true;
node.hide();
if(game.chess){
var rect=this.getBoundingClientRect();
var dx=rect.left+this.offsetWidth/2-ui.arena.offsetWidth/2;
var dy=rect.top+this.offsetHeight/2-ui.arena.offsetHeight/2;
var coeff=240/Math.sqrt(dx*dx+dy*dy);
dx*=coeff;
dy*=coeff;
node.style.left=(this.offsetLeft+this.offsetWidth/2-52-dx)+'px';
node.style.top=(this.offsetTop+this.offsetHeight/2-52-dy)+'px';
this.parentNode.appendChild(node);
}
else{
this.parentNode.appendChild(node);
node.style.left='calc(50% - 52px)';
node.style.top='calc(50% - 52px)';
this.parentNode.appendChild(node);
node.style.transitionDuration='0.8s';
ui.refresh(node);
var dx=this.offsetLeft+this.offsetWidth/2-52-node.offsetLeft;
var dy=this.offsetTop+this.offsetHeight/2-52-node.offsetTop;
}
node.style.transitionDuration='0.8s';
ui.refresh(node);
if(typeof num=='number'&&init!==false){
config={
total:num,
@ -9842,6 +9923,9 @@
}
game.addVideo('throw',this,[get.cardsInfo(card),time]);
}
if(game.chess){
this.chessFocus();
}
if(get.itemtype(card)=='cards'){
var node;
for(var i=0;i<card.length;i++){
@ -9882,6 +9966,23 @@
ui.thrown.push(node);
var uithrowns=ui.thrown.slice(0);
var tops;
if(game.chess){
switch(Math.floor((ui.thrown.length-1)/4)){
case 0:
tops=['calc(50% - 82px)'];
break;
case 1:
tops=['calc(50% - 139px)','calc(50% - 25px)'];
break;
case 2:
tops=['calc(50% - 196px)','calc(50% - 82px)','calc(50% + 32px)'];
break;
default:
tops=['calc(50% - 253px)','calc(50% - 139px)',
'calc(50% - 25px)','calc(50% + 89px)'];
}
}
else{
switch(Math.floor((ui.thrown.length-1)/4)){
case 0:
tops=['calc(50% - 52px)'];
@ -9896,6 +9997,7 @@
tops=['calc(50% - 223px)','calc(50% - 109px)',
'calc(50% + 5px)','calc(50% + 119px)'];
}
}
while(uithrowns.length){
var throwns=uithrowns.splice(0,Math.min(uithrowns.length,4));
switch(throwns.length){
@ -9923,7 +10025,12 @@
top=tops.shift();
}
else{
if(game.chess){
top='calc(50% - 82px)';
}
else{
top='calc(50% - 52px)';
}
}
for(var i=0;i<throwns.length;i++){
throwns[i].style.top=top;
@ -9943,8 +10050,15 @@
var ny=parseCalc(node.style.top);
nx=nx[0]*ui.arena.offsetWidth/100+nx[1];
ny=ny[0]*ui.arena.offsetHeight/100+ny[1];
if(game.chess){
var rect=this.getBoundingClientRect();
var dx=rect.left+this.offsetWidth/2-52-nx;
var dy=rect.top+this.offsetHeight/2-52-ny;
}
else{
var dx=this.offsetLeft+this.offsetWidth/2-52-nx;
var dy=this.offsetTop+this.offsetHeight/2-52-ny;
}
if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
node.style.transform+=' translate('+dx+'px,'+dy+'px)';
}
@ -9973,8 +10087,15 @@
var ny=[50,-52];
nx=nx[0]*ui.arena.offsetWidth/100+nx[1];
ny=ny[0]*ui.arena.offsetHeight/100+ny[1];
if(game.chess){
var rect=this.getBoundingClientRect();
var dx=rect.left+this.offsetWidth/2-52-nx;
var dy=rect.top+this.offsetHeight/2-52-ny;
}
else{
var dx=this.offsetLeft+this.offsetWidth/2-52-nx;
var dy=this.offsetTop+this.offsetHeight/2-52-ny;
}
if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
node.style.transform+=' translate('+dx+'px,'+dy+'px)';
}
@ -10036,6 +10157,9 @@
else{
top=0;
}
if(game.chess){
top-=30;
}
for(var i=0;i<throwns.length;i++){
throwns[i].style.transform=throwns[i]._transthrown+top+'px)';
delete throwns[i]._transthrown;
@ -10061,7 +10185,7 @@
return node;
},
$throwxy2:function(card,left,top,trans,flipx,flipy){
if(lib.config.mode=='chess'){
if(game.chess){
return this.$throwxy.apply(this,arguments);
}
var node=card.copy('thrown','thrownhighlight');
@ -10339,7 +10463,7 @@
setTimeout(function(){
game.broadcastAll(function(that,type,name,color){
if(lib.config.animation&&!lib.config.low_performance){
if(lib.config.mode=='chess'){
if(game.chess){
that['$'+type+'2'](1200);
}
else{
@ -10355,7 +10479,7 @@
$fire:function(){
game.addVideo('flame',this,'fire');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
@ -10370,7 +10494,7 @@
$thunder:function(){
game.addVideo('flame',this,'thunder');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
@ -10410,7 +10534,7 @@
time=time||700;
game.addVideo('flame',this,'rare');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
@ -10428,7 +10552,7 @@
time=time||700;
game.addVideo('flame',this,'epic');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
@ -10446,7 +10570,7 @@
time=time||700;
game.addVideo('flame',this,'legend');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
@ -10500,7 +10624,7 @@
},this);
game.addVideo('flame',this,'recover');
var left,top;
if(lib.config.mode=='chess'){
if(game.chess){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
@ -11272,16 +11396,22 @@
node.classList.add('controlthundertext');
node.parentNode.classList.add('controlpressdown');
node.parentNode.classList.add('controlpressdownx');
if(typeof node.parentNode._offset=='number'){
node.parentNode.style.transform='translateX('+node.parentNode._offset+'px) scale(0.97)';
}
});
node.addEventListener(lib.config.touchscreen?'touchend':'mouseup',function(){
if(typeof node.parentNode._offset=='number'){
node.parentNode.style.transform='translateX('+node.parentNode._offset+'px)';
}
node.classList.remove('controlthundertext');
node.parentNode.classList.remove('controlpressdown');
node.parentNode.classList.remove('controlpressdownx');
// setTimeout(function(){
// if(node.parentNode)
// },200);
});
node.addEventListener(lib.config.touchscreen?'touchmove':'mousemove',function(){
if(typeof node.parentNode._offset=='number'){
node.parentNode.style.transform='translateX('+node.parentNode._offset+'px)';
}
node.classList.remove('controlthundertext');
node.parentNode.classList.remove('controlpressdown');
node.parentNode.classList.remove('controlpressdownx');
@ -15035,7 +15165,7 @@
}
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(lib.config.mode=='chess'){
if(game.chess){
ui.chess.appendChild(node);
}
else{
@ -15110,7 +15240,7 @@
ctx.lineTo(current[0],current[1]);
ctx.stroke();
};
if(arguments[2]&&lib.config.mode=='chess'){
if(arguments[2]&&game.chess){
game.draw2(drawfunc);
}
else{
@ -16207,7 +16337,7 @@
_status.multitarget=true;
}
if(event.isMine()){
if(lib.config.mode=='chess'&&game.me&&get.config('show_distance')){
if(game.chess&&game.me&&get.config('show_distance')){
for(var i=0;i<game.players.length;i++){
if(game.players[i]==game.me){
game.players[i].node.action.hide();
@ -16263,7 +16393,7 @@
uncheck:function(){
var i,j;
if(true){
if(lib.config.mode=='chess'){
if(game.chess){
var shadows=ui.chessContainer.getElementsByClassName('playergrid temp');
while(shadows.length){
shadows[0].remove();
@ -16350,7 +16480,7 @@
player1.dataset.position=player2.dataset.position;
player2.dataset.position=temp1;
game.arrangePlayers();
if(lib.config.mode!='chess'){
if(!game.chess){
if(player1.dataset.position=='0'||player2.dataset.position=='0'){
pos=parseInt(player1.dataset.position);
if(pos==0) pos=parseInt(player2.dataset.position);
@ -17079,7 +17209,7 @@
game.log(str);
},str);
if(lib.config.title) document.title=str;
if(lib.config.show_log!='off'&&lib.config.mode!='chess'){
if(lib.config.show_log!='off'&&!game.chess){
ui.arenalog.insertBefore(node.cloneNode(true),ui.arenalog.firstChild);
while(ui.arenalog.childNodes.length&&ui.arenalog.scrollHeight>ui.arenalog.offsetHeight){
ui.arenalog.lastChild.remove();
@ -23058,7 +23188,7 @@
e.preventDefault();
var item=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY);
while(item){
if(lib.config.enable_touchdragline&&_status.mouseleft&&lib.config.mode!='chess'){
if(lib.config.enable_touchdragline&&_status.mouseleft&&!game.chess){
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
@ -23111,7 +23241,7 @@
var ex=e.touches[0].clientX-ui.arena.offsetLeft;
var ey=e.touches[0].clientY-ui.arena.offsetTop;
var exx=ex,eyy=ey;
if(lib.config.mode=='chess'){
if(game.chess){
ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft;
ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop;
}
@ -23163,7 +23293,7 @@
}
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(lib.config.mode=='chess'){
if(game.chess){
ui.chess.appendChild(node);
}
else{
@ -23443,7 +23573,7 @@
var ex=e.x-ui.arena.offsetLeft;
var ey=e.y-ui.arena.offsetTop;
var exx=ex,eyy=ey;
if(lib.config.mode=='chess'){
if(game.chess){
ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft;
ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop;
}
@ -23863,7 +23993,7 @@
else{
game.closePopped();
}
if(_status.event.custom.add.window){
if(_status.event.custom&&_status.event.custom.add.window){
_status.event.custom.add.window(clicked);
}
},
@ -23984,7 +24114,7 @@
if(!notoggle){
this.classList.toggle('selected');
}
if(lib.config.mode=='chess'&&get.config('show_range')&&!_status.event.skill&&this.classList.contains('selected')&&
if(game.chess&&get.config('show_range')&&!_status.event.skill&&this.classList.contains('selected')&&
_status.event.isMine()&&_status.event.name=='chooseToUse'){
var player=_status.event.player;
var range=get.info(this).range;
@ -24710,6 +24840,7 @@
var offset=-length/2;
var control=controls.shift();
control.style.transform='translateX('+offset+'px)';
control._offset=offset;
while(controls.length){
var control=controls.shift();
var width=widths.shift();
@ -24718,6 +24849,7 @@
offset+=6;
}
control.style.transform='translateX('+offset+'px)';
control._offset=offset;
}
},
updatex:function(){
@ -24862,7 +24994,7 @@
ui.updates[i]();
}
if(ui.dialog&&!ui.dialog.classList.contains('noupdate')){
if(lib.config.mode=='chess'){
if(game.chess){
if(ui.dialog.content.scrollHeight<240&&(!ui.dialog.buttons||!ui.dialog.buttons.length)){
ui.dialog.style.height=ui.dialog.content.offsetHeight+'px';
ui.dialog.classList.add('slim');
@ -25517,7 +25649,7 @@
if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity;
var player=from,m,n=1,i;
var fxy,txy;
if(lib.config.mode=='chess'){
if(game.chess){
fxy=from.getXY();
txy=to.getXY();
n=Math.abs(fxy[0]-txy[0])+Math.abs(fxy[1]-txy[1]);

BIN
image/splash/realtime.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
image/splash/story.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -140,7 +140,13 @@ table{table-layout: fixed;}
position: relative;
transition: all 0.8s;
}
#splash:not(.touch)>div:hover{
#splash>div:first-child{
margin-left: 20px;
}
#splash>div:last-child{
margin-right: 20px;
}
#splash:not(.touch)>div:hover:not(.clicked){
transform: translateY(-20px);
}
#splash>div.clicked{
@ -1306,6 +1312,7 @@ div:hover>.intro{opacity: 1;}
}
.player .identity[data-color="zhu"],
.player .identity[data-color="truezhu"],
.player .identity[data-color="enemy"],
div[data-nature='fire'],
span[data-nature='fire']{
text-shadow: black 0 0 1px,rgba(232, 53, 53,1) 0 0 2px,rgba(232, 53, 53,1) 0 0 5px,rgba(232, 53, 53,1) 0 0 10px,
@ -1319,6 +1326,8 @@ span[data-nature='firem']{
.player .identity[data-color="zhong"],
.player .identity[data-color="mingzhong"],
.player .identity[data-color="qun"],
.player .identity[data-color="neutral"],
.player .identity[data-color="friend2"],
div[data-nature='metal'],
span[data-nature='metal']{
text-shadow: black 0 0 1px,rgba(255, 203, 0,1) 0 0 2px,rgba(255, 203, 0,1) 0 0 5px,rgba(255, 203, 0,1) 0 0 10px,
@ -1366,6 +1375,7 @@ span[data-nature='woodmm']{
.player .identity[data-color="cai"],
.player .identity[data-color="wei"],
.player .identity[data-color="falsezhu"],
.player .identity[data-color="friend"],
div[data-nature='water'],
span[data-nature='water']{
text-shadow: rgba(78, 117, 140,1) 0 0 2px,rgba(78, 117, 140,1) 0 0 5px,rgba(78, 117, 140,1) 0 0 10px,

View File

@ -1015,7 +1015,7 @@ mode.chess={
}
game.over(game.me.side==game.players[0].side);
},
$draw:function(num){
$draw_old:function(num){
var cards;
if(get.itemtype(num)=='cards'){
cards=num;
@ -1113,7 +1113,7 @@ mode.chess={
}
}
},
$throw:function(card,time,init){
$throw_old:function(card,time,init){
if(init!==false){
if(get.itemtype(card)!='cards'){
if(get.itemtype(card)=='card'){
@ -1413,6 +1413,7 @@ mode.chess={
game:{
minskin:true,
singleHandcard:true,
chess:true,
treasures:[],
obstacles:[],
getVideoName:function(){
@ -2283,7 +2284,7 @@ mode.chess={
var node=ui.create.div('.avatar',ui.chessinfo);
node.style.backgroundImage=p.node.avatar.style.backgroundImage;
node.link=p;
node.listen(game.clickChessInfo);
node.listen(ui.click.chessInfo);
p.instance=node;
if(_status.currentPhase==p){
node.classList.add('glow2');
@ -2300,18 +2301,6 @@ mode.chess={
character:[]
});
},
clickChessInfo:function(e){
if(this.link.isAlive()){
this.link.chessFocus();
if(this.link.classList.contains('selectable')||
this.link.classList.contains('selected')){
// this.link.click();
ui.click.target.call(this.link,e);
ui.click.window.call(ui.window,e);
}
e.stopPropagation();
}
},
leaderView:function(){
var next=game.createEvent('leaderView',false);
next.content=function(){
@ -5462,12 +5451,9 @@ mode.chess={
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;
}
if(player.instance){
player.instance.classList.add('glow2');
ui.chessinfo.scrollTop=player.instance.offsetTop-8;
}
}
},
@ -5482,14 +5468,12 @@ mode.chess={
!player.movable(1,0)&&!player.movable(-1,0)){
return false;
}
// var move=player.skills.contains('noactpunish')?2:1;
var move=2;
move=game.checkMod(player,move,'chessMove',player.get('s'));
return move>0;
},
content:function(){
"step 0"
// var move=player.skills.contains('noactpunish')?2:1;
var move=2;
move=game.checkMod(player,move,'chessMove',player.get('s'));
player.chooseToMove(move).phasing=true;
@ -5563,7 +5547,7 @@ mode.chess={
popup:false,
filter:function(event,player){
if(event.autochoose&&event.autochoose()) return false;
if(_status.mode=='combat'&&!get.config('single_control')) return false;
if(lib.config.mode=='chess'&&_status.mode=='combat'&&!get.config('single_control')) return false;
return player.isUnderControl();
},
content:function(){
@ -5919,6 +5903,17 @@ mode.chess={
}
},
click:{
chessInfo:function(e){
if(this.link.isAlive()){
this.link.chessFocus();
if(this.link.classList.contains('selectable')||
this.link.classList.contains('selected')){
ui.click.target.call(this.link,e);
ui.click.window.call(ui.window,e);
}
e.stopPropagation();
}
},
playergrid:function(){
if(!_status.paused) return;
var pos=parseInt(this.dataset.position);

9
mode/realtime.js Normal file
View File

@ -0,0 +1,9 @@
'use strict';
mode.realtime={
start:function(){
},
game:{
}
};

349
mode/story.js Normal file
View File

@ -0,0 +1,349 @@
'use strict';
mode.story={
start:function(){
'step 0'
game.loadChess();
'step 1'
game.combat({
size:[6,4]
});
},
game:{
minskin:true,
singleHandcard:true,
chess:true,
addChessPlayer:function(name,enemy,num,pos){
if(typeof num!='number'){
num=4;
}
var player=ui.create.player();
player.animate('start');
if(enemy){
player.side=!game.me.side;
player.setIdentity('enemy');
player.identity='enemy';
_status.enemies.push(player);
}
else{
player.side=game.me.side;
player.setIdentity('friend');
player.identity='friend';
_status.friends.push(player);
}
game.players.push(player);
game.phasequeue.push(player);
ui.chess.appendChild(player);
if(pos&&!lib.posmap[pos]){
player.dataset.position=pos;
}
else{
var grids=[];
var gridnum=ui.chessheight*ui.chesswidth;
for(var i=0;i<gridnum;i++){
grids.push(i);
}
for(var i=0;i<game.players.length;i++){
grids.remove(parseInt(game.players[i].dataset.position));
}
player.dataset.position=grids.randomGet();
}
lib.posmap[player.dataset.position]=player;
player.init(name);
if(num){
player.directgain(get.cards(num));
}
game.arrangePlayers();
player.chessFocus();
game.setChessInfo();
return player;
},
setChessInfo:function(){
ui.chessinfo.innerHTML='';
for(var i=0;i<game.players.length;i++){
var p=game.players[i];
var node=ui.create.div('.avatar',ui.chessinfo);
node.style.backgroundImage=p.node.avatar.style.backgroundImage;
node.link=p;
node.listen(ui.click.chessInfo);
p.instance=node;
if(_status.currentPhase==p){
node.classList.add('glow2');
}
}
},
combat:function(config){
var next=game.createEvent('combat');
next.config=config;
next.content=function(){
'step 0'
game.phasequeue=[];
_status.friends=[];
_status.enemies=[];
lib.setPopped(ui.create.system('手牌',null,true),function(){
var uiintro=ui.create.dialog('hidden');
var added=false;
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==game.me.side&&game.players[i]!=game.me){
added=true;
uiintro.add(get.translation(game.players[i]));
var cards=game.players[i].get('h');
if(cards.length){
uiintro.addSmall(cards,true);
}
else{
uiintro.add('(无)');
}
}
}
if(!added){
uiintro.add('无队友');
}
return uiintro;
},220);
_status.enemyDied=0;
_status.friendDied=0;
ui.enemyDied=ui.create.system('杀敌: '+get.cnNumber(0),null,true);
ui.friendDied=ui.create.system('阵亡: '+get.cnNumber(0),null,true);
ui.chesssheet=document.createElement('style');
document.head.appendChild(ui.chesssheet);
ui.chesswidth=event.config.size[0];
ui.chessheight=event.config.size[1];
ui.chess.style.height=148*ui.chessheight+'px';
ui.chess.style.width=148*ui.chesswidth+'px';
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);
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);
}
ui.create.me();
ui.create.fakeme();
ui.chessinfo=ui.create.div('.fakeme.player',ui.me,function(e){
e.stopPropagation();
});
lib.setScroll(ui.chessinfo);
var list=['caocao','liubei','sunquan','zhangjiao','yuanshao','dongzhuo'];
for(var i=0;i<list.length;i++){
game.addChessPlayer(list[i],i>=list.length/2,0);
}
game.modeSwapPlayer(game.players[3]);
game.delay(0.5);
'step 1'
event.trigger('gameStart');
game.gameDraw(game.players[0]);
game.phaseLoop(game.players[0]);
}
},
loadChess:function(){
var next=game.createEvent('loadChess');
next.content=function(){
'step 0'
game.loadMode('chess');
'step 1'
for(var i in result.element){
for(var j in result.element[i]){
if(j!='dieAfter'){
lib.element[i][j]=result.element[i][j];
}
}
}
for(var i in result.ui){
for(var j in result.ui[i]){
ui[i][j]=result.ui[i][j];
}
}
ai.get.attitude=result.ai.get.attitude;
game.$randomMove=result.game.$randomMove;
game.modeSwapPlayer=result.game.modeSwapPlayer;
game.isChessNeighbour=result.game.isChessNeighbour;
get.chessDistance=result.get.chessDistance;
lib.skill._chessmove=result.skill._chessmove;
lib.skill._chessswap=result.skill._chessswap;
lib.skill._chesscenter=result.skill._chesscenter;
lib.skill._phasequeue=result.skill._phasequeue;
'step 2'
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(lib.assetURL+'layout/mode','chess');
ui.create.cards();
game.finishCards();
ui.arena.classList.add('chess');
ui.chessContainer=ui.create.div('#chess-container',ui.arena);
lib.setScroll(ui.chessContainer);
ui.chess=ui.create.div('#chess',ui.chessContainer);
ui.canvas2=document.createElement('canvas');
ui.canvas2.id='canvas2';
ui.chess.appendChild(ui.canvas2);
ui.ctx2=ui.canvas2.getContext('2d');
game.me=ui.create.player();
if(!lib.config.touchscreen){
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(){
this._chessdrag=null;
});
ui.chess.addEventListener('mouseup',function(){
if(this._chessdrag){
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;
_status.clicked=true;
}
e.preventDefault();
});
ui.chessContainer.addEventListener('mousewheel',function(){
if(_status.currentChessFocus){
clearInterval(_status.currentChessFocus);
delete _status.currentChessFocus;
}
});
}
ui.chessscroll1=ui.create.div('.chessscroll.left',ui.chessContainer);
ui.chessscroll2=ui.create.div('.chessscroll.right',ui.chessContainer);
var chessscroll=function(){
if(lib.config.touchscreen) return;
var direction=this.direction;
var speed=parseInt(get.config('chessscroll_speed'));
if(!speed) return;
var interval=setInterval(function(){
ui.chessContainer.scrollLeft+=speed*direction;
},16);
_status.chessscrolling=interval;
};
var leavescroll=function(){
if(_status.chessscrolling){
clearInterval(_status.chessscrolling);
delete _status.chessscrolling;
}
};
ui.chessscroll1.direction=-1;
ui.chessscroll1.addEventListener('mouseenter',chessscroll);
ui.chessscroll1.addEventListener('mouseleave',leavescroll);
ui.chessscroll2.direction=1;
ui.chessscroll2.addEventListener('mouseenter',chessscroll);
ui.chessscroll2.addEventListener('mouseleave',leavescroll);
}
}
},
element:{
player:{
dieAfter:function(){
var player=this;
if(_status.friends){
_status.friends.remove(this);
}
if(_status.enemies){
_status.enemies.remove(this);
}
if(ui.friendDied&&player.side==game.me.side){
ui.friendDied.innerHTML='阵亡: '+get.cnNumber(++_status.friendDied,true);
}
if(ui.enemyDied&&player.side!=game.me.side){
ui.enemyDied.innerHTML='杀敌: '+get.cnNumber(++_status.enemyDied,true);
}
delete lib.posmap[player.dataset.position];
setTimeout(function(){
player.delete();
},500);
if(player.instance){
player.instance.remove();
}
if(_status.friends.length==0){
game.over(false);
}
else if(_status.enemies.length==0){
game.over(true);
}
}
}
},
skill:{
_attackmove:{
trigger:{player:'damageEnd'},
forced:true,
popup:false,
priority:50,
filter:function(event,player){
if(!event.source) return false;
if(get.distance(event.source,player,'pure')>2) return false;
var xy1=event.source.getXY();
var xy2=player.getXY();
var dx=xy2[0]-xy1[0];
var dy=xy2[1]-xy1[1];
if(dx==0&&Math.abs(dy)==2){
dy/=2;
}
if(dy==0&&Math.abs(dx)==2){
dx/=2;
}
return player.movable(dx,dy);
},
content:function(){
var xy1=trigger.source.getXY();
var xy2=player.getXY();
var dx=xy2[0]-xy1[0];
var dy=xy2[1]-xy1[1];
if(dx==0&&Math.abs(dy)==2){
dy/=2;
}
if(dy==0&&Math.abs(dx)==2){
dx/=2;
}
if(player.movable(dx,dy)){
player.move(dx,dy);
}
}
},
},
posmap:{},
translate:{
friend:'友',
friend2:'友',
enemy:'敌',
neutral:'中',
_chessmove:'移动'
}
};