Files
2026-08-17 13:59:12 +08:00

3 lines
5.8 KiB
JavaScript

"use strict";const h=require("../../../common/vendor.js"),b="tongji_game_sfx_enabled",m="https://gz-1349751149.cos.ap-guangzhou.myqcloud.com/uploads/file",t={tap:`${m}/20260526/20260526105128557ef8669.mp3`,swoosh:`${m}/20260527/202605271539371ebe13672.mp3`,pop:`${m}/20260526/202605261051282a0a94508.mp3`,buzz:`${m}/20260527/202605271539376ff628472.mp3`,chime:`${m}/20260528/202605280937077bad76716.mp3`,fanfare:`${m}/20260528/20260528093707b021f5794.mp3`,blast:`${m}/20260528/20260528093707ebd4d5733.mp3`,sparkle:`${m}/20260528/20260528093707016f07427.mp3`,stinger:`${m}/20260528/20260528093709c669f4659.mp3`},z={tap:{src:t.tap,volume:.32,rate:1,pool:3},pop:{src:t.pop,volume:.3,rate:1,pool:4},fanfare:{src:t.fanfare,volume:.56,rate:1,pool:2},blast:{src:t.blast,volume:.62,rate:1,pool:2},sparkle:{src:t.sparkle,volume:.5,rate:1,pool:2},select:{src:t.tap,volume:.32,rate:1.05,pool:3},deselect:{src:t.tap,volume:.22,rate:.82,pool:2},hint:{src:t.tap,volume:.26,rate:1.28,pool:2},swap:{src:t.swoosh,volume:.38,rate:1,pool:3},swapFail:{src:t.buzz,volume:.36,rate:1.18,pool:2},drop:{src:t.pop,volume:.3,rate:.88,pool:4},dropLight:{src:t.pop,volume:.22,rate:1.22,pool:2},match3:{src:t.chime,volume:.48,rate:1,pool:4},match4:{src:t.fanfare,volume:.54,rate:1.06,pool:3},match5:{src:t.blast,volume:.62,rate:1,pool:3},matchLowGi:{src:t.chime,volume:.42,rate:.86,pool:2},matchMidGi:{src:t.chime,volume:.46,rate:1.02,pool:2},matchHighGi:{src:t.buzz,volume:.44,rate:.92,pool:2},combo2:{src:t.fanfare,volume:.56,rate:1.12,pool:2},combo3:{src:t.blast,volume:.64,rate:1.08,pool:2},comboMega:{src:t.blast,volume:.72,rate:1.22,pool:2},insulin:{src:t.sparkle,volume:.5,rate:1.15,pool:2},fiber:{src:t.swoosh,volume:.48,rate:1.32,pool:2},meal:{src:t.stinger,volume:.42,rate:1.35,pool:1},reshuffle:{src:t.swoosh,volume:.46,rate:.72,pool:2},score:{src:t.tap,volume:.28,rate:1.38,pool:2},goalTick:{src:t.chime,volume:.36,rate:1.45,pool:2},meterWarn:{src:t.buzz,volume:.5,rate:1,pool:2},meterDanger:{src:t.buzz,volume:.58,rate:.78,pool:2},meterStable:{src:t.pop,volume:.24,rate:1.05,pool:1},win:{src:t.fanfare,volume:.66,rate:1,pool:1},winStinger:{src:t.stinger,volume:.38,rate:1.5,pool:1},lose:{src:t.buzz,volume:.52,rate:.68,pool:1},match:{src:t.chime,volume:.48,rate:1,pool:4},combo:{src:t.fanfare,volume:.56,rate:1.1,pool:3},heal:{src:t.pop,volume:.44,rate:1.18,pool:2},boost:{src:t.sparkle,volume:.52,rate:1,pool:2},invalid:{src:t.buzz,volume:.4,rate:1.15,pool:2},danger:{src:t.blast,volume:.58,rate:.95,pool:2}},S=["select","swap","swapFail","drop","dropLight","match3","match4","match5","combo2","combo3","comboMega","insulin","sparkle","reshuffle","lose"];function _(){if(typeof Audio<"u"){const r=new Audio;return r.preload="auto",{get src(){return r.src},set src(e){r.src=e},get volume(){return r.volume},set volume(e){r.volume=e},get playbackRate(){return r.playbackRate},set playbackRate(e){r.playbackRate=e},play(){const e=r.play();e!=null&&e.catch&&e.catch(()=>{})},stop(){r.pause();try{r.currentTime=0}catch{}},seek(e){try{r.currentTime=e}catch{}},destroy(){r.pause(),r.removeAttribute("src")}}}return h.index.createInnerAudioContext()}class k{constructor(e,c,l,i=1){this.src=e,this.size=c,this.volume=l,this.rate=i,this.list=[],this.cursor=0,this.warmedUp=!1}createOne(){const e=_();e.src=this.src,e.obeyMuteSwitch=!1,e.autoplay=!1,e.volume=this.volume;try{e.playbackRate=this.rate}catch{}return this.list.push(e),e}create(){for(;this.list.length<this.size;)this.createOne()}warmUp(){if(this.warmedUp)return;const e=this.list[0]||this.createOne();try{e.volume=0,e.play(),setTimeout(()=>{try{e.stop(),e.volume=this.volume}catch{}},60)}catch{}this.size>1&&(this.cursor=1),this.warmedUp=!0}play(e=1,c=1){this.list.length<this.size&&this.create();const l=this.list[this.cursor%this.list.length];this.cursor+=1;const i=Math.min(1,this.volume*e),s=Math.min(2,Math.max(.5,this.rate*c));try{l.volume=i;try{l.playbackRate=s}catch{}l.stop(),l.seek(0),l.play()}catch{try{l.play()}catch{}}}destroy(){this.list.forEach(e=>{try{e.stop(),e.destroy()}catch{}}),this.list=[],this.warmedUp=!1}}function x(r=[]){const e={low:0,mid:0,high:0};r.forEach(i=>{var u;const s=(u=i==null?void 0:i.type)==null?void 0:u.gi;s&&e[s]!==void 0&&(e[s]+=1)});let c="mid",l=0;return Object.entries(e).forEach(([i,s])=>{s>l&&(l=s,c=i)}),c}function M(){const r=h.ref(!0),e={};try{const o=h.index.getStorageSync(b);(o===!1||o==="0"||o===0)&&(r.value=!1)}catch{}function c(){try{h.index.setInnerAudioOption({obeyMuteSwitch:!1,mixWithOther:!0})}catch{}}function l(o){const a=z[o];return a?(e[o]||(e[o]=new k(a.src,a.pool,a.volume,a.rate??1)),e[o]):null}function i(){if(!r.value)return;c(),(typeof Audio<"u"?["select"]:S).forEach(a=>{var p;(p=l(a))==null||p.warmUp()})}function s(o,a=1,p=1){var n;r.value&&((n=l(o))==null||n.play(a,p))}function u(o,a,p=70,n=.6){s(o),a&&setTimeout(()=>s(a,n),p)}function f({matchCount:o=3,chain:a=0,tiles:p=[]}={}){if(!r.value)return;const n=(()=>{const d=x(p);return d==="low"?"matchLowGi":d==="high"?"matchHighGi":"matchMidGi"})();if(a>=3){u("comboMega",n,90,.55);return}if(a===2){u("combo3",n,80,.5);return}if(a===1){u("combo2",n,70,.45);return}o>=5?u("match5","matchHighGi",85,.5):o>=4?u("match4",n,65,.48):(s(n,1,1),setTimeout(()=>s("match3",.85),40))}function y(o=1){if(!r.value||o<=0)return;const a=o>=4?"drop":"dropLight";s(a,Math.min(1.2,.85+o*.04),o>=6?.9:1)}function g(o,a){r.value&&(a>70?s("meterDanger",1+(a-70)*.02):a<30?s("meterWarn",.9,.95):o>8?s("meterWarn",.75):o<-5&&s("meterStable",1.1))}function w(){r.value=!r.value;try{h.index.setStorageSync(b,r.value?"1":"0")}catch{}r.value&&(i(),s("select"))}function v(){Object.keys(e).forEach(o=>{var a;(a=e[o])==null||a.destroy(),delete e[o]})}return h.onUnmounted(()=>{v()}),{enabled:r,play:s,playLayer:u,playMatch:f,playDrop:y,playMeter:g,warmUp:i,toggleEnabled:w,destroyAll:v}}exports.useGameSfx=M;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/tongji/endless-game/composables/useGameSfx.js.map