1
0
Fork 0

Local Build Deployment

This commit is contained in:
iTNTPiston 2022-06-20 22:56:03 -07:00
parent 367a08b2c2
commit c1e23b5940
43 changed files with 378 additions and 370 deletions

View file

@ -1,16 +1,41 @@
{ {
"files": { "files": {
"main.css": "/static/css/main.7948f1f9.css", "main.css": "/static/css/main.820e0273.css",
"main.js": "/static/js/main.6564ce4b.js", "main.js": "/static/js/main.96892c8b.js",
"static/js/787.ada1a5f8.chunk.js": "/static/js/787.ada1a5f8.chunk.js", "static/js/787.ada1a5f8.chunk.js": "/static/js/787.ada1a5f8.chunk.js",
"static/media/PotLid.png": "/static/media/PotLid.baf78a40199753b3af39.png",
"static/media/Calamity-Regular.otf": "/static/media/Calamity-Regular.cbeefc650e6ac39335b6.otf", "static/media/Calamity-Regular.otf": "/static/media/Calamity-Regular.cbeefc650e6ac39335b6.otf",
"static/media/SpiritOrb.png": "/static/media/SpiritOrb.66f25f8bbb0f27f0f568.png",
"static/media/AncientArrow.png": "/static/media/AncientArrow.9a1a41d05b09babd770d.png",
"static/media/IceArrow.png": "/static/media/IceArrow.c227e7fda67cfc094e27.png",
"static/media/FaroshHorn.png": "/static/media/FaroshHorn.ea7e3cbc262af3c30e1d.png",
"static/media/Rushroom.png": "/static/media/Rushroom.ab3824a1f76fa5347021.png",
"static/media/SpeedFood.png": "/static/media/SpeedFood.1bde9cae9ffc0c3906ea.png",
"static/media/HeartyBass.png": "/static/media/HeartyBass.4e0f8e06034479e163fe.png",
"static/media/SilentPrincess.png": "/static/media/SilentPrincess.6b9283141fbc5993b481.png",
"static/media/FaroshScale.png": "/static/media/FaroshScale.cc674ca9ac3cb63f99a3.png",
"static/media/Honey.png": "/static/media/Honey.dbf6fd6eae2e33fc3d6c.png",
"static/media/Tail.png": "/static/media/Tail.a43cfa310e2c86532247.png",
"static/media/Wood.png": "/static/media/Wood.8105d493814e4ecd145f.png",
"static/media/Diamond.png": "/static/media/Diamond.df6931b37a1f47165e37.png",
"static/media/NormalArrow.png": "/static/media/NormalArrow.1c54890bf60a08914a20.png",
"static/media/BombArrow.png": "/static/media/BombArrow.6b5994846aa06c8a8e92.png",
"static/media/Opal.png": "/static/media/Opal.2e20b71d79a80f905a80.png",
"static/media/Spring.png": "/static/media/Spring.bb7dcfa111b7b56ab25a.png",
"static/media/ShockArrow.png": "/static/media/ShockArrow.823f535857deb6e461ab.png",
"static/media/Shaft.png": "/static/media/Shaft.328e8aa17c1e5f9f0058.png",
"static/media/ForestDwellerBow.png": "/static/media/ForestDwellerBow.d2a6ab2d3f59bcc67b4b.png",
"static/media/FaroshClaw.png": "/static/media/FaroshClaw.4da7a445c986e0279916.png",
"static/media/HyruleBass.png": "/static/media/HyruleBass.82ea677144fd38b4665a.png",
"static/media/FireArrow.png": "/static/media/FireArrow.103898dc3f492d3293bd.png",
"static/media/Lotus.png": "/static/media/Lotus.6006e27a51c66a0b9d3b.png",
"index.html": "/index.html", "index.html": "/index.html",
"main.7948f1f9.css.map": "/static/css/main.7948f1f9.css.map", "main.820e0273.css.map": "/static/css/main.820e0273.css.map",
"main.6564ce4b.js.map": "/static/js/main.6564ce4b.js.map", "main.96892c8b.js.map": "/static/js/main.96892c8b.js.map",
"787.ada1a5f8.chunk.js.map": "/static/js/787.ada1a5f8.chunk.js.map" "787.ada1a5f8.chunk.js.map": "/static/js/787.ada1a5f8.chunk.js.map"
}, },
"entrypoints": [ "entrypoints": [
"static/css/main.7948f1f9.css", "static/css/main.820e0273.css",
"static/js/main.6564ce4b.js" "static/js/main.96892c8b.js"
] ]
} }

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="for Breath of the Wild"/><meta property="og:site_name" content="itntpiston.app"/><meta property="og:title" content="Hundo Duplication Simulator"><meta property="og:type" content="website"><meta property="og:url" content="https://dupl.itntpiston.app/#/"><meta property="og:description" content="for Breath of the Wild"><link rel="manifest" href="/manifest.json"/><title>Hundo Duplication Simulator</title><script defer="defer" src="/static/js/main.6564ce4b.js"></script><link href="/static/css/main.7948f1f9.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="for Breath of the Wild"/><meta property="og:site_name" content="itntpiston.app"/><meta property="og:title" content="Hundo Duplication Simulator"><meta property="og:type" content="website"><meta property="og:url" content="https://dupl.itntpiston.app/#/"><meta property="og:description" content="for Breath of the Wild"><link rel="manifest" href="/manifest.json"/><title>Hundo Duplication Simulator</title><script defer="defer" src="/static/js/main.96892c8b.js"></script><link href="/static/css/main.820e0273.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

