assassin-bug/app_web/game.js

2 lines
358 KiB
JavaScript
Raw Normal View History

2022-11-26 01:22:02 +00:00
(()=>{"use strict";class t{constructor(){this.states=new Map}get(t,e=null){return this.states.has(t)?this.states.get(t):(this.states.set(t,e),e)}set(t,e){return this.states.set(t,e)}change(t,e=1){let s=this.get(t,0);s+=e,this.set(t,s)}serialize(){const t=this.states.entries(),e=[];for(let s of t)e.push(s);return e}deserialize(t){this.states=new Map(t)}}class e{constructor(){this.inventory=[],this.currentRoom="start",this.context=null}addItem(t){this.inventory.push(t)}removeItem(t){this.inventory=this.inventory.filter((e=>e!=t))}getInventory(){return this.inventory.map((t=>this.context.getItem(t)))}}class s{speak(t){}stop(){}setOptions(t){}}class i extends s{constructor(t={}){super(),this.timeout=100,this.timeout=t.timeout||100,this.init()}init(){this.container=document.createElement("div"),this.container.setAttribute("aria-live","polite"),this.speechDisplay=document.createElement("div"),this.speechDisplay.setAttribute("aria-live","polite"),this.container.append(this.speechDisplay),document.body.appendChild(this.container),document.body.insertBefore(this.container,document.body.firstChild)}speak(t){this.clearDisplay();const e=document.createTextNode(t),s=document.createElement("p");s.appendChild(e),this.speechDisplay.appendChild(s),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class a extends s{constructor(t={}){super(),this.rate=t.rate||1,this.synth=window.speechSynthesis}speak(t){let e=new SpeechSynthesisUtterance(t);e.rate=this.rate,this.synth.speak(e)}stop(){this.synth.cancel()}setOptions(t){this.rate=t.rate||1}}class n{constructor(t=function(t="aria"){return"webtts"===t?new a:new i}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}var h=function(t,e,s,i){return new(s||(s=Promise))((function(a,n){function h(t){try{u(i.next(t))}catch(t){n(t)}}function r(t){try{u(i.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(h,r)}u((i=i.apply(t,e||[])).next())}))};class r{constructor(){this.context=new AudioContext}getContext(){return this.context}createGain(){return this.context.createGain()}getOutputDestination(){return this.context.destination}createBufferSource(){return this.context.createBufferSource()}decodeAudioData(t){return h(this,void 0,void 0,(function*(){return yield this.context.decodeAudioData(t)}))}createPanner(){return this.context.createPanner()}createMediaElementSource(t){return this.context.createMediaElementSource(t)}}class u{constructor(){this.events=new Map}emit(t,e={}){let s=this.events.get(t);if(s)s.subscribers.forEach((t=>{t(e)}));else{let e=new o(t);this.events.set(t,e)}}subscribe(t,e){let s=this.events.get(t);s||(s=new o(t),this.events.set(t,s)),s.subscribers.push(e)}unsubscribe(t,e){if(this.events.has(t)){let s=this.events.get(t);s.subscribers=s.subscribers.filter((t=>t!==e)),s.subscribers.length<1&&this.events.delete(t)}}unsubscribeAll(t){this.events.has(t)&&this.events.delete(t)}}class o{constructor(t){this.id=t,this.subscribers=[]}}class l{constructor(t){this.values=new Float32Array(4),void 0!==t&&(this.xyzw=t)}get x(){return this.values[0]}get y(){return this.values[1]}get z(){return this.values[2]}get w(){return this.values[3]}get xy(){return[this.values[0],this.values[1]]}get xyz(){return[this.values[0],this.values[1],this.values[2]]}get xyzw(){return[this.values[0],this.values[1],this.values[2],this.values[3]]}set x(t){this.values[0]=t}set y(t){this.values[1]=t}set z(t){this.values[2]=t}set w(t){this.values[3]=t}set xy(t){this.values[0]=t[0],this.values[1]=t[1]}set xyz(t){this.values[0]=t[0],this.values[1]=t[1],this.values[2]=t[2]}set xyzw(t){this.values[0]=t[0],this.values[1]=t[1],this.values[2]=t[2],this.values[3]=t[3]}get r(){return this.values[0]}get g(){return this.values[1]}get b(){return this.values[2]}get a(){return this.values[3]}get rg(){return[this.values[0],this.values[1]]}get rgb(){return[this.values[0],this.values[1],this.values[2]]}get rgba(){return[this.values[0],this.values[1],this.values[2],this.val
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBQWUsTU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