-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbard.html
More file actions
22 lines (22 loc) · 16.1 KB
/
bard.html
File metadata and controls
22 lines (22 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Svelte</title>
<script type="module" crossorigin>var ft=Object.defineProperty;var dt=(e,t,n)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ce=(e,t,n)=>dt(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function N(){}function ct(e){return e()}function Ge(){return Object.create(null)}function ie(e){e.forEach(ct)}function it(e){return typeof e=="function"}function at(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function ht(e){return Object.keys(e).length===0}function pt(e,...t){if(e==null){for(const s of t)s(void 0);return N}const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function _t(e,t,n){e.$$.on_destroy.push(pt(t,n))}function i(e,t){e.appendChild(t)}function z(e,t,n){e.insertBefore(t,n||null)}function q(e){e.parentNode&&e.parentNode.removeChild(e)}function re(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function f(e){return document.createElement(e)}function J(e){return document.createTextNode(e)}function _(){return J(" ")}function E(e,t,n,s){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n,s)}function u(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function gt(e){return Array.from(e.childNodes)}function Q(e,t){t=""+t,e.data!==t&&(e.data=t)}function R(e,t){e.value=t??""}let Oe;function ce(e){Oe=e}const X=[],He=[];let Y=[];const Qe=[],mt=Promise.resolve();let xe=!1;function bt(){xe||(xe=!0,mt.then(ut))}function Ee(e){Y.push(e)}const Ae=new Set;let G=0;function ut(){if(G!==0)return;const e=Oe;do{try{for(;G<X.length;){const t=X[G];G++,ce(t),vt(t.$$)}}catch(t){throw X.length=0,G=0,t}for(ce(null),X.length=0,G=0;He.length;)He.pop()();for(let t=0;t<Y.length;t+=1){const n=Y[t];Ae.has(n)||(Ae.add(n),n())}Y.length=0}while(X.length);for(;Qe.length;)Qe.pop()();xe=!1,Ae.clear(),ce(e)}function vt(e){if(e.fragment!==null){e.update(),ie(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(Ee)}}function yt(e){const t=[],n=[];Y.forEach(s=>e.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),Y=t}const kt=new Set;function $t(e,t){e&&e.i&&(kt.delete(e),e.i(t))}function I(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function wt(e,t,n){const{fragment:s,after_update:a}=e.$$;s&&s.m(t,n),Ee(()=>{const l=e.$$.on_mount.map(ct).filter(it);e.$$.on_destroy?e.$$.on_destroy.push(...l):ie(l),e.$$.on_mount=[]}),a.forEach(Ee)}function Ct(e,t){const n=e.$$;n.fragment!==null&&(yt(n.after_update),ie(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function At(e,t){e.$$.dirty[0]===-1&&(X.push(e),bt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function xt(e,t,n,s,a,l,h=null,d=[-1]){const p=Oe;ce(e);const r=e.$$={fragment:null,ctx:[],props:l,update:N,not_equal:a,bound:Ge(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(p?p.$$.context:[])),callbacks:Ge(),dirty:d,skip_bound:!1,root:t.target||p.$$.root};h&&h(r.root);let b=!1;if(r.ctx=n?n(e,t.props||{},(g,L,...v)=>{const O=v.length?v[0]:L;return r.ctx&&a(r.ctx[g],r.ctx[g]=O)&&(!r.skip_bound&&r.bound[g]&&r.bound[g](O),b&&At(e,g)),L}):[],r.update(),b=!0,ie(r.before_update),r.fragment=s?s(r.ctx):!1,t.target){if(t.hydrate){const g=gt(t.target);r.fragment&&r.fragment.l(g),g.forEach(q)}else r.fragment&&r.fragment.c();t.intro&&$t(e.$$.fragment),wt(e,t.target,t.anchor),ut()}ce(p)}class Et{constructor(){Ce(this,"$$");Ce(this,"$$set")}$destroy(){Ct(this,1),this.$destroy=N}$on(t,n){if(!it(n))return N;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(n),()=>{const a=s.indexOf(n);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!ht(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Ot="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ot);const H=[];function St(e,t=N){let n;const s=new Set;function a(d){if(at(e,d)&&(e=d,n)){const p=!H.length;for(const r of s)r[1](),H.push(r,e);if(p){for(let r=0;r<H.length;r+=2)H[r][0](H[r+1]);H.length=0}}}function l(d){a(d(e))}function h(d,p=N){const r=[d,p];return s.add(r),s.size===1&&(n=t(a,l)||N),d(e),()=>{s.delete(r),s.size===0&&n&&(n(),n=null)}}return{set:a,update:l,subscribe:h}}const D={weapons:[{id:"dagger_(atk)",cost:2,desc:`Attack from close range.
Attack from long range with disadvantage.`},{id:"longsword_(atk)",cost:1,desc:"Attack from close range."},{id:"bow_(atk)",cost:1,desc:"Attack from long range."}],armour:[{id:"leather_armour_(def)",cost:1,desc:"+1 def when worn"},{id:"iron_armour_(def)",cost:2,desc:"Advantage on defense when worn"}],items:[{id:"torch",cost:1,desc:"Emits light when lit. Comes with a matchbox to light the torch"},{id:"notebook",cost:1,desc:"Allows you to take notes. Comes with a quill and small bottle of ink"}],spells:[{id:"fireball_(arc)",cost:1,desc:"Attack from long range."},{id:"cooling_grasp_(arc)",cost:1,desc:"Attack from short range."},{id:"eldritch_binding_(arc)",cost:1,desc:"Freeze a creature in place. Their next defense roll is with disadvantage"},{id:"poison_bolt_(arc)",cost:1,desc:`Attack from close range with advantage.
Attack from long range.`},{id:"light",cost:1,desc:"Emit light for a short period"},{id:"voicebox",cost:1,desc:"Makes your voice really loud"},{id:"teleport",cost:3,desc:"Teleport a short range."}]},Nt=()=>{const e={name:"",points:9,atk:0,def:0,arc:0,purchases:[]},{subscribe:t,set:n,update:s}=St(JSON.parse(localStorage.getItem("char"))??e);let a;return t(l=>{a=l,localStorage.setItem("char",JSON.stringify(l))}),{subscribe:t,setName:l=>{l&&s(h=>({...h,name:l}))},incAtk:()=>{s(l=>l.points<=0||l.atk>=2?l:{...l,atk:l.atk+1,points:l.points-1})},decAtk:()=>{s(l=>l.atk<=-1?l:{...l,atk:l.atk-1,points:l.points+1})},incDef:()=>{s(l=>l.points<=0||l.def>=2?l:{...l,def:l.def+1,points:l.points-1})},decDef:()=>{s(l=>l.def<=-1?l:{...l,def:l.def-1,points:l.points+1})},incArc:()=>{s(l=>l.points<=0||l.arc>=2?l:{...l,arc:l.arc+1,points:l.points-1})},decArc:()=>{s(l=>l.arc<=-1?l:{...l,arc:l.arc-1,points:l.points+1})},buy:(l,h)=>{const d=D[l].find(p=>p.id===h);s(p=>p.points<d.cost?p:{...p,points:p.points-d.cost,purchases:[...p.purchases,d]})},refund:l=>{s(h=>({...h,points:h.points+h.purchases[l].cost,purchases:[...h.purchases.filter((d,p)=>p!==l)]}))},importChar(l){try{s(h=>JSON.parse(l))}catch{alert("An error occoured when importing your sheet!")}},exportChar(){const l=JSON.stringify(a);navigator.clipboard.writeText(l).then(()=>{alert("copied char sheet to clipboard")},()=>{alert("could not copy to clipboard. here is the export"),alert(l)})},reset(){confirm("Are you sure you would like to reset the character?")&&n(e)}}},S=Nt();function Xe(e,t,n){const s=e.slice();return s[11]=t[n],s[13]=n,s}function Ye(e,t,n){const s=e.slice();return s[14]=t[n],s}function Ze(e,t,n){const s=e.slice();return s[17]=t[n],s}function et(e,t,n){const s=e.slice();return s[20]=t[n],s}function tt(e,t,n){const s=e.slice();return s[23]=t[n],s}function nt(e){let t;return{c(){t=f("option"),t.textContent=`${e[3](e[23].id)} (${e[23].cost})
`,t.__value="weapons/"+e[23].id,R(t,t.__value),u(t,"class","svelte-420yh1")},m(n,s){z(n,t,s)},p:N,d(n){n&&q(t)}}}function lt(e){let t;return{c(){t=f("option"),t.textContent=`${e[3](e[20].id)} (${e[20].cost})
`,t.__value="armour/"+e[20].id,R(t,t.__value),u(t,"class","svelte-420yh1")},m(n,s){z(n,t,s)},p:N,d(n){n&&q(t)}}}function ot(e){let t;return{c(){t=f("option"),t.textContent=`${e[3](e[17].id)} (${e[17].cost})
`,t.__value="items/"+e[17].id,R(t,t.__value),u(t,"class","svelte-420yh1")},m(n,s){z(n,t,s)},p:N,d(n){n&&q(t)}}}function st(e){let t;return{c(){t=f("option"),t.textContent=`${e[3](e[14].id)} (${e[14].cost})
`,t.__value="spells/"+e[14].id,R(t,t.__value),u(t,"class","svelte-420yh1")},m(n,s){z(n,t,s)},p:N,d(n){n&&q(t)}}}function rt(e){let t,n=e[3](e[11].id)+"",s,a,l,h,d;function p(){return e[8](e[13])}return{c(){t=f("div"),s=J(n),a=_(),l=f("button"),l.textContent="Remove",u(t,"class","svelte-420yh1"),u(l,"class","span-3 svelte-420yh1")},m(r,b){z(r,t,b),i(t,s),z(r,a,b),z(r,l,b),h||(d=E(l,"click",p),h=!0)},p(r,b){e=r,b&4&&n!==(n=e[3](e[11].id)+"")&&Q(s,n)},d(r){r&&(q(t),q(a),q(l)),h=!1,d()}}}function Dt(e){let t,n,s,a,l,h,d,p,r,b,g,L,v,O,ae=e[2].points+"",be,Se,Ne,F,ue,De,fe,Ie,de=e[2].atk+"",ve,Le,Z,Pe,ee,Te,he,je,pe=e[2].def+"",ye,qe,te,Be,ne,Je,_e,Re,ge=e[2].arc+"",ke,ze,le,Fe,oe,Me,y,B,P,T,j,Ke,se,Ue,me,$e,Ve,we,We,M=I(D.weapons),k=[];for(let c=0;c<M.length;c+=1)k[c]=nt(tt(e,M,c));let K=I(D.armour),$=[];for(let c=0;c<K.length;c+=1)$[c]=lt(et(e,K,c));let U=I(D.items),w=[];for(let c=0;c<U.length;c+=1)w[c]=ot(Ze(e,U,c));let V=I(D.spells),C=[];for(let c=0;c<V.length;c+=1)C[c]=st(Ye(e,V,c));let W=I(e[2].purchases),A=[];for(let c=0;c<W.length;c+=1)A[c]=rt(Xe(e,W,c));return{c(){t=f("main"),n=f("div"),s=f("button"),s.textContent="Import",a=_(),l=f("button"),l.textContent="Export",h=_(),d=f("button"),d.textContent="Reset",p=_(),r=f("form"),b=f("div"),g=f("input"),v=_(),O=f("div"),be=J(ae),Se=J("/9"),Ne=_(),F=f("meter"),De=_(),fe=f("div"),fe.textContent="Attack (ATK)",Ie=_(),ve=J(de),Le=_(),Z=f("button"),Z.textContent="+",Pe=_(),ee=f("button"),ee.textContent="-",Te=_(),he=f("div"),he.textContent="Defense (DEF)",je=_(),ye=J(pe),qe=_(),te=f("button"),te.textContent="+",Be=_(),ne=f("button"),ne.textContent="-",Je=_(),_e=f("div"),_e.textContent="Arcana (ARC)",Re=_(),ke=J(ge),ze=_(),le=f("button"),le.textContent="+",Fe=_(),oe=f("button"),oe.textContent="-",Me=_(),y=f("select"),B=f("option"),B.textContent="-- Weapons --";for(let c=0;c<k.length;c+=1)k[c].c();P=f("option"),P.textContent="-- Armour --";for(let c=0;c<$.length;c+=1)$[c].c();T=f("option"),T.textContent="-- Items --";for(let c=0;c<w.length;c+=1)w[c].c();j=f("option"),j.textContent="-- Spells --";for(let c=0;c<C.length;c+=1)C[c].c();Ke=_(),se=f("button"),se.textContent="Add",Ue=_(),me=f("div"),$e=J(e[1]),Ve=_();for(let c=0;c<A.length;c+=1)A[c].c();u(s,"class","svelte-420yh1"),u(l,"class","svelte-420yh1"),u(d,"class","svelte-420yh1"),u(n,"class","svelte-420yh1"),u(g,"type","text"),u(g,"placeholder","Name"),g.value=L=e[2].name,u(g,"class","svelte-420yh1"),u(O,"class","svelte-420yh1"),F.value=ue=e[2].points,u(F,"min",0),u(F,"max",9),u(F,"class","svelte-420yh1"),u(b,"class","header svelte-420yh1"),u(fe,"class","svelte-420yh1"),u(Z,"class","svelte-420yh1"),u(ee,"class","svelte-420yh1"),u(he,"class","svelte-420yh1"),u(te,"class","svelte-420yh1"),u(ne,"class","svelte-420yh1"),u(_e,"class","svelte-420yh1"),u(le,"class","svelte-420yh1"),u(oe,"class","svelte-420yh1"),B.__value="",R(B,B.__value),B.disabled=!0,u(B,"class","svelte-420yh1"),P.__value="",R(P,P.__value),P.disabled=!0,u(P,"class","svelte-420yh1"),T.__value="",R(T,T.__value),T.disabled=!0,u(T,"class","svelte-420yh1"),j.__value="",R(j,j.__value),j.disabled=!0,u(j,"class","svelte-420yh1"),u(y,"class","span-2 svelte-420yh1"),u(se,"class","span-2 svelte-420yh1"),u(me,"class","span-4 svelte-420yh1"),u(r,"class","svelte-420yh1"),u(t,"class","svelte-420yh1")},m(c,m){z(c,t,m),i(t,n),i(n,s),i(n,a),i(n,l),i(n,h),i(n,d),i(t,p),i(t,r),i(r,b),i(b,g),i(b,v),i(b,O),i(O,be),i(O,Se),i(b,Ne),i(b,F),i(r,De),i(r,fe),i(r,Ie),i(r,ve),i(r,Le),i(r,Z),i(r,Pe),i(r,ee),i(r,Te),i(r,he),i(r,je),i(r,ye),i(r,qe),i(r,te),i(r,Be),i(r,ne),i(r,Je),i(r,_e),i(r,Re),i(r,ke),i(r,ze),i(r,le),i(r,Fe),i(r,oe),i(r,Me),i(r,y),i(y,B);for(let o=0;o<k.length;o+=1)k[o]&&k[o].m(y,null);i(y,P);for(let o=0;o<$.length;o+=1)$[o]&&$[o].m(y,null);i(y,T);for(let o=0;o<w.length;o+=1)w[o]&&w[o].m(y,null);i(y,j);for(let o=0;o<C.length;o+=1)C[o]&&C[o].m(y,null);i(r,Ke),i(r,se),i(r,Ue),i(r,me),i(me,$e),i(r,Ve);for(let o=0;o<A.length;o+=1)A[o]&&A[o].m(r,null);we||(We=[E(s,"click",e[5]),E(l,"click",S.exportChar),E(d,"click",S.reset),E(g,"change",e[6]),E(Z,"click",S.incAtk),E(ee,"click",S.decAtk),E(te,"click",S.incDef),E(ne,"click",S.decDef),E(le,"click",S.incArc),E(oe,"click",S.decArc),E(y,"input",e[4]),E(se,"click",e[7]),E(r,"submit",It)],we=!0)},p(c,[m]){if(m&4&&L!==(L=c[2].name)&&g.value!==L&&(g.value=L),m&4&&ae!==(ae=c[2].points+"")&&Q(be,ae),m&4&&ue!==(ue=c[2].points)&&(F.value=ue),m&4&&de!==(de=c[2].atk+"")&&Q(ve,de),m&4&&pe!==(pe=c[2].def+"")&&Q(ye,pe),m&4&&ge!==(ge=c[2].arc+"")&&Q(ke,ge),m&8){M=I(D.weapons);let o;for(o=0;o<M.length;o+=1){const x=tt(c,M,o);k[o]?k[o].p(x,m):(k[o]=nt(x),k[o].c(),k[o].m(y,P))}for(;o<k.length;o+=1)k[o].d(1);k.length=M.length}if(m&8){K=I(D.armour);let o;for(o=0;o<K.length;o+=1){const x=et(c,K,o);$[o]?$[o].p(x,m):($[o]=lt(x),$[o].c(),$[o].m(y,T))}for(;o<$.length;o+=1)$[o].d(1);$.length=K.length}if(m&8){U=I(D.items);let o;for(o=0;o<U.length;o+=1){const x=Ze(c,U,o);w[o]?w[o].p(x,m):(w[o]=ot(x),w[o].c(),w[o].m(y,j))}for(;o<w.length;o+=1)w[o].d(1);w.length=U.length}if(m&8){V=I(D.spells);let o;for(o=0;o<V.length;o+=1){const x=Ye(c,V,o);C[o]?C[o].p(x,m):(C[o]=st(x),C[o].c(),C[o].m(y,null))}for(;o<C.length;o+=1)C[o].d(1);C.length=V.length}if(m&2&&Q($e,c[1]),m&12){W=I(c[2].purchases);let o;for(o=0;o<W.length;o+=1){const x=Xe(c,W,o);A[o]?A[o].p(x,m):(A[o]=rt(x),A[o].c(),A[o].m(r,null))}for(;o<A.length;o+=1)A[o].d(1);A.length=W.length}},i:N,o:N,d(c){c&&q(t),re(k,c),re($,c),re(w,c),re(C,c),re(A,c),we=!1,ie(We)}}}const It=e=>{e.preventDefault()};function Lt(e,t,n){let s;_t(e,S,v=>n(2,s=v));const a=v=>v.replace(/\w\S*/g,O=>(O.charAt(0).toUpperCase()+O.substring(1).toLowerCase()).replaceAll("_"," ")),l=v=>D[v[0]].find(O=>O.id===v[1]),h=v=>{n(0,d=v.target.value.split("/")),n(1,p=l(d).desc)};let d=["weapons","dagger_(atk)"],p=D.weapons[0].desc;return[d,p,s,a,h,()=>{S.importChar(prompt("Char:"))},v=>{S.setName(v.target.value)},()=>{S.buy(...d)},v=>{S.refund(v)}]}class Pt extends Et{constructor(t){super(),xt(this,t,Lt,Dt,at,{})}}new Pt({target:document.getElementById("app")});
</script>
<style rel="stylesheet" crossorigin>:root{--accent:#dd1b99;--dark:#1c1d21;--light:#ffffff}*{margin:0;padding:0;box-sizing:border-box;font:inherit;font-family:sans-serif;-webkit-appearance:none;-moz-appearance:none;appearance:none}.svelte-420yh1{color:var(--light)}main.svelte-420yh1{width:100dvw;height:100dvh;background-color:var(--dark);display:flex;justify-content:start;align-items:center;flex-direction:column;padding:10px}main.svelte-420yh1>div{width:25ch;display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr;gap:5px;margin-bottom:5px}form.svelte-420yh1{display:grid;grid-template-columns:1fr 2cap 2cap 2cap;width:25ch;height:fit-content;gap:4px}.header.svelte-420yh1{grid-column:span 4;display:flex;flex-direction:row;gap:5px}.header.svelte-420yh1 *{display:inline}.header.svelte-420yh1 input{width:100%}.header.svelte-420yh1 div{margin-block:auto;width:max-content}.header.svelte-420yh1 meter{width:3.5cap}.span-2.svelte-420yh1{grid-column:span 2}.span-3.svelte-420yh1{grid-column:span 3}.span-4.svelte-420yh1{grid-column:span 4}input.svelte-420yh1,button.svelte-420yh1,meter.svelte-420yh1,select.svelte-420yh1{border:none;--background:hsl(from var(--dark) h s calc(l*1.75) / alpha);background:var(--background)}input.svelte-420yh1{border-bottom:2px solid var(--accent)}input.svelte-420yh1:focus-visible{outline:1px solid var(--accent)}button.svelte-420yh1,select.svelte-420yh1,input.svelte-420yh1{height:26px;margin-block:auto}meter.svelte-420yh1{display:block;width:100%;height:16px;margin-block:auto}meter.svelte-420yh1::-webkit-meter-bar{background:var(--background)}meter.svelte-420yh1::-webkit-meter-optimum-value{background:var(--accent)}meter.svelte-420yh1:-moz-meter-optimum::-moz-meter-bar{background:var(--accent)}
</style>
</head>
<body>
<div id="app"></div>
</body>
</html>