View file

@ -1,2 +0,0 @@
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}h1{margin:0}@font-face{font-family:CalamitySans;src:url(/static/media/Calamity-Regular.cbeefc650e6ac39335b6.otf) format("opentype")}.Calamity{font-family:CalamitySans}.CommandItemSelected{background-color:#eee}.CommandItemContextSelected{background-color:#eaa}.CommandItemError{color:red}.CommandItem{cursor:pointer;padding:2px 2px 2px 10px}.CommandItem:hover{border:1px solid #000}.InputError{background-color:#eaa}
/*# sourceMappingURL=main.7948f1f9.css.map*/

View file

@ -1 +0,0 @@
{"version":3,"file":"static/css/main.7948f1f9.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF,CCZA,GACE,QACF,CAEA,WACE,wBAAyB,CACzB,mFACF,CAEA,UACE,wBACF,CAEA,qBACE,qBACF,CAEA,4BACE,qBACF,CAEA,kBACE,SACF,CAEA,aAEE,cAAe,CADf,wBAEF,CAEA,mBACE,qBACF,CAEA,YACE,qBACF","sources":["index.css","App.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n","h1 {\n margin: 0\n}\n\n@font-face {\n font-family: CalamitySans;\n src: url(\"assets/Calamity-Regular.otf\") format(\"opentype\");\n}\n\n.Calamity {\n font-family: CalamitySans;\n}\n\n.CommandItemSelected {\n background-color: #eeeeee;\n}\n\n.CommandItemContextSelected {\n background-color: #eeaaaa;\n}\n\n.CommandItemError{\n color: red;\n}\n\n.CommandItem {\n padding: 2px 2px 2px 10px;\n cursor: pointer;\n}\n\n.CommandItem:hover {\n border: 1px solid black\n}\n\n.InputError {\n background-color: #eeaaaa;\n}\n"],"names":[],"sourceRoot":""}

2
docs/static/css/main.820e0273.css vendored Normal file
View file

@ -0,0 +1,2 @@
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}h1{margin:0}@font-face{font-family:CalamitySans;src:url(/static/media/Calamity-Regular.cbeefc650e6ac39335b6.otf) format("opentype")}.Calamity{font-family:CalamitySans}.CommandItemSelected{background-color:#eee}.CommandItemContextSelected{background-color:#eaa}.CommandItemComment{color:green;font-size:10pt}.CommandItem{cursor:pointer;padding:2px 2px 2px 10px}.CommandItem:hover{background-color:#eee}.InputError{background-color:#eaa}.ItemSlot{background-color:#333;box-sizing:content-box;display:inline-block;height:64px;margin:4px;width:64px}.ItemSlotBroken{background-color:#600}.ItemSlotSave{background-color:#030}.ItemSlotEquipped{background-color:#08f}.ItemImage{border:1px solid #999;box-sizing:border-box;display:inline-block;height:62px;margin:1px;width:62px}.ItemCount{color:#eee;float:left;font-size:10pt;left:8px;position:relative;top:-22px}
/*# sourceMappingURL=main.820e0273.css.map*/

1
docs/static/css/main.820e0273.css.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"static/css/main.820e0273.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF,CCZA,GACE,QACF,CAEA,WACE,wBAAyB,CACzB,mFACF,CAEA,UACE,wBACF,CAEA,qBACE,qBACF,CAEA,4BACE,qBACF,CAEA,oBACE,WAAY,CACZ,cACF,CAEA,aAEE,cAAe,CADf,wBAEF,CAEA,mBACE,qBACF,CAEA,YACE,qBACF,CAEA,UAKE,qBAAyB,CACzB,sBAAuB,CACvB,oBAAqB,CAJrB,WAAY,CAFZ,UAAW,CACX,UAMF,CAEA,gBACE,qBACF,CAEA,cACE,qBACF,CAEA,kBACE,qBACF,CAEA,WACE,qBAAyB,CACzB,qBAAsB,CAItB,oBAAoB,CADpB,WAAW,CAFX,UAAU,CACV,UAGF,CAKA,WAKE,UAAa,CACb,UAAW,CALX,cAAe,CAGf,QAAQ,CAFR,iBAAiB,CACjB,SAIF","sources":["index.css","App.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n","h1 {\n margin: 0\n}\n\n@font-face {\n font-family: CalamitySans;\n src: url(\"assets/Calamity-Regular.otf\") format(\"opentype\");\n}\n\n.Calamity {\n font-family: CalamitySans;\n}\n\n.CommandItemSelected {\n background-color: #eeeeee;\n}\n\n.CommandItemContextSelected {\n background-color: #eeaaaa;\n}\n\n.CommandItemComment{\n color: green;\n font-size: 10pt;\n}\n\n.CommandItem {\n padding: 2px 2px 2px 10px;\n cursor: pointer;\n}\n\n.CommandItem:hover {\n background-color: #eeeeee;\n}\n\n.InputError {\n background-color: #eeaaaa;\n}\n\n.ItemSlot {\n margin: 4px;\n width: 64px;\n height: 64px;\n \n background-color: #333333;\n box-sizing: content-box;\n display: inline-block;\n}\n\n.ItemSlotBroken {\n background-color: #660000;\n}\n\n.ItemSlotSave {\n background-color: #003300;\n}\n\n.ItemSlotEquipped {\n background-color: #0088ff;\n}\n\n.ItemImage {\n border: 1px solid #999999;\n box-sizing: border-box;\n margin:1px;\n width:62px;\n height:62px;\n display:inline-block;\n}\n\n.ItemImageSave {\n}\n\n.ItemCount {\n font-size: 10pt;\n position:relative;\n top:-22px;\n left:8px;\n color:#eeeeee;\n float: left;\n}\n"],"names":[],"sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
docs/static/js/main.96892c8b.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,3 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
/** /**
* @license React * @license React
* react-dom.production.min.js * react-dom.production.min.js

1
docs/static/js/main.96892c8b.js.map vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -95,9 +95,7 @@ export const App: React.FC = () => {
setContextMenuY(contextMenuY-rect.height); setContextMenuY(contextMenuY-rect.height);
} }
} }
}, [contextMenuRef, contextMenuShowing]) }, [contextMenuRef, contextMenuShowing]);
return ( return (
<div className='Calamity' <div className='Calamity'
@ -173,7 +171,7 @@ export const App: React.FC = () => {
</div> </div>
{displayIndex >= 0 && displayIndex < commands.length && {displayIndex >= 0 && displayIndex < commands.length &&
<DisplayPane <DisplayPane
overlaySave={overlaySave} overlaySave={overlaySave}
displayIndex={displayIndex} displayIndex={displayIndex}
command={commands[displayIndex].getDisplayString()} command={commands[displayIndex].getDisplayString()}
orbs={inventories[displayIndex].getTurnedInOrbs()} orbs={inventories[displayIndex].getTurnedInOrbs()}
@ -217,51 +215,50 @@ export const App: React.FC = () => {
paddingInlineStart: 0 paddingInlineStart: 0
}}> }}>
{contextIndex >= 0 ? <> {contextIndex >= 0 ? <>
<CommandItem onClick={()=>{ <CommandItem onClick={()=>{
const arrCopy = [...commands];
arrCopy.splice(contextIndex, 0, new CommandNothing());
setCommands(arrCopy);
setContextMenuShowing(false);
setContextIndex(-1);
}}>Insert Above</CommandItem>
<CommandItem onClick={()=>{
if(contextIndex > 0){
const arrCopy = [...commands]; const arrCopy = [...commands];
const temp = arrCopy[contextIndex]; arrCopy.splice(contextIndex, 0, new CommandNothing());
arrCopy[contextIndex] = arrCopy[contextIndex-1];
arrCopy[contextIndex-1] = temp;
setCommands(arrCopy); setCommands(arrCopy);
setContextMenuShowing(false);
setContextIndex(-1);
}
}}>Move Up</CommandItem>
<CommandItem onClick={()=>{
if(confirm("Delete?")){
setCommands(commands.filter((_,i)=>i!==contextIndex));
if(displayIndex >= commands.length){
setDisplayIndex(commands.length-1);
}
setContextMenuShowing(false); setContextMenuShowing(false);
setContextIndex(-1); setContextIndex(-1);
} }}>Insert Above</CommandItem>
}}>Delete</CommandItem></> : <CommandItem onClick={()=>{
<> if(contextIndex > 0){
<CommandItem onClick={()=>{ const arrCopy = [...commands];
setOverlaySave(!overlaySave); const temp = arrCopy[contextIndex];
}}>Toggle Save Overlay</CommandItem> arrCopy[contextIndex] = arrCopy[contextIndex-1];
<CommandItem onClick={()=>{ arrCopy[contextIndex-1] = temp;
if(uploadRef.current){ setCommands(arrCopy);
uploadRef.current.click(); setContextMenuShowing(false);
} setContextIndex(-1);
}}>Import</CommandItem> }
<CommandItem onClick={()=>{
const lines = commands.map(c=>c.getDisplayString()); }}>Move Up</CommandItem>
const text = lines.join("\n"); <CommandItem onClick={()=>{
saveAs(text, "dupe.txt"); if(confirm("Delete?")){
}}>Export</CommandItem> setCommands(commands.filter((_,i)=>i!==contextIndex));
<CommandItem onClick={()=>{ if(displayIndex >= commands.length){
setDisplayIndex(commands.length-1);
}
setContextMenuShowing(false);
setContextIndex(-1);
}
}}>Delete</CommandItem></> :
<>
<CommandItem onClick={()=>{
setOverlaySave(!overlaySave);
}}>Toggle Save Overlay</CommandItem>
<CommandItem onClick={()=>{
if(uploadRef.current){
uploadRef.current.click();
}
}}>Import</CommandItem>
<CommandItem onClick={()=>{
const lines = commands.map(c=>c.getDisplayString());
const text = lines.join("\n");
saveAs(text, "dupe.txt");
}}>Export</CommandItem>
<CommandItem onClick={()=>{
alert(`Available Commands: alert(`Available Commands:
Initialize X Item1 Y Item2 Z Item3 ... Initialize X Item1 Y Item2 Z Item3 ...
Break X Slots - add X broken slots Break X Slots - add X broken slots
@ -276,7 +273,7 @@ Limitations:
Inventory corruption is not implemented yet Inventory corruption is not implemented yet
`); `);
alert(`Available Items: alert(`Available Items:
Slate Slate
Glider Glider
SpiritOrb SpiritOrb
@ -299,9 +296,9 @@ Core
Wood Wood
Weapon Weapon
`); `);
}}>Reference</CommandItem> }}>Reference</CommandItem>
</> </>
} }

View file

@ -9,22 +9,22 @@ type ItemSlotProps = {
export const ItemSlot: React.FC<ItemSlotProps> = ({image, count, isBroken, isSave, isEquipped})=>{ export const ItemSlot: React.FC<ItemSlotProps> = ({image, count, isBroken, isSave, isEquipped})=>{
return ( return (
<span className={clsx("ItemSlot", isBroken && "ItemSlotBroken", isSave && "ItemSlotSave", isEquipped && "ItemSlotEquipped")}> <span className={clsx("ItemSlot", isBroken && "ItemSlotBroken", isSave && "ItemSlotSave", isEquipped && "ItemSlotEquipped")}>
<img className={clsx("ItemImage", isSave && "ItemImageSave")}src={image} /> <img className={clsx("ItemImage", isSave && "ItemImageSave")}src={image} />
{ {
count > 0 && <span className={"ItemCount"}> count > 0 && <span className={"ItemCount"}>
x{count} x{count}
</span> </span>
} }
</span> </span>
); );
}; };
export const DoubleItemSlot: React.FC<{first?: ItemSlotProps, second?: ItemSlotProps}> = ({first, second})=>{ export const DoubleItemSlot: React.FC<{first?: ItemSlotProps, second?: ItemSlotProps}> = ({first, second})=>{
return ( return (
<span style={{display: "inline-block", width: 72, height: 144, verticalAlign:"top"}}> <span style={{display: "inline-block", width: 72, height: 144, verticalAlign:"top"}}>
{first ? <ItemSlot {...first}/> : <div style={{height: 72}}/>} {first ? <ItemSlot {...first}/> : <div style={{height: 72}}/>}
{second ? <ItemSlot {...second}/> : <div style={{height: 72}}/> } {second ? <ItemSlot {...second}/> : <div style={{height: 72}}/> }
</span> </span>
) );
} };

View file

@ -1,7 +1,5 @@
import { Inventory } from "./Inventory"; import { Inventory } from "./Inventory";
import { idToItemData, Item, ItemStack, itemToArrowType, itemToItemData } from "./Item"; import { Item, ItemStack, itemToArrowType } from "./Item";
const Buffer = require("buffer/").Buffer; /* eslint-disable-line @typescript-eslint/no-var-requires*/
export interface Command { export interface Command {
execute(inv: Inventory): void, execute(inv: Inventory): void,
@ -199,7 +197,7 @@ export class CommandRemoveMaterial implements Command {
inv.remove(this.item, this.count, this.slot); inv.remove(this.item, this.count, this.slot);
} }
public getDisplayString(): string { public getDisplayString(): string {
const slotString = this.noSlot ? "" : ` From Slot ${this.slot+1}` const slotString = this.noSlot ? "" : ` From Slot ${this.slot+1}`;
return `${Verbs[this.verb]} ${this.count} ${this.item}${slotString}`; return `${Verbs[this.verb]} ${this.count} ${this.item}${slotString}`;
} }
} }
@ -220,7 +218,7 @@ export class CommandRemoveUnstackableMaterial implements Command {
inv.remove(this.item, 1, this.slot); inv.remove(this.item, 1, this.slot);
} }
public getDisplayString(): string { public getDisplayString(): string {
const slotString = this.noSlot ? "" : ` From Slot ${this.slot+1}` const slotString = this.noSlot ? "" : ` From Slot ${this.slot+1}`;
return `${Verbs[this.verb]} ${this.item}${slotString}`; return `${Verbs[this.verb]} ${this.item}${slotString}`;
} }
} }
@ -281,7 +279,7 @@ export class CommandEquipArrow implements Command {
inv.equipEquipmentOrArrow(this.item, this.slot); inv.equipEquipmentOrArrow(this.item, this.slot);
} }
public getDisplayString(): string { public getDisplayString(): string {
const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}` const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}`;
return `Equip ${itemToArrowType(this.item)} Arrow${slotString}`; return `Equip ${itemToArrowType(this.item)} Arrow${slotString}`;
} }
} }
@ -300,7 +298,7 @@ export class CommandEquip implements Command {
inv.equipEquipmentOrArrow(this.item, this.slot); inv.equipEquipmentOrArrow(this.item, this.slot);
} }
public getDisplayString(): string { public getDisplayString(): string {
const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}` const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}`;
return `Equip ${this.item}${slotString}`; return `Equip ${this.item}${slotString}`;
} }
} }
@ -319,7 +317,7 @@ export class CommandUnequip implements Command {
inv.unequipEquipment(this.item, this.slot); inv.unequipEquipment(this.item, this.slot);
} }
public getDisplayString(): string { public getDisplayString(): string {
const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}` const slotString = this.noSlot ? "" : ` In Slot ${this.slot+1}`;
return `Unequip ${this.item}${slotString}`; return `Unequip ${this.item}${slotString}`;
} }
} }
@ -334,7 +332,7 @@ export class CommandSetTag implements Command {
inv.setTag(this.name); inv.setTag(this.name);
} }
public getDisplayString(): string { public getDisplayString(): string {
return `Save As ${this.name}` return `Save As ${this.name}`;
} }
} }
@ -347,7 +345,7 @@ export class CommandApplyTag implements Command {
inv.applyTag(this.name); inv.applyTag(this.name);
} }
public getDisplayString(): string { public getDisplayString(): string {
return `Use ${this.name}` return `Use ${this.name}`;
} }
} }
@ -356,7 +354,7 @@ export class CommandCloseGame implements Command {
inv.closeGame(); inv.closeGame();
} }
public getDisplayString(): string { public getDisplayString(): string {
return `Close Game`; return "Close Game";
} }
} }
@ -365,8 +363,8 @@ export class CommandComment implements Command {
constructor(name: string){ constructor(name: string){
this.name = name; this.name = name;
} }
public execute(inv: Inventory): void { public execute(_inv: Inventory): void {
// nothing
} }
public getDisplayString(): string { public getDisplayString(): string {
return `# ${this.name}`; return `# ${this.name}`;

View file

@ -1,8 +1,6 @@
import { Item, ItemStack, itemToItemData, ItemType, ItemTypes } from "./Item"; import { Item, ItemStack, itemToItemData, ItemType, ItemTypes } from "./Item";
import { Slots } from "./Slots"; import { Slots } from "./Slots";
export class Inventory { export class Inventory {
private slots: Slots = new Slots([]); private slots: Slots = new Slots([]);
private savedSlots: Slots = new Slots([]); private savedSlots: Slots = new Slots([]);
@ -51,7 +49,7 @@ export class Inventory {
public init(stacks: ItemStack[]) { public init(stacks: ItemStack[]) {
this.slots = new Slots([]); this.slots = new Slots([]);
stacks.forEach(s=>{ stacks.forEach(s=>{
this.slots.add(s.item, s.count) this.slots.add(s.item, s.count);
}); });
this.numBroken = 0; this.numBroken = 0;
this.isInitialSort = false; this.isInitialSort = false;
@ -110,7 +108,7 @@ export class Inventory {
this.savedSlots.get(s).count = 999; this.savedSlots.get(s).count = 999;
} }
} }
}) });
} }
public reload() { public reload() {

View file

@ -44,14 +44,14 @@ export enum ItemType {
} }
export const ItemTypes = [ export const ItemTypes = [
ItemType.Weapon, ItemType.Weapon,
ItemType.Bow, ItemType.Bow,
ItemType.Arrow, ItemType.Arrow,
ItemType.Shield, ItemType.Shield,
ItemType.Material, ItemType.Material,
ItemType.Meal, ItemType.Meal,
ItemType.Key ItemType.Key
] ];
export type ItemStack = { export type ItemStack = {
item: Item, item: Item,
@ -131,14 +131,14 @@ const register = (id: number, item: Item, type: ItemType, image: string, options
repeatable: true, repeatable: true,
stackable: true, stackable: true,
sortOrder, sortOrder,
...(options||{}) ...options||{}
}; };
if(id in IdToData){ if(id in IdToData){
console.error("Multiple items registered to the same id: "+id+", ("+item+")"); console.error("Multiple items registered to the same id: "+id+", ("+item+")");
} }
IdToData[id] = data; IdToData[id] = data;
ItemToData[item] = data; ItemToData[item] = data;
} };
/* Do not change the ID once created. Otherwise you would break existing codes */ /* Do not change the ID once created. Otherwise you would break existing codes */
register(0x00, Item.Slate, ItemType.Key, ImageSlate, { register(0x00, Item.Slate, ItemType.Key, ImageSlate, {
repeatable: false, repeatable: false,
@ -201,4 +201,4 @@ export const itemToArrowType = (item: Item): string => {
return str.substring(0,str.length-5); return str.substring(0,str.length-5);
} }
return ""; return "";
} };

View file

@ -1,197 +1,197 @@
import { Item, ItemStack, itemToItemData, ItemType } from "./Item"; import { Item, ItemStack, itemToItemData, ItemType } from "./Item";
export class Slots { export class Slots {
private internalSlots: ItemStack[] = []; private internalSlots: ItemStack[] = [];
constructor(slots: ItemStack[]) { constructor(slots: ItemStack[]) {
this.internalSlots = slots; this.internalSlots = slots;
} }
public getSlotsRef(): ItemStack[] { public getSlotsRef(): ItemStack[] {
return this.internalSlots; return this.internalSlots;
} }
public deepClone(): Slots { public deepClone(): Slots {
return new Slots(this.internalSlots.map(s=>({...s}))); return new Slots(this.internalSlots.map(s=>({...s})));
} }
public get length(): number { public get length(): number {
return this.internalSlots.length; return this.internalSlots.length;
} }
public get(i: number): ItemStack{ public get(i: number): ItemStack{
return this.internalSlots[i]; return this.internalSlots[i];
} }
public getByType(type: ItemType): Slots { public getByType(type: ItemType): Slots {
return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type===type)); return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type===type));
} }
public getBeforeType(type: ItemType): Slots { public getBeforeType(type: ItemType): Slots {
return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type<type)); return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type<type));
} }
public getAfterType(type: ItemType): Slots { public getAfterType(type: ItemType): Slots {
return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type>type)); return new Slots(this.internalSlots.filter(s=>itemToItemData(s.item).type>type));
} }
public addSlotsToEnd(slots: Slots) { public addSlotsToEnd(slots: Slots) {
slots.internalSlots.forEach(s=>this.addStack(s)); slots.internalSlots.forEach(s=>this.addStack(s));
} }
public addStack(stack: ItemStack) { public addStack(stack: ItemStack) {
// Scan non-repeatables // Scan non-repeatables
const data = itemToItemData(stack.item); const data = itemToItemData(stack.item);
if(!data.repeatable){ if(!data.repeatable){
for(let i=0;i<this.internalSlots.length;i++){ for(let i=0;i<this.internalSlots.length;i++){
if(this.internalSlots[i].item===stack.item){ if(this.internalSlots[i].item===stack.item){
return; return;
} }
} }
} }
this.internalSlots.push(stack); this.internalSlots.push(stack);
} }
public addStackCopy(stack: ItemStack) { public addStackCopy(stack: ItemStack) {
this.addStack({...stack}); this.addStack({...stack});
} }
public sort() { public sort() {
this.internalSlots.sort((a,b)=>{ this.internalSlots.sort((a,b)=>{
return itemToItemData(a.item).sortOrder - itemToItemData(b.item).sortOrder; return itemToItemData(a.item).sortOrder - itemToItemData(b.item).sortOrder;
}); });
} }
public removeFromEnd(count: number): Slots { public removeFromEnd(count: number): Slots {
const end = this.internalSlots.splice(-count, count); const end = this.internalSlots.splice(-count, count);
return new Slots(end); return new Slots(end);
} }
public remove(item: Item, count: number, slot: number) { public remove(item: Item, count: number, slot: number) {
let s = 0; let s = 0;
for(let i = 0; i<this.internalSlots.length && count > 0;i++){ for(let i = 0; i<this.internalSlots.length && count > 0;i++){
if(this.internalSlots[i].item === item){ if(this.internalSlots[i].item === item){
if(s<slot){ if(s<slot){
s++; s++;
}else{ }else{
if(this.internalSlots[i].count<count){ if(this.internalSlots[i].count<count){
count-=this.internalSlots[i].count; count-=this.internalSlots[i].count;
this.internalSlots[i].count=0; this.internalSlots[i].count=0;
}else{ }else{
this.internalSlots[i].count-=count; this.internalSlots[i].count-=count;
break; break;
} }
} }
} }
} }
this.internalSlots = this.internalSlots.filter(({count})=>count>0); this.internalSlots = this.internalSlots.filter(({count})=>count>0);
} }
public add(item: Item, count: number) { public add(item: Item, count: number) {
let added = false; let added = false;
const data = itemToItemData(item); const data = itemToItemData(item);
if(data.stackable){ if(data.stackable){
for(let i = 0; i<this.internalSlots.length;i++){ for(let i = 0; i<this.internalSlots.length;i++){
if(this.internalSlots[i].item === item){ if(this.internalSlots[i].item === item){
this.internalSlots[i].count+=count; this.internalSlots[i].count+=count;
added = true; added = true;
break; break;
} }
} }
} }
if(!added){ if(!added){
const after = this.removeFromEnd(this.getAfterType(data.type).length); const after = this.removeFromEnd(this.getAfterType(data.type).length);
if(data.stackable){ if(data.stackable){
if(data.type===ItemType.Arrow){ if(data.type===ItemType.Arrow){
// if currently equipped arrow == 0. new arrows are equiped // if currently equipped arrow == 0. new arrows are equiped
const shouldEquipNew = this.internalSlots.filter(s=>{ const shouldEquipNew = this.internalSlots.filter(s=>{
const sData = itemToItemData(s.item); const sData = itemToItemData(s.item);
return sData.type === data.type && s.equipped && s.count > 0; return sData.type === data.type && s.equipped && s.count > 0;
}).length === 0; }).length === 0;
this.addStack({item,count,equipped:shouldEquipNew}); this.addStack({item,count,equipped:shouldEquipNew});
}else{ }else{
this.addStack({item,count,equipped:false}); this.addStack({item,count,equipped:false});
} }
}else{ }else{
if(data.type===ItemType.Weapon || data.type===ItemType.Bow || data.type===ItemType.Shield){ if(data.type===ItemType.Weapon || data.type===ItemType.Bow || data.type===ItemType.Shield){
//Check equip //Check equip
const shouldEquipNew = this.internalSlots.filter(s=>{ const shouldEquipNew = this.internalSlots.filter(s=>{
const sData = itemToItemData(s.item); const sData = itemToItemData(s.item);
return sData.type === data.type && s.equipped; return sData.type === data.type && s.equipped;
}).length === 0; }).length === 0;
this.addStack({item,count:1,equipped: shouldEquipNew}); this.addStack({item,count:1,equipped: shouldEquipNew});
for(let i=1;i<count;i++){ for(let i=1;i<count;i++){
this.addStack({item,count:1,equipped: false}); this.addStack({item,count:1,equipped: false});
} }
}else{ }else{
for(let i=0;i<count;i++){ for(let i=0;i<count;i++){
this.addStack({item,count:1,equipped: false}); this.addStack({item,count:1,equipped: false});
} }
} }
} }
this.addSlotsToEnd(after); this.addSlotsToEnd(after);
} }
} }
// this is for both equipments and arrows // this is for both equipments and arrows
public equip(item: Item, slot: number) { public equip(item: Item, slot: number) {
let s = 0; let s = 0;
const type = itemToItemData(item).type; const type = itemToItemData(item).type;
const filtered = this.internalSlots.filter(s=>itemToItemData(s.item).type === type); const filtered = this.internalSlots.filter(s=>itemToItemData(s.item).type === type);
for(let i = 0; i<filtered.length;i++){ for(let i = 0; i<filtered.length;i++){
filtered[i].equipped=false; filtered[i].equipped=false;
if(filtered[i].item === item){ if(filtered[i].item === item){
if (s===slot){ if (s===slot){
filtered[i].equipped=true; filtered[i].equipped=true;
} }
s++; s++;
} }
} }
} }
public unequip(item:Item, slot: number) { public unequip(item:Item, slot: number) {
let s = 0; let s = 0;
const type = itemToItemData(item).type; const type = itemToItemData(item).type;
if (type===ItemType.Arrow){ if (type===ItemType.Arrow){
return; // cannot unequip arrow return; // cannot unequip arrow
} }
for(let i = 0; i<this.internalSlots.length;i++){ for(let i = 0; i<this.internalSlots.length;i++){
if(this.internalSlots[i].item === item){ if(this.internalSlots[i].item === item){
if(slot < 0){ if(slot < 0){
if(this.internalSlots[i].equipped){ if(this.internalSlots[i].equipped){
this.internalSlots[i].equipped=false; this.internalSlots[i].equipped=false;
break; break;
} }
}else{ }else{
if(s<slot){ if(s<slot){
s++; s++;
}else{ }else{
this.internalSlots[i].equipped=false; this.internalSlots[i].equipped=false;
break; break;
} }
} }
} }
} }
} }
// Difference between shoot and remove: // Difference between shoot and remove:
// 1. can only be from first (leftmost) slot // 1. can only be from first (leftmost) slot
// 2. empty slots not removed // 2. empty slots not removed
public shoot(item: Item, count: number) { public shoot(item: Item, count: number) {
for(let i = 0; i<this.internalSlots.length;i++){ for(let i = 0; i<this.internalSlots.length;i++){
if(this.internalSlots[i].item === item){ if(this.internalSlots[i].item === item){
this.internalSlots[i].count-=count; this.internalSlots[i].count-=count;
} }
} }
} }
public sortArrows() { public sortArrows() {
const after = this.removeFromEnd(this.getAfterType(ItemType.Arrow).length); const after = this.removeFromEnd(this.getAfterType(ItemType.Arrow).length);
const arrows = this.removeFromEnd(this.getByType(ItemType.Arrow).length); const arrows = this.removeFromEnd(this.getByType(ItemType.Arrow).length);
arrows.sort(); arrows.sort();
this.addSlotsToEnd(arrows); this.addSlotsToEnd(arrows);
this.addSlotsToEnd(after); this.addSlotsToEnd(after);
} }
public getFirstEquippedSlotIndex(type: ItemType): number { public getFirstEquippedSlotIndex(type: ItemType): number {
for(let i = 0; i<this.internalSlots.length;i++){ for(let i = 0; i<this.internalSlots.length;i++){
if(this.internalSlots[i].equipped){ if(this.internalSlots[i].equipped){
const data = itemToItemData(this.internalSlots[i].item); const data = itemToItemData(this.internalSlots[i].item);
if(data.type === type){ if(data.type === type){
return i; return i;
} }
} }
} }
return -1; return -1;
} }
} }

