Merge pull request #206 from Tipx-L/PR-Branch
Add various features to lib.element.content.chooseToPlayBeatmap, and game.generateBeatmapTimeleap, and new beatmaps.
This commit is contained in:
commit
0ce89d276e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -4110,7 +4110,15 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
{
|
||||
name:'ignotus',
|
||||
filename:'ignotus',
|
||||
timeleap:[0,1412,2824,4235,5647,5824,7059,8294,8471,9882,10941,11294,12000,12706,13412,14118,14824,15529,15882,16059,16235,16412,16588],
|
||||
//Number of tracks
|
||||
//轨道数量
|
||||
number_of_tracks:4,
|
||||
//Customize the track to generate for every note (0 is the first track)
|
||||
//自定义每个音符生成的轨道(0是第一个轨道)
|
||||
mapping:[0,2,3,1,1,0,3,0,0,3,0,0,2,1,2],
|
||||
//Convert from beats (0 is the first beat) to timeleap
|
||||
//将节拍(0是第一拍)转换为开始时间点
|
||||
timeleap:game.generateBeatmapTimeleap(170,[0,4,8,12,14,16,16.5,23.5,24,31,32,40,45,46,47]),
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
range1:[84,110],
|
||||
|
@ -4123,6 +4131,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
{
|
||||
name:'Super Mario 3D World Theme',
|
||||
filename:'sm3dw_overworld',
|
||||
//Random (Randomly choose tracks to generate notes each play)
|
||||
//随机(每次演奏时音符会随机选择轨道生成)
|
||||
mapping:'random',
|
||||
timeleap:[0,1071,1518,2054,4018,4286,5357,6429,7500,8571,9643,10714,11786,12321,12589,12857,13929,15000,16071,17143,18214,18482,18750,19018,19286,20357],
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
|
@ -4133,6 +4144,67 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
node_color:'linear-gradient(rgba(120, 130, 240, 1), rgba(100, 100, 230, 1))',
|
||||
judgebar_color:'linear-gradient(rgba(230, 40, 30, 1), rgba(220, 30, 10, 1))',
|
||||
},
|
||||
{
|
||||
name:'只因你太美',
|
||||
filename:'chicken_you_are_so_beautiful',
|
||||
number_of_tracks:7,
|
||||
mapping:[3,6,4,5,6,2,3,2,1,2,0,4,3,6,5,4,3,6,3,2,3,1,0,1,2,3,4,5,6],
|
||||
timeleap:game.generateBeatmapTimeleap(107,[2,3.5,4.5,5.5,6.5,8.5,10,11.5,12.5,13.5,14.5,15.5,18,19.5,20.5,21.5,22.5,24.5,26,27.5,28.5,29.5,30.5,31,31.5,32,32.5,33,33.5]),
|
||||
//Hitsound file name (By default in the audio/effect folder. To redirect to the extension, please write in the format of 'ext:extension_name')
|
||||
//打击音文件名(默认在audio/effect文件夹下 若要重定向到扩展 请写为'ext:扩展名称'的格式)
|
||||
hitsound:'chickun.wav',
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
range1:[84,110],
|
||||
range2:[90,104],
|
||||
range3:[94,100],
|
||||
speed:25,
|
||||
node_color:'linear-gradient(#99f, #66c)',
|
||||
judgebar_color:'linear-gradient(#ccf, #99c)',
|
||||
},
|
||||
{
|
||||
name:'Croatian Rhapsody',
|
||||
filename:'croatian_rhapsody',
|
||||
mapping:[4,1,2,1,0,0,4,5,1,3,2,1,0,0],
|
||||
timeleap:game.generateBeatmapTimeleap(96,[4,6,8,9,10,11,12,13.5,14,15.5,16,17,18,19]),
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
range1:[84,110],
|
||||
range2:[90,104],
|
||||
range3:[94,100],
|
||||
speed:25,
|
||||
node_color:'linear-gradient(#fff, #ccc)',
|
||||
judgebar_color:'linear-gradient(#fff, #ccc)',
|
||||
},
|
||||
{
|
||||
name:'罗刹海市',
|
||||
filename:'rakshasa_sea_city',
|
||||
number_of_tracks:7,
|
||||
mapping:'random',
|
||||
timeleap:game.generateBeatmapTimeleap(150,[0,2,4,6,7,9,11,13,14,16,18,20,21,23,25,27]),
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
range1:[84,110],
|
||||
range2:[90,104],
|
||||
range3:[94,100],
|
||||
speed:25,
|
||||
node_color:'linear-gradient(#333, #000)',
|
||||
judgebar_color:'linear-gradient(#c66, #933)',
|
||||
},
|
||||
{
|
||||
name:'Pigstep (Stereo Mix)',
|
||||
filename:'pigstep',
|
||||
number_of_tracks:16,
|
||||
timeleap:game.generateBeatmapTimeleap(170,[3,4,6,6.5,7.5,11,12,14,14.5,15.5,19,20,22,22.5,23.5,27,28,30,30.5,31.5,35,36,38,38.5,39.5,43,44,46,46.5,47.5,51,52,54,54.5,55.5,59,60,62,62.5]),
|
||||
current:-110,
|
||||
judgebar_height:0.16,
|
||||
range1:[84,110],
|
||||
range2:[90,104],
|
||||
range3:[94,100],
|
||||
speed:25,
|
||||
node_color:'linear-gradient(#066, #033)',
|
||||
judgebar_color:'linear-gradient(#633, #300)',
|
||||
},
|
||||
],
|
||||
derivation:'chongxu_faq',
|
||||
},
|
||||
|
@ -6164,12 +6236,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
speed=-4;
|
||||
}
|
||||
};
|
||||
document.addEventListener(lib.config.touchscreen?'touchend':'click',fly);
|
||||
document.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',fly);
|
||||
|
||||
event.settle=function(){
|
||||
clearInterval(event.fly);
|
||||
clearInterval(event.addPipe);
|
||||
document.removeEventListener(lib.config.touchscreen?'touchend':'click',fly);
|
||||
document.removeEventListener(lib.config.touchscreen?'touchstart':'mousedown',fly);
|
||||
setTimeout(function(){
|
||||
event.switchToAuto()
|
||||
},1000);
|
||||
|
@ -8268,7 +8340,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
if(event.zhengjing.length){
|
||||
var card=ui.create.card(ui.special,'noclick',true);
|
||||
card.init(['','',event.zhengjing.shift()]);
|
||||
card.addEventListener(lib.config.touchscreen?'touchend':'click',click);
|
||||
card.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',click);
|
||||
event.zhengjing_nodes.push(card);
|
||||
card.style.position='absolute';
|
||||
var rand1=Math.round(Math.random()*100);
|
||||
|
@ -13427,7 +13499,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
chongxu:'冲虚',
|
||||
chongxu_info:'出牌阶段限一次,你可以随机演奏一首音乐,并根据完成度来获得相应的分数(至多五分)。然后你可修改〖妙剑〗或〖莲华〗(消耗3分),并使用剩余的分数进行摸牌(每张2分)。',
|
||||
chongxu_faq:'目前的曲库',
|
||||
chongxu_faq_info:' <br>《鸟之诗》- 折户伸治<br>《竹取飛翔 ~ Lunatic Princess》- ZUN<br>《ignotus》- ak+q<br>《Super Mario 3D World Theme》- 横田真人',
|
||||
chongxu_faq_info:' <br>《鸟之诗》- 折户伸治<br>《竹取飛翔 ~ Lunatic Princess》- ZUN<br>《ignotus》- ak+q<br>《Super Mario 3D World Theme》- 横田真人<br>《只因你太美》- SWIN-S<br>《Croatian Rhapsody》- Maksim<br>《罗刹海市》- 刀郎<br>《Pigstep (Stereo Mix)》- Lena Raine',
|
||||
miaojian:'妙剑',
|
||||
miaojian_info:'出牌阶段限一次。你可将一张【杀】当做刺【杀】使用,或将一张锦囊牌当做【无中生有】使用。',
|
||||
miaojian1:'妙剑·改',
|
||||
|
|
88
game/game.js
88
game/game.js
|
@ -11084,7 +11084,8 @@
|
|||
game.broadcastAll(function(player,id,beatmap){
|
||||
if(_status.connectMode) lib.configOL.choose_timeout=(Math.ceil((beatmap.timeleap[beatmap.timeleap.length-1]+beatmap.speed*100+(beatmap.current||0))/1000)+5).toString();
|
||||
if(player==game.me) return;
|
||||
var str=get.translation(player)+'正在演奏《'+beatmap.name+'》...<br>';
|
||||
var str=get.translation(player)+'正在演奏《'+beatmap.name+'》...';
|
||||
if(!_status.connectMode) str+='<br>(点击屏幕可以跳过等待AI操作)';
|
||||
ui.create.dialog(str).videoId=id;
|
||||
if(ui.backgroundMusic) ui.backgroundMusic.pause();
|
||||
if(lib.config.background_audio){
|
||||
|
@ -11107,8 +11108,23 @@
|
|||
//初始化一堆变量
|
||||
var score=0;
|
||||
var added=timeleap.length;
|
||||
var number_of_tracks=beatmap.number_of_tracks||6;
|
||||
var custom_mapping=Array.isArray(beatmap.mapping);
|
||||
var mapping=custom_mapping?beatmap.mapping.slice():beatmap.mapping;
|
||||
var hitsound=beatmap.hitsound||'hitsound.wav';
|
||||
if(hitsound.indexOf('ext:')==0) hitsound=lib.assetURL+'extension/'+hitsound.slice(4);
|
||||
else hitsound=lib.assetURL+'audio/effect/'+hitsound;
|
||||
var hitsound_audio=new Audio(hitsound);
|
||||
hitsound_audio.volume=0.25;
|
||||
var abs=1;
|
||||
var node_pos=0;
|
||||
if(custom_mapping){
|
||||
node_pos=mapping.shift();
|
||||
}
|
||||
else if(mapping=='random'){
|
||||
abs=get.rand(number_of_tracks);
|
||||
node_pos=abs;
|
||||
}
|
||||
var combo=0;
|
||||
var max_combo=0;
|
||||
var nodes=[];
|
||||
|
@ -11139,6 +11155,10 @@
|
|||
event.settleed=true;
|
||||
//评分
|
||||
var acc=Math.floor(score/(added*5)*100);
|
||||
if(!Array.isArray(lib.config.choose_to_play_beatmap_accuracies)) lib.config.choose_to_play_beatmap_accuracies=[];
|
||||
lib.config.choose_to_play_beatmap_accuracies.push(acc);
|
||||
if(lib.config.choose_to_play_beatmap_accuracies.length>5) lib.config.choose_to_play_beatmap_accuracies.shift();
|
||||
game.saveConfigValue("choose_to_play_beatmap_accuracies");
|
||||
var rank;
|
||||
if(acc==100) rank=['SS','metal'];
|
||||
else if(acc>=94) rank=['S','orange'];
|
||||
|
@ -11159,7 +11179,8 @@
|
|||
game.resume();
|
||||
_status.imchoosing=false;
|
||||
if(roundmenu) ui.roundmenu.style.display='';
|
||||
if(ui.backgroundMusic) ui.backgroundMusic.play();
|
||||
if(ui.backgroundMusic) ui.backgroundMusic.play().catch(()=>void 0);
|
||||
hitsound_audio.remove();
|
||||
},1000);
|
||||
};
|
||||
event.dialog.open();
|
||||
|
@ -11190,11 +11211,11 @@
|
|||
node.style["border-radius"]='3px';
|
||||
node.style.position='absolute';
|
||||
node.style.height=Math.ceil(height/10)+'px';
|
||||
node.style.width=Math.ceil(width/6)-10+'px';
|
||||
node.style.width=Math.ceil(width/number_of_tracks)-10+'px';
|
||||
node._position=get.utc();
|
||||
event.dialog.appendChild(node);
|
||||
|
||||
node.style.left=Math.ceil(width*node_pos/6+5)+'px';
|
||||
node.style.left=Math.ceil(width*node_pos/number_of_tracks+5)+'px';
|
||||
node.style.top='-'+(Math.ceil(height/10))+'px';
|
||||
ui.refresh(node);
|
||||
node.style.transition='all '+speed*110+'ms linear';
|
||||
|
@ -11208,14 +11229,25 @@
|
|||
}
|
||||
},speed*110);
|
||||
|
||||
node_pos+=abs;
|
||||
if(node_pos>5){
|
||||
abs=-1;
|
||||
node_pos=4;
|
||||
if(custom_mapping){
|
||||
node_pos=mapping.shift();
|
||||
}
|
||||
else if(node_pos<0){
|
||||
abs=1;
|
||||
node_pos=1;
|
||||
else if(mapping=='random'){
|
||||
while(node_pos==abs){
|
||||
node_pos=get.rand(number_of_tracks);
|
||||
}
|
||||
abs=node_pos;
|
||||
}
|
||||
else{
|
||||
node_pos+=abs;
|
||||
if(node_pos>number_of_tracks-1){
|
||||
abs=-1;
|
||||
node_pos=number_of_tracks-2;
|
||||
}
|
||||
else if(node_pos<0){
|
||||
abs=1;
|
||||
node_pos=1;
|
||||
}
|
||||
}
|
||||
if(timeleap.length){
|
||||
setTimeout(function(){
|
||||
|
@ -11261,6 +11293,8 @@
|
|||
if(player.damagepopups.length) player.$damagepop();
|
||||
combo++;
|
||||
max_combo=Math.max(combo,max_combo);
|
||||
hitsound_audio.currentTime=0;
|
||||
if(hitsound_audio.paused) hitsound_audio.play();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -11284,9 +11318,16 @@
|
|||
else{
|
||||
game.pause();
|
||||
game.countChoose();
|
||||
setTimeout(function(){
|
||||
var settle=function(){
|
||||
_status.imchoosing=false;
|
||||
var acc=get.rand.apply(get,beatmap.aiAcc||[70,100]);
|
||||
//Algorithm: Generate the random number range using the mean and the half standard deviation of accuracies of the player's last 5 plays
|
||||
//算法:用玩家的上5次游玩的准确率的平均数和半标准差生成随机数范围
|
||||
var choose_to_play_beatmap_accuracies=(lib.config.choose_to_play_beatmap_accuracies||[]).concat(Array.from({
|
||||
length:6-(lib.config.choose_to_play_beatmap_accuracies||[]).length
|
||||
},()=>get.rand(70,100)));
|
||||
var mean=Math.round(choose_to_play_beatmap_accuracies.reduce((previousValue,currentValue)=>previousValue+currentValue)/choose_to_play_beatmap_accuracies.length);
|
||||
var half_standard_deviation=Math.round(Math.sqrt(choose_to_play_beatmap_accuracies.reduce((previousValue,currentValue)=>previousValue+Math.pow(currentValue-mean,2),0))/2);
|
||||
var acc=Math.min(Math.max(get.rand.apply(get,beatmap.aiAcc||[mean-half_standard_deviation-get.rand(0,half_standard_deviation),mean+half_standard_deviation+get.rand(0,half_standard_deviation)]),0),100);
|
||||
var rank;
|
||||
if(acc==100) rank=['SS','metal'];
|
||||
else if(acc>=94) rank=['S','orange'];
|
||||
|
@ -11302,7 +11343,23 @@
|
|||
if(event.dialog) event.dialog.close();
|
||||
if(event.control) event.control.close();
|
||||
game.resume();
|
||||
},beatmap.timeleap[beatmap.timeleap.length-1]+beatmap.speed*100+1000+(beatmap.current||0));
|
||||
};
|
||||
var song_duration=beatmap.timeleap[beatmap.timeleap.length-1]+beatmap.speed*100+1000+(beatmap.current||0);
|
||||
var settle_timeout=setTimeout(settle,song_duration);
|
||||
if(!_status.connectMode) {
|
||||
var skip_timeout;
|
||||
var skip=()=>{
|
||||
settle();
|
||||
Array.from(ui.window.getElementsByTagName('audio')).forEach(value=>{
|
||||
if(value.currentSrc.indexOf(beatmap.filename.indexOf('ext:')==0?beatmap.name:beatmap.filename)>-1) value.remove();
|
||||
});
|
||||
document.removeEventListener(lib.config.touchscreen?'touchend':'click',skip);
|
||||
clearTimeout(settle_timeout);
|
||||
clearTimeout(skip_timeout);
|
||||
};
|
||||
document.addEventListener(lib.config.touchscreen?'touchend':'click',skip);
|
||||
skip_timeout=setTimeout(()=>document.removeEventListener(lib.config.touchscreen?'touchend':'click',skip),song_duration);
|
||||
}
|
||||
}
|
||||
'step 2'
|
||||
game.broadcastAll(function(id,time){
|
||||
|
@ -11311,7 +11368,7 @@
|
|||
if(dialog){
|
||||
dialog.close();
|
||||
}
|
||||
if(ui.backgroundMusic) ui.backgroundMusic.play();
|
||||
if(ui.backgroundMusic) ui.backgroundMusic.play().catch(()=>void 0);
|
||||
},event.videoId,event.time);
|
||||
var result=event.result||result;
|
||||
event.result=result;
|
||||
|
@ -31090,6 +31147,7 @@
|
|||
],
|
||||
};
|
||||
var game={
|
||||
generateBeatmapTimeleap:(bpm,beats,offset)=>beats.map(value=>Math.round(value*60000/bpm+(offset||0))),
|
||||
updateRenku:function(){
|
||||
game.broadcast(function(renku){
|
||||
_status.renku=renku;
|
||||
|
|
Loading…
Reference in New Issue