View file

@ -34,7 +34,7 @@ const stacksToItemProps = (stacks: ItemStack[]): ItemListItemProps[] => {
const stackToItemProps = ({item, count, equipped}: ItemStack): ItemListItemProps => { const stackToItemProps = ({item, count, equipped}: ItemStack): ItemListItemProps => {
const data = itemToItemData(item); const data = itemToItemData(item);
return {image: data.image, count: data.stackable ? count : 0, isEquipped:equipped}; return {image: data.image, count: data.stackable ? count : 0, isEquipped:equipped};
} };
export const DisplayPane: React.FC<DisplayPaneProps> = ({command,orbs,editCommand,displayIndex, slots, savedSlots, numBroken, overlaySave})=>{ export const DisplayPane: React.FC<DisplayPaneProps> = ({command,orbs,editCommand,displayIndex, slots, savedSlots, numBroken, overlaySave})=>{
const [commandString, setCommandString] = useState<string>(""); const [commandString, setCommandString] = useState<string>("");
@ -79,72 +79,71 @@ export const DisplayPane: React.FC<DisplayPaneProps> = ({command,orbs,editComman
setHasError(true); setHasError(true);
} }
}}></input> }}></input>
<span> <span>
Orbs: {orbs} Orbs: {orbs}
</span> </span>
</div> </div>
{overlaySave ? {overlaySave ?
<div style={{ <div style={{
borderTop: "1px solid black", borderTop: "1px solid black",
boxSizing: "content-box", boxSizing: "content-box",
height: "calc( ( 99vh - 60px ))", height: "calc( ( 99vh - 60px ))",
overflowY: "auto" overflowY: "auto"
} }> } }>
<div>Save / Current</div> <div>Save / Current</div>
<div> <div>
{ {
(()=>{ (()=>{
const doubleSlots: JSX.Element[] = []; const doubleSlots: JSX.Element[] = [];
for(let i=0;i<savedSlots.length && i<slots.length;i++){ for(let i=0;i<savedSlots.length && i<slots.length;i++){
doubleSlots.push(<DoubleItemSlot key={i} doubleSlots.push(<DoubleItemSlot key={i}
first={{...stackToItemProps(savedSlots.get(i)), isBroken:false, isSave:true}} first={{...stackToItemProps(savedSlots.get(i)), isBroken:false, isSave:true}}
second={{...stackToItemProps(slots.get(i)), isBroken:i>=slots.length-numBroken, isSave:false}} second={{...stackToItemProps(slots.get(i)), isBroken:i>=slots.length-numBroken, isSave:false}}
/>); />);
}
if(savedSlots.length>slots.length){
for(let i=slots.length;i<savedSlots.length;i++){
doubleSlots.push(<DoubleItemSlot key={i+slots.length}
first={{...stackToItemProps(savedSlots.get(i)), isBroken:false, isSave:true}}
/>);
}
}else if(slots.length > savedSlots.length){
for(let i=savedSlots.length;i<slots.length;i++){
doubleSlots.push(<DoubleItemSlot key={i + savedSlots.length}
second={{...stackToItemProps(slots.get(i)), isBroken:i>=slots.length-numBroken, isSave:false}}
/>);
}
}
return doubleSlots;
})()
} }
if(savedSlots.length>slots.length){ </div>
for(let i=slots.length;i<savedSlots.length;i++){
doubleSlots.push(<DoubleItemSlot key={i+slots.length}
first={{...stackToItemProps(savedSlots.get(i)), isBroken:false, isSave:true}}
/>);
}
}else if(slots.length > savedSlots.length){
for(let i=savedSlots.length;i<slots.length;i++){
doubleSlots.push(<DoubleItemSlot key={i + savedSlots.length}
second={{...stackToItemProps(slots.get(i)), isBroken:i>=slots.length-numBroken, isSave:false}}
/>);
}
}
return doubleSlots;
})()
}
</div>
</div> </div>
:<> :<>
<div style={{ <div style={{
borderTop: "1px solid black", borderTop: "1px solid black",
borderBottom: "1px solid black", borderBottom: "1px solid black",
marginBottom: 2, marginBottom: 2,
boxSizing: "content-box", boxSizing: "content-box",
height: "calc( ( 99vh - 60px ) / 2)", height: "calc( ( 99vh - 60px ) / 2)",
overflowY: "auto" overflowY: "auto"
} }> } }>
<div>Inventory of Save</div> <div>Inventory of Save</div>
<ItemList {...listSaveProps}/> <ItemList {...listSaveProps}/>
</div> </div>
<div style={{ <div style={{
borderTop: "1px solid black", borderTop: "1px solid black",
boxSizing: "content-box", boxSizing: "content-box",
height: "calc( ( 99vh - 60px ) / 2)", height: "calc( ( 99vh - 60px ) / 2)",
overflowY: "auto" overflowY: "auto"
} }> } }>
<div>Current Inventory</div> <div>Current Inventory</div>
<ItemList {...listProps}/> <ItemList {...listProps}/>
</div> </div>
</>} </>}
</div>; </div>;
}; };