Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en-us">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Keal's Roe2Js Test @ Test.Puzzlum.Org.2.Test</title>
- <link rel="icon" href="data:image/png;base64,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" type="image/png">
- <link rel="shortcut icon" href="data:image/png;base64,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" type="image/png">
- <style>
- :root {
- --host: "http://test.puzzlum.org.2.test";
- }
- canvas {
- image-rendering: smooth;
- position: absolute;
- top: 0px;
- left: 0px;
- width: 320px;
- height: 240px;
- margin: 0px;
- background-color: #f0f0f0;
- border: none;
- z-index: -1;
- }
- .frontbuffer {
- z-index: -1;
- }
- .backbuffer {
- z-index: -2;
- visibility: hidden;
- }
- :root {
- --ega-black: #000000;
- --ega-blue: #0000AA;
- --ega-green: #00AA00;
- --ega-cyan: #00AAAA;
- --ega-red: #AA0000;
- --ega-magenta: #AA00AA;
- --ega-brown: #AA5500;
- --ega-light-gray: #AAAAAA;
- --ega-dark-gray: #555555;
- --ega-light-blue: #5555FF;
- --ega-light-green: #55FF55;
- --ega-light-cyan: #55FFFF;
- --ega-light-red: #FF5555;
- --ega-light-magenta: #FF55FF;
- --ega-yellow: #FFFF55;
- --ega-white: #FFFFFF;
- }
- :root {
- --ega-0: #000000;
- --ega-1: #0000AA;
- --ega-2: #00AA00;
- --ega-3: #00AAAA;
- --ega-4: #AA0000;
- --ega-5: #AA00AA;
- --ega-6: #AA5500;
- --ega-7: #AAAAAA;
- --ega-8: #555555;
- --ega-9: #5555FF;
- --ega-10: #55FF55;
- --ega-11: #55FFFF;
- --ega-12: #FF5555;
- --ega-13: #FF55FF;
- --ega-14: #FFFF55;
- --ega-15: #FFFFFF;
- }
- :root {
- --ega-a: #55FF55;
- --ega-b: #55FFFF;
- --ega-c: #FF5555;
- --ega-d: #FF55FF;
- --ega-e: #FFFF55;
- --ega-f: #FFFFFF;
- }
- :root {
- --bull-regular: '\25CE';
- /*--bull-visited: '\25B2';*/
- --bull-visited: '\25C9';
- --bull-focus: '\25C9';
- --bull-active: '\25C9';
- --bull-hover: '\25C9';
- }
- :root {
- --link-regular: var(--ega-11);
- --link-visited: var(--ega-14);
- --link-focus: var(--ega-15);
- --link-active: var(--ega-15);
- --link-hover: var(--ega-15);
- }
- /* Regular links */
- a,
- a::before {
- text-decoration: none;
- content: var(--bull-regular);
- color: var(--link-regular);
- }
- /* Currently hovered links */
- a:hover,
- a:hover::before {
- content: var(--bull-hover);
- color: var(--link-hover);
- }
- /* Currently active links */
- a:active,
- a:active::before {
- content: var(--bull-active);
- color: var(--link-active);
- }
- /* Currently open/active links */
- a:focus,
- a:focus::before {
- outline: none; /* Remove default focus outline */
- content: var(--bull-focus);
- color: var(--link-focus);
- }
- /* Visited links */
- a:visited,
- a:visited::before {
- content: var(--bull-visited);
- color: var(--link-visited);
- }
- /* main.css */
- body {
- text-decoration: none;
- background-color: var(--ega-1);
- color: var(--ega-14);
- -webkit-text-stroke-width: 1.3px;
- -webkit-text-stroke-color: rgba(0, 0, 0, 0.1);
- font-family: 'Courier New', Courier, monospace;
- }
- span {
- display: inline-block;
- width: 6em;
- text-align: center;
- }
- suffix {
- display: inline-block;
- width: 1.3em;
- text-align: center;
- }
- table {
- border-collapse: collapse;
- width: auto;
- height: auto;
- }
- .outertable {
- text-decoration: none;
- border: none;
- width: 100%;
- text-align: center;
- vertical-align: top;
- padding: 0.0em;
- }
- .lefttable {
- background-color: rgba(255, 255, 255, 0.6);
- text-decoration: none;
- border: 1px solid black;
- width: 12em;
- text-align: center;
- vertical-align: top;
- padding: 0.3em;
- }
- .righttable {
- background-color: rgba(255, 255, 255, 0.6);
- text-decoration: none;
- border: 1px solid black;
- width: 12em;
- text-align: right;
- vertical-align: top;
- padding: 0.3em;
- }
- td {
- border: none;
- padding: 0;
- background-size: 100% 100%;
- }
- body, html {
- margin: 0;
- padding: 0;
- height: 100%;
- overflow: hidden;
- }
- .container {
- display: flex;
- height: 100%;
- }
- .left, .right {
- flex: 1;
- overflow-y: auto;
- }
- .scroll-region {
- overflow: auto;
- }
- .top-scroll {
- height: 20vh;
- overflow-y: auto;
- }
- .bottom-scroll {
- height: calc(100% - 20vh);
- overflow-y: auto;
- }
- /* Background scrolling animation */
- .background {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-image: url(/GFX/stonwall.png);
- background-size: auto;
- background-repeat: repeat;
- animation: scrollBackground 7s linear infinite;
- z-index: -1;
- }
- @keyframes scrollBackground {
- from {
- background-position: 0 0;
- }
- to {
- background-position: 24px 24px;
- }
- }
- /* Class to apply the panning animation to any element with the specific background */
- .panning-background {
- background-image: url(/GFX/stonwall.png);
- background-size: auto;
- background-repeat: repeat;
- animation: scrollBackground 7s linear infinite;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="left scrollable"></div>
- <div class="right">
- <div class="scrollable"></div>
- <div class="scrollable"></div>
- </div>
- </div>
- <script>
- var special = {
- "emptyCell": "________",
- "stonwall": "stonwall",
- "rockwall": "rockwall",
- "sel1dash": "sel1dash",
- "sel2dash": "sel2dash",
- "sel1dots": "sel1dots",
- "sel2dots": "sel2dots"
- }
- var host = host || `http://test.puzzlum.org.2.test`;
- var map = map || `demo`;
- // Map position
- var cx = 0;
- var cy = 0;
- var tileW = 24;
- var tileH = 24;
- var gutterW = 8;
- var gutterH = 8;
- var viewCursor = {
- "hover": { "x": 0, "y": 0 },
- "prev": { "x": 0, "y": 0 },
- "click": { "x": 0, "y": 0 },
- "dragging": false,
- "dragStart": { "x": 0, "y": 0 },
- "dragEnd": { "x": 0, "y": 0 }
- }
- var canvasCursor = {
- "hover": { "x": 0, "y": 0 },
- "prev": { "x": 0, "y": 0 },
- "click": { "x": 0, "y": 0 },
- "dragging": false,
- "dragStart": { "x": 0, "y": 0 },
- "dragEnd": { "x": 0, "y": 0 }
- }
- var layers = {
- "terrain": 0,
- "critter": 1,
- "object": 2,
- "ailment": 3,
- "gui": 4
- }
- var rawMap = [
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "web_____"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "stps____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "imp_____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "door____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "stpw____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ]
- ]
- // Load view portal constraints
- var viewConstraints = {
- "viewMinX": -3,
- "viewMaxX": 3,
- "viewMinY": -3,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 7,
- "viewSpanY": 7
- }
- var ViewPortal = create3DArrayBlock(`${special.emptyCell}`, viewConstraints.viewMinX, viewConstraints.viewMaxX, viewConstraints.viewMinY, viewConstraints.viewMaxY, 0, layers.gui);
- // Load purse tray constraints
- var purseConstraints = {
- "viewMinX": 0,
- "viewMaxX": 4,
- "viewMinY": 0,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 5,
- "viewSpanY": 6
- }
- var PurseTray = create3DArrayBlock(`${special.emptyCell}`, purseConstraints.viewMinX, purseConstraints.viewMaxX, purseConstraints.viewMinY, purseConstraints.viewMaxY, 0, layers.gui)
- var default_entity_stats = [];
- var default_action_stats = [];
- default_entity_stats = loadDefaultStats ( );
- default_action_stats = loadDefaultActions ( );
- function loadDefaultStats ( ){
- var ent_layers = [];
- var ent_stats = [];
- ent_stats[`____`] =
- loadJSONDirect(`/test dictionary/scripts/json/gamevars/default stats.json`);
- var ent_layers = {
- "terrain": [
- "____",
- "dirt",
- "hole",
- "watr",
- "stps",
- "stpw"
- ],
- "critter": [
- "____",
- "dtby",
- "spdr",
- "grml",
- "imp_",
- "emgd",
- "shkt",
- "pndx"
- ],
- "object": [
- "____",
- "door",
- "wall",
- "bldr",
- "ccts",
- "chst",
- "pwch"
- ],
- "ailment": [
- "____",
- "web_",
- "wing",
- "cure",
- "vnom",
- "fire",
- "loc1",
- "loc2",
- "loc3",
- "dust",
- "zzzz"
- ]
- }
- // console.log(ent_layers);
- for(let layer = 0; layer < ent_layers.length; layer++ ){
- let entityRoster = ent_layers[layer];
- for(let index = 0; index < entityRoster.length; index++ ){
- ent_stats[entityRoster[index]] = loadJSONDirect(`/test dictionary/scripts/json/gamevars/entities/`+left(entityRoster[index]+'____',4)+`.json`);
- }
- }
- return ent_stats;
- }
- function loadDefaultActions ( ){
- var actionRoster = [];
- var act_stats = [];
- var act_stats = [
- "____",
- "wstf",
- "bite",
- "burn",
- "cure",
- "dggr",
- "fire",
- "grpl",
- "ispt",
- "kick",
- "lash",
- "move",
- "pike",
- "pnch",
- "seed",
- "tngl",
- "vnom",
- "web_"
- ]
- for( let index = 0; index < actionRoster.length; index++ ){
- let actName = actionRoster[index];
- act_stats[actName] = [];
- let url = `${host}/test dictionary/scripts/json/gamevars/actions/${actName}.json`;
- act_stats[actName] = loadJSONDirect(url);
- }
- return act_stats;
- }
- function loadMap ( ){
- var rawMap = [
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "web_____"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "stps____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "imp_____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "door____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "stpw____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ]
- ]
- full_map = create3DArrayBlock(`____`, 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- full_entity_stats = create3DArrayBlock([], 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- for(let y = 0; y < rawMap[0].length; y++ ){
- for(let x = 0; x < rawMap.length; x++ ){
- for(let z = 0; z < layers.gui; z++ ){
- full_map[x][y][z] = left(rawMap[x][y][z]+`____`,4);
- full_entity_stats[x][y][z] = default_entity_stats[left(full_map[x][y][z]+`____`,4)];
- }
- }
- }
- cx = randInt(0,full_map.length - 1);
- cy = randInt(0,full_map[0].length - 1);
- }
- // Function to reset the turn table
- function turnReset ( ) {
- if(narration.length !== 0){
- logFeats(narration.join("\r\n"));
- narration = [];
- }
- try {
- turnTable = JSON.parse(JSON.stringify(prefab)); // Use deep copy to avoid reference issues
- logDebug("Turn table reset successfully.");
- } catch (error) {
- logError("Error resetting turn table:", error);
- }
- return true;
- }
- // Check if coordinates are out of bounds for the view
- function oobView(coords) {
- const result = soob(coords, [
- [viewConstraints.viewMinX, viewConstraints.viewMaxX],
- [viewConstraints.viewMinY, viewConstraints.viewMaxY]
- ]);
- logDebug("oobView result for coords", coords, ":", result);
- return result;
- }
- // Check if coordinates are out of bounds for the map
- function oobMap(coords) {
- const result = soob(coords, [
- [0, full_map.length - 1],
- [0, full_map[0].length - 1]
- ]);
- logDebug("oobMap result for coords", coords, ":", result);
- return result;
- }
- // Validate move direction for given coordinates
- function validateMove(coords) {
- logDebug("Validating move for coords:", coords);
- if (!Array.isArray(coords) || coords.length !== 2) {
- // logError("Invalid coordinates:", coords);
- return false;
- }
- let isValid = oobMap(coords);
- if (isValid !== true) {
- logWarning("Coordinates out of map bounds:", coords);
- return false;
- }
- let [x, y] = coords;
- let direction = dice(`1d` + cardinals.length) - 1;
- if (direction === -1) {
- logWarning("Invalid dice roll direction:", direction);
- return false;
- }
- let x2 = x + cardinals[direction][0];
- let y2 = y + cardinals[direction][1];
- if (oobMap([x2, y2]) !== true) {
- logWarning("Destination out of map bounds:", [x2, y2]);
- return false;
- }
- if (turnTable[x][y].hadit === 1 || turnTable[x2][y2].hadit === 1) {
- logWarning("Turn already taken for these coordinates:", [x, y], [x2, y2]);
- return false;
- }
- // logDebug("Move direction validated:", direction);
- return direction;
- }
- // Execute turn logic for all critters
- function takeTurns ( ) {
- logDebug("Executing takeTurns...");
- turnReset ( );
- for (let y = 0; y < full_map[0].length; y++) {
- for (let x = 0; x < full_map.length; x++) {
- critterAnimate([x, y]);
- }
- }
- turnReset ( );
- refreshGui ( );
- logDebug("Turn execution completed.");
- }
- // Function to animate critter movement
- function critterAnimate(coords) {
- if (oobMap(coords) !== true) {
- return false;
- }
- let [x, y] = coords;
- let z = layers.critter;
- if (invalidName(full_map[x][y][layers.critter])){
- return false;
- }
- let direction = validateMove([x, y]);
- if ([false, 0].includes(direction)) {
- return direction;
- }
- let [x2, y2] = [x + cardinals[direction][0], y + cardinals[direction][1]];
- if (oobMap([x, y]) !== true || oobMap([x2, y2]) !== true) {
- return false;
- }
- queue.src.Map = full_map[x][y];
- queue.src.Stats = full_entity_stats[x][y];
- queue.dest.Map = full_map[x2][y2];
- queue.dest.Stats = full_entity_stats[x2][y2];
- // logFeats([queue.src.Map,queue.src.Stats]);
- // logFeats([queue.dest.Map,queue.dest.Stats]);
- if (!queue.src.Stats[layers.critter] && !queue.src.Stats[layers.critter].stats.card) {
- queue.src.Stats = default_entity_stats[full_map[x,y,z]];
- }
- if (!queue.dest.Stats[layers.critter] && !queue.dest.Stats[layers.critter].stats.card) {
- queue.dest.Stats = default_entity_stats[full_map[x2,y2,z]];
- }
- if (turnTable[x][y].hadit === 1 || turnTable[x2][y2].hadit === 1) {
- return false;
- }
- turnTable[x][y].hasit = 1;
- turnTable[x][y].hadit = 1;
- logFeats(`{${queue.src.Stats[layers.critter].stats.card.namesake}: '${queue.src.Stats[layers.critter].stats.card.action}'}`);
- switch(queue.src.Stats[layers.critter].stats.card.namesake){
- case ucwords(`Placeholder`):
- case ucwords(`Out Of Bounds`):
- // console.log(queue.src.Stats[layers.critter].stats.card.namesake);
- return null;
- default:
- // console.log(queue.src.Stats[layers.critter].stats.card.namesake);
- break;
- }
- let actionRoster = sections(queue.src.Stats[layers.critter].stats.card.action,4);
- /*
- var default_action_stats = [];
- for(let $index = 0; $index < actionRoster.length; $index++){
- default_action_stats[actionRoster[$index]] = loadJSONDirect(`${host}/test dictionary/scripts/json/gamevars/actions/`+actionRoster[$index]+`.json`);
- }
- */
- let options = actionRoster;
- let choiceRoll = dice(`1d${options.length}`) - 1;
- let choice = options[choiceRoll];
- let choiceDirect = choice;
- let choiceName = ucwords('unknown');
- let srcCrit = inlineNames(queue.src.Map[layers.critter],4)[0];
- let destCrit = inlineNames(queue.dest.Map[layers.critter],4)[0];
- let srcName = ucwords(queue.src.Stats[layers.critter].stats.card.namesake);
- let destName = ucwords(queue.dest.Stats[layers.critter].stats.card.namesake);
- if (invalidName(destCrit,2)){
- destName = ucwords('clear passage');
- }
- if (choiceName !== ucwords('unknown')) {
- narration.push(`@ ${padCoord([x, y])}: ${srcName} attempted to wield their ${choiceName} ability upon the nearest adjacent ${ucwords(cardDirect[direction])}ward ${destName}.. (Rolled ${choiceRoll + 1} out of ${options.length})`);
- } else {
- return null;
- }
- if (invalidName(choice,2)){
- return null;
- }
- let functionName = `${attributes[z]}_${srcCrit}_${choice}`;
- let result = callAttributeFunction(functionName, queue);
- let Status = ``;
- if (result !== true) {
- Status = ucwords(`Failure`);
- } else {
- Status = ucwords(`Success`);
- }
- narration.push(`@ ${padCoord([x, y])}: ${srcName}'s attempted usage of their ${choiceName} ability resulted in ${Status}.`);
- if (result !== true) {
- return null;
- }
- full_map[x][y] = queue.src.Map;
- full_entity_stats[x][y] = queue.src.Stats;
- full_map[x2][y2] = queue.dest.Map;
- full_entity_stats[x2][y2] = queue.dest.Stats;
- return true;
- }
- // Function to move the critter from source to destination
- function moveCritter(srcCoords, destCoords, z) {
- let [x, y] = srcCoords;
- let [x2, y2] = destCoords;
- logDebug(`Moving critter from (${x}, ${y}, ${z}) to (${x2}, ${y2}, ${z})`);
- for(let zi = 0; zi < layers.gui; zi++)
- {
- switch(zi){
- case layers.critter:
- case layers.ailment:
- // Swap critter positions
- [
- full_map[x][y][zi],
- full_map[x2][y2][zi]
- ]
- =
- [
- full_map[x2][y2][zi],
- full_map[x][y][zi]
- ];
- // Update stats accordingly
- [
- full_entity_stats[x][y][zi], full_entity_stats[x2][y2][zi]
- ]
- =
- [
- full_entity_stats[x2][y2][zi], full_entity_stats[x][y][zi]
- ];
- break;
- }
- }
- // Update turnTable to reflect the move
- turnTable[x][y].hasit = 0;
- turnTable[x][y].hadit = 1;
- turnTable[x2][y2].hasit = 1;
- turnTable[x2][y2].hadit = 1;
- logDebug(`Critter moved successfully.`);
- }
- // Check if coordinates are valid
- function validateCoords(coords) {
- if (!Array.isArray(coords) || coords.length !== 2) {
- logError("Invalid coordinates:", coords);
- return false;
- }
- let [x, y] = coords.map(c => parseInt(c, 10));
- if (isNaN(x) || isNaN(y)) {
- logError("Coordinates are not numbers:", coords);
- return false;
- }
- logDebug("Coordinates validated:", coords);
- return true;
- }
- // Check if coordinates are out of bounds and adjust if necessary
- function soob(coords, rules) {
- if (!Array.isArray(coords) || !Array.isArray(rules) || coords.length !== rules.length) {
- logError("Invalid coordinates or rules for soob:", coords, rules);
- return false;
- }
- let [x,y] = coords;
- let adjustedCoords = coords.map((coord, index) => {
- let x = Math.round(parseInt(coord, 10));
- if (isNaN(x)) return false;
- let [min, max] = rules[index].map(rule => Math.round(parseInt(rule, 10)));
- if (isNaN(min) || isNaN(max)) return false;
- return Math.min(Math.max(x, min), max);
- });
- if (adjustedCoords.includes(false)) {
- logError("Adjusted coordinates contain invalid values:", adjustedCoords);
- return false;
- }
- const result = adjustedCoords.every((coord, index) => coord === coords[index]) ? true : adjustedCoords;
- logDebug("soob result for coords", coords, ":", result);
- return result;
- }
- // Function to validate and deep copy the data
- function validateAndDeepCopy(data) {
- if (typeof data === 'undefined') {
- logError("Data is undefined, cannot deep copy");
- return null;
- }
- try {
- return JSON.parse(JSON.stringify(data));
- } catch (e) {
- logError("Failed to parse data:", data, e);
- return null;
- }
- }
- function padNumber(num, length, char = '0') {
- return num.toString ( ).padStart(length, char);
- }
- function padCoord(Coord){
- return '('+padNumber(Coord[0], 5, ' ')+','+padNumber(Coord[1], 5, ' ')+')';
- }
- // console.log(`Exists: "/GFX/dooropen.png"`,`(`+fileExists(`/GFX/dooropen.png`)+`)`);
- /* Missing File: {{ #viewCursor=/test dictionary/scripts/json/gamevars/viewCursor.json }} */
- // Hover position
- viewCursor.hover.x = 0;
- viewCursor.hover.y = 0;
- viewCursor.hover.z = layers.gui;
- // Hover previous position
- viewCursor.prev.x = viewCursor.hover.x;
- viewCursor.prev.y = viewCursor.hover.y;
- viewCursor.prev.z = viewCursor.hover.z;
- var viewSpanX = viewConstraints.viewMaxX - viewConstraints.viewMinX + 1;
- var viewSpanY = viewConstraints.viewMaxY - viewConstraints.viewMinY + 1;
- var purseSpanX = purseConstraints.purseMaxX - purseConstraints.purseMinX + 1;
- var purseSpanY = purseConstraints.purseMaxY - purseConstraints.purseMinY + 1;
- var cardDirect = [];
- var cardinals = [];
- var attributes = [
- "terrain",
- "critter",
- "object",
- "ailment",
- "gui"
- ]
- var entityRoster = {
- "terrain": [
- "____",
- "dirt",
- "hole",
- "watr",
- "stps",
- "stpw"
- ],
- "critter": [
- "____",
- "dtby",
- "spdr",
- "grml",
- "imp_",
- "emgd",
- "shkt",
- "pndx"
- ],
- "object": [
- "____",
- "door",
- "wall",
- "bldr",
- "ccts",
- "chst",
- "pwch"
- ],
- "ailment": [
- "____",
- "web_",
- "wing",
- "cure",
- "vnom",
- "fire",
- "loc1",
- "loc2",
- "loc3",
- "dust",
- "zzzz"
- ]
- }
- var actionRoster = [
- "____",
- "wstf",
- "bite",
- "burn",
- "cure",
- "dggr",
- "fire",
- "grpl",
- "ispt",
- "kick",
- "lash",
- "move",
- "pike",
- "pnch",
- "seed",
- "tngl",
- "vnom",
- "web_"
- ]
- var host = host || `http://test.puzzlum.org.2.test`;
- var map = map || `demo`;
- /* Missing File: {{ #/test dictionary/scripts/js/files.js }} */
- // Load view portal constraints
- var viewConstraints = {
- "viewMinX": -3,
- "viewMaxX": 3,
- "viewMinY": -3,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 7,
- "viewSpanY": 7
- }
- var ViewPortal = create3DArrayBlock(`${special.emptyCell}`, viewConstraints.viewMinX, viewConstraints.viewMaxX, viewConstraints.viewMinY, viewConstraints.viewMaxY, 0, layers.gui);
- // Load purse tray constraints
- var purseConstraints = {
- "viewMinX": 0,
- "viewMaxX": 4,
- "viewMinY": 0,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 5,
- "viewSpanY": 6
- }
- var PurseTray = create3DArrayBlock(`${special.emptyCell}`, purseConstraints.viewMinX, purseConstraints.viewMaxX, purseConstraints.viewMinY, purseConstraints.viewMaxY, 0, layers.gui)
- const EQU = (a, b) => a === b;
- const NEQ = (a, b) => a !== b;
- const GTR = (a, b) => a > b;
- const LSS = (a, b) => a < b;
- const GEQ = (a, b) => a >= b;
- const LEQ = (a, b) => a <= b;
- var layers = {
- "terrain": 0,
- "critter": 1,
- "object": 2,
- "ailment": 3,
- "gui": 4
- }
- function loadJSONSync(url) {
- url = fixURL(url);
- var xhr = new XMLHttpRequest ( );
- xhr.open('GET', url, false); // 'false' makes the request synchronous
- xhr.send(null);
- if (xhr.status === 200) {
- return JSON.parse(xhr.responseText);
- } else {
- // throw new Error('Failed to load JSON');
- return [];
- }
- }
- function loadJSONDirect (url) {
- url = fixURL ( url );
- if( !fileExists ( url ) ) {
- return [];
- }
- try {
- var data = loadJSONSync(url);
- // // console.log(data);
- } catch (error) {
- return [];
- // console.error(error);
- }
- // console.log ( basename(url), data );
- return data;
- }
- function fileExists ( url ) {
- url = fixURL( url );
- try {
- fetch ( url );
- } catch (error) {
- return false;
- }
- return true;
- }
- function basename(path = '', ext = '') {
- // Ensure path is a string
- path = path.toString ( );
- // Split the path by '/'
- let parts = path.split('/');
- // Get the last part of the path
- let base = parts[parts.length - 1];
- // If an extension is specified and the base ends with that extension
- if (ext && right(base, len(ext)) === ext) {
- // Remove the extension from the base
- base = left(base, len(base) - len(ext));
- }
- return base;
- }
- function fixURL ( url ) {
- // Ensure the URL starts with the host
- if ( !url.startsWith( host ) ) {
- url = `${host}${url}`;
- }
- // Replace spaces with %20
- url = url.replace(/ /g, '%20');
- return url;
- }
- var host = host || `http://test.puzzlum.org.2.test`;
- var map = map || `demo`;
- // Map position
- var cx = 0;
- var cy = 0;
- var tileW = 24;
- var tileH = 24;
- var gutterW = 8;
- var gutterH = 8;
- var viewCursor = {
- "hover": { "x": 0, "y": 0 },
- "prev": { "x": 0, "y": 0 },
- "click": { "x": 0, "y": 0 },
- "dragging": false,
- "dragStart": { "x": 0, "y": 0 },
- "dragEnd": { "x": 0, "y": 0 }
- }
- var canvasCursor = {
- "hover": { "x": 0, "y": 0 },
- "prev": { "x": 0, "y": 0 },
- "click": { "x": 0, "y": 0 },
- "dragging": false,
- "dragStart": { "x": 0, "y": 0 },
- "dragEnd": { "x": 0, "y": 0 }
- }
- var layers = {
- "terrain": 0,
- "critter": 1,
- "object": 2,
- "ailment": 3,
- "gui": 4
- }
- var rawMap = [
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "web_____"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "stps____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "imp_____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "door____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "stpw____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ]
- ]
- // Load view portal constraints
- var viewConstraints = {
- "viewMinX": -3,
- "viewMaxX": 3,
- "viewMinY": -3,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 7,
- "viewSpanY": 7
- }
- var ViewPortal = create3DArrayBlock(`${special.emptyCell}`, viewConstraints.viewMinX, viewConstraints.viewMaxX, viewConstraints.viewMinY, viewConstraints.viewMaxY, 0, layers.gui);
- // Load purse tray constraints
- var purseConstraints = {
- "viewMinX": 0,
- "viewMaxX": 4,
- "viewMinY": 0,
- "viewMaxY": 3,
- "viewMinZ": 0,
- "viewMaxZ": 4,
- "viewSpanX": 5,
- "viewSpanY": 6
- }
- var PurseTray = create3DArrayBlock(`${special.emptyCell}`, purseConstraints.viewMinX, purseConstraints.viewMaxX, purseConstraints.viewMinY, purseConstraints.viewMaxY, 0, layers.gui)
- var default_entity_stats = [];
- var default_action_stats = [];
- default_entity_stats = loadDefaultStats ( );
- default_action_stats = loadDefaultActions ( );
- function loadDefaultStats ( ){
- var ent_layers = [];
- var ent_stats = [];
- ent_stats[`____`] =
- loadJSONDirect(`/test dictionary/scripts/json/gamevars/default stats.json`);
- var ent_layers = {
- "terrain": [
- "____",
- "dirt",
- "hole",
- "watr",
- "stps",
- "stpw"
- ],
- "critter": [
- "____",
- "dtby",
- "spdr",
- "grml",
- "imp_",
- "emgd",
- "shkt",
- "pndx"
- ],
- "object": [
- "____",
- "door",
- "wall",
- "bldr",
- "ccts",
- "chst",
- "pwch"
- ],
- "ailment": [
- "____",
- "web_",
- "wing",
- "cure",
- "vnom",
- "fire",
- "loc1",
- "loc2",
- "loc3",
- "dust",
- "zzzz"
- ]
- }
- // console.log(ent_layers);
- for(let layer = 0; layer < ent_layers.length; layer++ ){
- let entityRoster = ent_layers[layer];
- for(let index = 0; index < entityRoster.length; index++ ){
- ent_stats[entityRoster[index]] = loadJSONDirect(`/test dictionary/scripts/json/gamevars/entities/`+left(entityRoster[index]+'____',4)+`.json`);
- }
- }
- return ent_stats;
- }
- function loadDefaultActions ( ){
- var actionRoster = [];
- var act_stats = [];
- var act_stats = [
- "____",
- "wstf",
- "bite",
- "burn",
- "cure",
- "dggr",
- "fire",
- "grpl",
- "ispt",
- "kick",
- "lash",
- "move",
- "pike",
- "pnch",
- "seed",
- "tngl",
- "vnom",
- "web_"
- ]
- for( let index = 0; index < actionRoster.length; index++ ){
- let actName = actionRoster[index];
- act_stats[actName] = [];
- let url = `${host}/test dictionary/scripts/json/gamevars/actions/${actName}.json`;
- act_stats[actName] = loadJSONDirect(url);
- }
- return act_stats;
- }
- function loadMap ( ){
- var rawMap = [
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "web_____"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "stps____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "imp_____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "door____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "stpw____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ]
- ]
- full_map = create3DArrayBlock(`____`, 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- full_entity_stats = create3DArrayBlock([], 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- for(let y = 0; y < rawMap[0].length; y++ ){
- for(let x = 0; x < rawMap.length; x++ ){
- for(let z = 0; z < layers.gui; z++ ){
- full_map[x][y][z] = left(rawMap[x][y][z]+`____`,4);
- full_entity_stats[x][y][z] = default_entity_stats[left(full_map[x][y][z]+`____`,4)];
- }
- }
- }
- cx = randInt(0,full_map.length - 1);
- cy = randInt(0,full_map[0].length - 1);
- }
- // Function to reset the turn table
- function turnReset ( ) {
- if(narration.length !== 0){
- logFeats(narration.join("\r\n"));
- narration = [];
- }
- try {
- turnTable = JSON.parse(JSON.stringify(prefab)); // Use deep copy to avoid reference issues
- logDebug("Turn table reset successfully.");
- } catch (error) {
- logError("Error resetting turn table:", error);
- }
- return true;
- }
- // Check if coordinates are out of bounds for the view
- function oobView(coords) {
- const result = soob(coords, [
- [viewConstraints.viewMinX, viewConstraints.viewMaxX],
- [viewConstraints.viewMinY, viewConstraints.viewMaxY]
- ]);
- logDebug("oobView result for coords", coords, ":", result);
- return result;
- }
- // Check if coordinates are out of bounds for the map
- function oobMap(coords) {
- const result = soob(coords, [
- [0, full_map.length - 1],
- [0, full_map[0].length - 1]
- ]);
- logDebug("oobMap result for coords", coords, ":", result);
- return result;
- }
- // Validate move direction for given coordinates
- function validateMove(coords) {
- logDebug("Validating move for coords:", coords);
- if (!Array.isArray(coords) || coords.length !== 2) {
- // logError("Invalid coordinates:", coords);
- return false;
- }
- let isValid = oobMap(coords);
- if (isValid !== true) {
- logWarning("Coordinates out of map bounds:", coords);
- return false;
- }
- let [x, y] = coords;
- let direction = dice(`1d` + cardinals.length) - 1;
- if (direction === -1) {
- logWarning("Invalid dice roll direction:", direction);
- return false;
- }
- let x2 = x + cardinals[direction][0];
- let y2 = y + cardinals[direction][1];
- if (oobMap([x2, y2]) !== true) {
- logWarning("Destination out of map bounds:", [x2, y2]);
- return false;
- }
- if (turnTable[x][y].hadit === 1 || turnTable[x2][y2].hadit === 1) {
- logWarning("Turn already taken for these coordinates:", [x, y], [x2, y2]);
- return false;
- }
- // logDebug("Move direction validated:", direction);
- return direction;
- }
- // Execute turn logic for all critters
- function takeTurns ( ) {
- logDebug("Executing takeTurns...");
- turnReset ( );
- for (let y = 0; y < full_map[0].length; y++) {
- for (let x = 0; x < full_map.length; x++) {
- critterAnimate([x, y]);
- }
- }
- turnReset ( );
- refreshGui ( );
- logDebug("Turn execution completed.");
- }
- // Function to animate critter movement
- function critterAnimate(coords) {
- if (oobMap(coords) !== true) {
- return false;
- }
- let [x, y] = coords;
- let z = layers.critter;
- if (invalidName(full_map[x][y][layers.critter])){
- return false;
- }
- let direction = validateMove([x, y]);
- if ([false, 0].includes(direction)) {
- return direction;
- }
- let [x2, y2] = [x + cardinals[direction][0], y + cardinals[direction][1]];
- if (oobMap([x, y]) !== true || oobMap([x2, y2]) !== true) {
- return false;
- }
- queue.src.Map = full_map[x][y];
- queue.src.Stats = full_entity_stats[x][y];
- queue.dest.Map = full_map[x2][y2];
- queue.dest.Stats = full_entity_stats[x2][y2];
- // logFeats([queue.src.Map,queue.src.Stats]);
- // logFeats([queue.dest.Map,queue.dest.Stats]);
- if (!queue.src.Stats[layers.critter] && !queue.src.Stats[layers.critter].stats.card) {
- queue.src.Stats = default_entity_stats[full_map[x,y,z]];
- }
- if (!queue.dest.Stats[layers.critter] && !queue.dest.Stats[layers.critter].stats.card) {
- queue.dest.Stats = default_entity_stats[full_map[x2,y2,z]];
- }
- if (turnTable[x][y].hadit === 1 || turnTable[x2][y2].hadit === 1) {
- return false;
- }
- turnTable[x][y].hasit = 1;
- turnTable[x][y].hadit = 1;
- logFeats(`{${queue.src.Stats[layers.critter].stats.card.namesake}: '${queue.src.Stats[layers.critter].stats.card.action}'}`);
- switch(queue.src.Stats[layers.critter].stats.card.namesake){
- case ucwords(`Placeholder`):
- case ucwords(`Out Of Bounds`):
- // console.log(queue.src.Stats[layers.critter].stats.card.namesake);
- return null;
- default:
- // console.log(queue.src.Stats[layers.critter].stats.card.namesake);
- break;
- }
- let actionRoster = sections(queue.src.Stats[layers.critter].stats.card.action,4);
- /*
- var default_action_stats = [];
- for(let $index = 0; $index < actionRoster.length; $index++){
- default_action_stats[actionRoster[$index]] = loadJSONDirect(`${host}/test dictionary/scripts/json/gamevars/actions/`+actionRoster[$index]+`.json`);
- }
- */
- let options = actionRoster;
- let choiceRoll = dice(`1d${options.length}`) - 1;
- let choice = options[choiceRoll];
- let choiceDirect = choice;
- let choiceName = ucwords('unknown');
- let srcCrit = inlineNames(queue.src.Map[layers.critter],4)[0];
- let destCrit = inlineNames(queue.dest.Map[layers.critter],4)[0];
- let srcName = ucwords(queue.src.Stats[layers.critter].stats.card.namesake);
- let destName = ucwords(queue.dest.Stats[layers.critter].stats.card.namesake);
- if (invalidName(destCrit,2)){
- destName = ucwords('clear passage');
- }
- if (choiceName !== ucwords('unknown')) {
- narration.push(`@ ${padCoord([x, y])}: ${srcName} attempted to wield their ${choiceName} ability upon the nearest adjacent ${ucwords(cardDirect[direction])}ward ${destName}.. (Rolled ${choiceRoll + 1} out of ${options.length})`);
- } else {
- return null;
- }
- if (invalidName(choice,2)){
- return null;
- }
- let functionName = `${attributes[z]}_${srcCrit}_${choice}`;
- let result = callAttributeFunction(functionName, queue);
- let Status = ``;
- if (result !== true) {
- Status = ucwords(`Failure`);
- } else {
- Status = ucwords(`Success`);
- }
- narration.push(`@ ${padCoord([x, y])}: ${srcName}'s attempted usage of their ${choiceName} ability resulted in ${Status}.`);
- if (result !== true) {
- return null;
- }
- full_map[x][y] = queue.src.Map;
- full_entity_stats[x][y] = queue.src.Stats;
- full_map[x2][y2] = queue.dest.Map;
- full_entity_stats[x2][y2] = queue.dest.Stats;
- return true;
- }
- // Function to move the critter from source to destination
- function moveCritter(srcCoords, destCoords, z) {
- let [x, y] = srcCoords;
- let [x2, y2] = destCoords;
- logDebug(`Moving critter from (${x}, ${y}, ${z}) to (${x2}, ${y2}, ${z})`);
- for(let zi = 0; zi < layers.gui; zi++)
- {
- switch(zi){
- case layers.critter:
- case layers.ailment:
- // Swap critter positions
- [
- full_map[x][y][zi],
- full_map[x2][y2][zi]
- ]
- =
- [
- full_map[x2][y2][zi],
- full_map[x][y][zi]
- ];
- // Update stats accordingly
- [
- full_entity_stats[x][y][zi], full_entity_stats[x2][y2][zi]
- ]
- =
- [
- full_entity_stats[x2][y2][zi], full_entity_stats[x][y][zi]
- ];
- break;
- }
- }
- // Update turnTable to reflect the move
- turnTable[x][y].hasit = 0;
- turnTable[x][y].hadit = 1;
- turnTable[x2][y2].hasit = 1;
- turnTable[x2][y2].hadit = 1;
- logDebug(`Critter moved successfully.`);
- }
- // Check if coordinates are valid
- function validateCoords(coords) {
- if (!Array.isArray(coords) || coords.length !== 2) {
- logError("Invalid coordinates:", coords);
- return false;
- }
- let [x, y] = coords.map(c => parseInt(c, 10));
- if (isNaN(x) || isNaN(y)) {
- logError("Coordinates are not numbers:", coords);
- return false;
- }
- logDebug("Coordinates validated:", coords);
- return true;
- }
- // Check if coordinates are out of bounds and adjust if necessary
- function soob(coords, rules) {
- if (!Array.isArray(coords) || !Array.isArray(rules) || coords.length !== rules.length) {
- logError("Invalid coordinates or rules for soob:", coords, rules);
- return false;
- }
- let [x,y] = coords;
- let adjustedCoords = coords.map((coord, index) => {
- let x = Math.round(parseInt(coord, 10));
- if (isNaN(x)) return false;
- let [min, max] = rules[index].map(rule => Math.round(parseInt(rule, 10)));
- if (isNaN(min) || isNaN(max)) return false;
- return Math.min(Math.max(x, min), max);
- });
- if (adjustedCoords.includes(false)) {
- logError("Adjusted coordinates contain invalid values:", adjustedCoords);
- return false;
- }
- const result = adjustedCoords.every((coord, index) => coord === coords[index]) ? true : adjustedCoords;
- logDebug("soob result for coords", coords, ":", result);
- return result;
- }
- // Function to validate and deep copy the data
- function validateAndDeepCopy(data) {
- if (typeof data === 'undefined') {
- logError("Data is undefined, cannot deep copy");
- return null;
- }
- try {
- return JSON.parse(JSON.stringify(data));
- } catch (e) {
- logError("Failed to parse data:", data, e);
- return null;
- }
- }
- function padNumber(num, length, char = '0') {
- return num.toString ( ).padStart(length, char);
- }
- function padCoord(Coord){
- return '('+padNumber(Coord[0], 5, ' ')+','+padNumber(Coord[1], 5, ' ')+')';
- }
- // console.log(`Exists: "/GFX/dooropen.png"`,`(`+fileExists(`/GFX/dooropen.png`)+`)`);
- /* Missing File: {{ #viewCursor=/test dictionary/scripts/json/gamevars/viewCursor.json }} */
- // Hover position
- viewCursor.hover.x = 0;
- viewCursor.hover.y = 0;
- viewCursor.hover.z = layers.gui;
- // Hover previous position
- viewCursor.prev.x = viewCursor.hover.x;
- viewCursor.prev.y = viewCursor.hover.y;
- viewCursor.prev.z = viewCursor.hover.z;
- var viewSpanX = viewConstraints.viewMaxX - viewConstraints.viewMinX + 1;
- var viewSpanY = viewConstraints.viewMaxY - viewConstraints.viewMinY + 1;
- var purseSpanX = purseConstraints.purseMaxX - purseConstraints.purseMinX + 1;
- var purseSpanY = purseConstraints.purseMaxY - purseConstraints.purseMinY + 1;
- var cardDirect = [];
- var cardinals = [];
- var attributes = [
- "terrain",
- "critter",
- "object",
- "ailment",
- "gui"
- ]
- var entityRoster = {
- "terrain": [
- "____",
- "dirt",
- "hole",
- "watr",
- "stps",
- "stpw"
- ],
- "critter": [
- "____",
- "dtby",
- "spdr",
- "grml",
- "imp_",
- "emgd",
- "shkt",
- "pndx"
- ],
- "object": [
- "____",
- "door",
- "wall",
- "bldr",
- "ccts",
- "chst",
- "pwch"
- ],
- "ailment": [
- "____",
- "web_",
- "wing",
- "cure",
- "vnom",
- "fire",
- "loc1",
- "loc2",
- "loc3",
- "dust",
- "zzzz"
- ]
- }
- var actionRoster = [
- "____",
- "wstf",
- "bite",
- "burn",
- "cure",
- "dggr",
- "fire",
- "grpl",
- "ispt",
- "kick",
- "lash",
- "move",
- "pike",
- "pnch",
- "seed",
- "tngl",
- "vnom",
- "web_"
- ]
- var narration = [];
- // Settings for debugging flags are as follows:
- // (Suggested settings are for debugging only.)
- const DEBUG = {
- // Set to false to disable detailed logging
- // suggested setting: "false"
- FULL: true,
- // Set to false to disable detailed logging
- // suggested setting: "false"
- DETAIL: false,
- // Set to false to disable error reports
- // suggested setting: "true"
- ERROR: false,
- // Set to false to disable warning reports
- // suggested setting: "true"
- WARNING: false,
- // Set to false to disable feat tracking
- // enabled highly suggested: "true"
- FEATS: true,
- // Set to false to disable inline messages
- // suggested setting: "false"
- CONSOLE: false,
- GUI: true
- }
- function logDebug(...args) {
- if (DEBUG.DETAIL) {
- console.log(...args);
- }
- }
- function logError(...args) {
- if (DEBUG.ERROR) {
- console.error(...args);
- }
- }
- function logWarning(...args) {
- if (DEBUG.WARNING) {
- console.warn(...args);
- }
- }
- function logFeats(...args) {
- if (DEBUG.FEATS) {
- console.warn(...args);
- }
- }
- function logGUI(...args) {
- if (DEBUG.GUI) {
- console.warn(...args);
- }
- }
- function logConsole(...args) {
- if (DEBUG.CONSOLE) {
- console.log(...args);
- }
- }
- /* array blocks lohi.js */
- function create1DArrayBlock(defaultValue, low1, high1) {
- const ArrayBlock = [];
- for (let i = low1; i <= high1; i++) {
- ArrayBlock[i] = defaultValue;
- }
- return ArrayBlock;
- }
- function create2DArrayBlock(defaultValue, low1, high1, low2, high2) {
- const ArrayBlock = [];
- for (let i = low1; i <= high1; i++) {
- ArrayBlock[i] = [];
- for (let j = low2; j <= high2; j++) {
- ArrayBlock[i][j] = defaultValue;
- }
- }
- return ArrayBlock;
- }
- function create3DArrayBlock(defaultValue, low1, high1, low2, high2, low3, high3) {
- const ArrayBlock = [];
- for (let i = low1; i <= high1; i++) {
- const innerArrayBlock1 = [];
- for (let j = low2; j <= high2; j++) {
- const innerArrayBlock2 = [];
- for (let k = low3; k <= high3; k++) {
- innerArrayBlock2.push(defaultValue);
- }
- innerArrayBlock1.push(innerArrayBlock2);
- }
- ArrayBlock.push(innerArrayBlock1);
- }
- return ArrayBlock;
- }
- function create1DObjectBlock(defaultValue, low1, high1) {
- const ObjectBlock = {};
- for (let i = low1; i <= high1; i++) {
- ObjectBlock[i] = defaultValue;
- }
- return ObjectBlock;
- }
- function create2DObjectBlock(defaultValue, low1, high1, low2, high2) {
- const ObjectBlock = {};
- for (let i = low1; i <= high1; i++) {
- ObjectBlock[i] = {};
- for (let j = low2; j <= high2; j++) {
- ObjectBlock[i][j] = defaultValue;
- }
- }
- return ObjectBlock;
- }
- function create3DObjectBlock(defaultValue, low1, high1, low2, high2, low3, high3) {
- const ObjectBlock = [];
- for (let i = low1; i <= high1; i++) {
- const innerObjectBlock1 = [];
- for (let j = low2; j <= high2; j++) {
- const innerObjectBlock2 = [];
- for (let k = low3; k <= high3; k++) {
- innerObjectBlock2.push(defaultValue);
- }
- innerObjectBlock1.push(innerObjectBlock2);
- }
- ObjectBlock.push(innerObjectBlock1);
- }
- return ObjectBlock;
- }
- /* Js Script: "/test dictionary/scripts/js/animatics/animatics vars.js" */
- var vowels = {
- "vowels": "aeiou"
- }
- // Ported BASIC functions
- function len(subject) {
- return subject.toString ( ).length;
- }
- function left(subject, n) {
- return subject.toString ( ).substring(0, n);
- }
- function right(subject, n) {
- return subject.toString ( ).substring(subject.length - n);
- }
- function mid(subject, start, length) {
- subject = subject.toString ( );
- let startIndex = start - 1;
- return length === undefined ? subject.substring(startIndex) : subject.substring(startIndex, startIndex + length);
- }
- function instr(haystack, needle, start) {
- if (typeof haystack !== 'string') throw new TypeError('haystack must be a string');
- needle = typeof needle === 'string' ? needle : ',';
- start = typeof start === 'number' ? start : 1;
- start = Math.max(0, start - 1);
- const index = haystack.indexOf(needle, start);
- return index !== -1 ? index + 1 : 0;
- }
- function reduceVowels(subject) {
- subject = subject.toLowerCase ( );
- if (len(subject) < 4) return left(subject + '____', 4);
- let count = 0;
- const vowelsList = 'aeiou';
- for (let offset = 0; offset < subject.length; offset++) {
- if (len(subject) === 4) return subject;
- if (instr(vowelsList, mid(subject, offset + 1, 1))) {
- count++;
- if (count === 1 && len(subject) > 4) {
- subject = left(subject, offset) + mid(subject, offset + 2, len(subject) - offset - 1);
- offset--;
- }
- }
- }
- return subject;
- }
- function inlineNames(data, span, plug) {
- return data.slice(0, span).map(item => {
- if (typeof item === 'object' && item !== null && item.name) {
- return item.name + (plug || '');
- } else if (typeof item === 'string') {
- return item + (plug || '');
- } else {
- return '____';
- }
- });
- }
- function inlineName(name, plug, span) {
- if (typeof name === 'string' || (typeof name === 'object' && name !== null && name.name)) {
- let nameStr = typeof name === 'string' ? name : name.name;
- let concatenatedName = nameStr + plug.repeat(span);
- return left(concatenatedName, plug.length * span);
- } else {
- return '____';
- }
- }
- function invalidName(name, span) {
- name = (name + `____`.repeat(span)).substr(0, span * 4);
- return name === `____`.repeat(span);
- }
- function loadCards ( ) {
- let cardDirect = [];
- let cardinals = [];
- cardDirect.push(...loadJSONDirect('/test dictionary/scripts/json/gamevars/cardDirect.json'));
- cardinals.push(...loadJSONDirect('/test dictionary/scripts/json/gamevars/cardinals.json'));
- if (cardDirect.length > 0 && cardinals.length > 0) {
- const cards = cardDirect.map((direction, index) => ({
- [reduceVowels(direction)]: { x: cardinals[index][0], y: cardinals[index][1] }
- }));
- // Do something with cards
- }
- }
- function sections(subject = '_'.repeat(8), length = 4, plug = '_'.repeat(8)) {
- let result = [];
- for (let index = 0; index < subject.length; index += length) {
- let section = mid(subject, index + 1, length) + plug;
- result.push(section.substr(0, length));
- }
- return result;
- }
- function inlineName(imagePath = `____`, repeats = 2, plug = `____`) {
- let baseImagePath = basename(imagePath);
- const concatenatedString = baseImagePath + plug.repeat(repeats);
- const substringLength = repeats * plug.length;
- return concatenatedString.substring(0, substringLength);
- }
- function ucwords(subject) {
- return subject.replace(/\b\w/g, function(match) {
- return match.toUpperCase ( );
- });
- }
- function isObject(variable) {
- return variable !== null && typeof variable === 'object' && !Array.isArray(variable);
- }
- /* dice.js */
- // Generate a random integer between min (inclusive) and max (exclusive)
- function randInt(min, max) {
- return Math.floor(Math.random ( ) * (max - min + 1)) + min;
- }
- // Generate a random dice roll
- function dice(cell) {
- if (cell.includes('${special.emptyCell}')) {
- cell = cell.replace('${special.emptyCell}', `${special.emptyCell}`);
- }
- var dicePattern = /(?<count>\d+)d(?<sides>\d+)/mi;
- var match = dicePattern.exec(cell); // Executing the regular expression on the cell string
- if (match !== null) { // Checking if there's a match
- var count = parseInt(match.groups.count); // Extracting count from the match
- var sides = parseInt(match.groups.sides); // Extracting sides from the match
- var rollResult = count * randInt(1, sides); // Generating random roll result
- cell = cell.replace(match[0], rollResult); // Replacing the dice notation with the rolled result
- cell = parseInt(cell,10);
- }
- return cell;
- }
- var default_entity_stats = [];
- var default_action_stats = [];
- default_entity_stats = loadDefaultStats ( );
- default_action_stats = loadDefaultActions ( );
- function loadDefaultStats ( ){
- var ent_layers = [];
- var ent_stats = [];
- ent_stats[`____`] =
- loadJSONDirect(`/test dictionary/scripts/json/gamevars/default stats.json`);
- var ent_layers = {
- "terrain": [
- "____",
- "dirt",
- "hole",
- "watr",
- "stps",
- "stpw"
- ],
- "critter": [
- "____",
- "dtby",
- "spdr",
- "grml",
- "imp_",
- "emgd",
- "shkt",
- "pndx"
- ],
- "object": [
- "____",
- "door",
- "wall",
- "bldr",
- "ccts",
- "chst",
- "pwch"
- ],
- "ailment": [
- "____",
- "web_",
- "wing",
- "cure",
- "vnom",
- "fire",
- "loc1",
- "loc2",
- "loc3",
- "dust",
- "zzzz"
- ]
- }
- // console.log(ent_layers);
- for(let layer = 0; layer < ent_layers.length; layer++ ){
- let entityRoster = ent_layers[layer];
- for(let index = 0; index < entityRoster.length; index++ ){
- ent_stats[entityRoster[index]] = loadJSONDirect(`/test dictionary/scripts/json/gamevars/entities/`+left(entityRoster[index]+'____',4)+`.json`);
- }
- }
- return ent_stats;
- }
- function loadDefaultActions ( ){
- var actionRoster = [];
- var act_stats = [];
- var act_stats = [
- "____",
- "wstf",
- "bite",
- "burn",
- "cure",
- "dggr",
- "fire",
- "grpl",
- "ispt",
- "kick",
- "lash",
- "move",
- "pike",
- "pnch",
- "seed",
- "tngl",
- "vnom",
- "web_"
- ]
- for( let index = 0; index < actionRoster.length; index++ ){
- let actName = actionRoster[index];
- act_stats[actName] = [];
- let url = `${host}/test dictionary/scripts/json/gamevars/actions/${actName}.json`;
- act_stats[actName] = loadJSONDirect(url);
- }
- return act_stats;
- }
- function loadMap ( ){
- var rawMap = [
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "web_____"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "spdr____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "bldr____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "pndx____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "shkt____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "stps____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "imp_____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "stps____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "stps____",
- "________",
- "door____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "door____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "stpw____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "dtby____",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "emgd____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "wall____",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "________",
- "________",
- "________"
- ],
- [
- "hole____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "grml____",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "watr____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "________",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "chst____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ],
- [
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ],
- [
- "dirt____",
- "________",
- "wall____",
- "________"
- ]
- ]
- ]
- full_map = create3DArrayBlock(`____`, 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- full_entity_stats = create3DArrayBlock([], 0,rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui );
- for(let y = 0; y < rawMap[0].length; y++ ){
- for(let x = 0; x < rawMap.length; x++ ){
- for(let z = 0; z < layers.gui; z++ ){
- full_map[x][y][z] = left(rawMap[x][y][z]+`____`,4);
- full_entity_stats[x][y][z] = default_entity_stats[left(full_map[x][y][z]+`____`,4)];
- }
- }
- }
- cx = randInt(0,full_map.length - 1);
- cy = randInt(0,full_map[0].length - 1);
- }
- function cursorState ( layer = layers.critter) {
- let state = [
- cx + viewCursor.hover.x,
- cy + viewCursor.hover.y
- ]
- let [ x, y ] = state;
- if(oobMap(state) !== true) {
- [x, y] = oobMap(state);
- }
- return [x,y,layer];
- }
- function backbuffer ( ) {
- var [ px, py, pz ] = cursorState ( layers.gui );
- canvasViewPortal ( );
- canvasScrollBars ( );
- canvasPurseTray ( );
- // drawScene ( );
- doubleBuffer ( );
- }
- function canvasViewPortal ( ){
- var [ px, py, pz ] = cursorState ( layers.gui );
- drawRectangle(gutterW, gutterH, viewConstraints.viewSpanX * tileW, viewConstraints.viewSpanY * tileH, 'black', 'black');
- let buffer = [];
- for(let y = viewConstraints.viewMinY; y <= viewConstraints.viewMaxY; y++){
- for(let x = viewConstraints.viewMinX; x <= viewConstraints.viewMaxX; x++){
- buffer = [];
- px = cx + x;
- py = cy + y;
- if(oobMap([px,py]) !== true){
- buffer.push(special.stonwall);
- }
- if(oobMap([px,py]) === true){
- for(let z = 0; z <= pz; z++){
- buffer.push(`${sections(full_map[px][py][z])[0]}____`);
- }
- if( ( x === 0 ) && ( y === 0 ) ){
- buffer.push(special.sel1dash);
- }
- }
- // logFeats(hover);
- if( ( x === viewCursor.hover.x ) && ( y === viewCursor.hover.y ) ){
- buffer.push(special.sel2dash);
- }
- buffer.push(special.sel2dots);
- drawImageStack(buffer,gutterW+(x - viewConstraints.viewMinX)*tileW,gutterH+(y - viewConstraints.viewMinY)*tileH,tileW,tileH);
- }
- }
- return true;
- }
- function canvasScrollBars ( ) {
- var [ px, py, pz ] = cursorState ( layers.gui );
- var gutterW = 0;
- var gutterH = 0;
- let scrollX1 = ( cx - viewSpanX / 2 ) / full_map.length;
- let scrollX2 = ( cx + viewSpanX / 2 ) / full_map.length;
- let scrollY1 = ( cy - viewSpanY / 2 ) / full_map[0].length;
- let scrollY2 = ( cy + viewSpanY / 2 ) / full_map[0].length;
- scrollX1 = viewSpanX * tileW * scrollX1;
- scrollX2 = viewSpanX * tileW * scrollX2;
- scrollY1 = viewSpanY * tileH * scrollY1;
- scrollY2 = viewSpanY * tileH * scrollY2;
- if( scrollX1 < 0 ){
- scrollX1 = 0;
- }
- if( scrollY1 < 0 ){
- scrollY1 = 0;
- }
- if( scrollX1 > viewSpanX * tileW ){
- scrollX1 = viewSpanX * tileW;
- }
- if( scrollY1 > viewSpanY * tileH ){
- scrollY1 = viewSpanY * tileH;
- }
- if( scrollX2 < 0 ){
- scrollX2 = 0;
- }
- if( scrollY2 < 0 ){
- scrollY2 = 0;
- }
- if( scrollX2 > viewSpanX * tileW ){
- scrollX2 = viewSpanX * tileW;
- }
- if( scrollY2 > viewSpanY * tileH ){
- scrollY2 = viewSpanY * tileH;
- }
- scrollW = scrollX2 - scrollX1;
- scrollH = scrollY2 - scrollY1;
- // left backbar
- drawRectangle(
- gutterW,
- gutterH,
- 8,
- viewSpanY*tileH,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // top backbar
- drawRectangle(
- gutterW,
- gutterH,
- viewSpanX*tileW,
- 8,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- gutterW = 0;
- gutterH = 0;
- // right backbar
- drawRectangle(
- gutterW+viewSpanX*tileW,
- gutterH,
- 8,
- viewSpanY*tileH,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // bottom backbar
- drawRectangle(
- gutterW,
- gutterH+viewSpanY*tileH,
- viewSpanX*tileW,
- 8,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // right scrollbar
- drawRectangle(
- gutterW*2+viewSpanX*tileW,
- gutterH*2+scrollY1,
- 8,
- scrollH,
- 'black',
- '#00ff00'
- );
- // bottom scrollbar
- drawRectangle(
- gutterW*2+scrollX1,
- gutterH*2+viewSpanY*tileH,
- scrollW,
- 8,
- 'black',
- '#00ff00'
- );
- return true;
- }
- function canvasPurseTray ( ) {
- var purseSpanX = 5;
- var purseSpanY = 6;
- var ent_stats = [];
- var [ px, py, pz ] = cursorState ( layers.critter );
- var xOffset = viewSpanX * tileW;
- drawRectangle(xOffset+gutterW*2, gutterH, purseSpanX * tileW, purseSpanY * tileH, 'black', 'black');
- var ss = [];
- ent_stats.stats = default_entity_stats[full_map[px][py][pz]].stats;
- ss.push(ent_stats.stats);
- ss.card = {};
- ss.card.namesake = `Placeholder`;
- ss.card.actionRoster = [];
- switch(true){
- case (oobMap([px,py]) !== true):
- ss.push(ent_stats.stats);
- ss.card.namesake = `Out Of Bounds`;
- ss.card.actionRoster = [];
- break;
- case (invalidName(full_map[px][py][layers.critter],2)):
- ss.push(ent_stats.stats);
- ss.card.namesake = `Placeholder`;
- ss.card.actionRoster = [];
- break;
- case (oobMap([px,py]) === true):
- ss.push(full_entity_stats[px][py][layers.critter].stats);
- ss.card.namesake = ss.card.namesake;
- ss.card.actionRoster = sections(ss.card.action,4);
- break;
- }
- let buffer = [];
- for(let y = purseConstraints.viewMinY; y <= purseConstraints.viewMaxY; y++){
- for(let x = purseConstraints.viewMinX; x <= purseConstraints.viewMaxX; x++){
- buffer = [];
- if(y === 3){
- let z = x;
- if((z >= 0) && (z < layers.gui)){
- if(oobMap([px,py]) === true){
- buffer.push(
- full_map[px][py][z]
- );
- }
- }
- }
- let x1 = 0;
- let purseSpanX = 5;
- let y1 = 4;
- let purseSpanY = 3;
- if((x >= x1) && (x < x1 + purseSpanX) && (y >= y1) && (y < y1 + purseSpanY)){
- let i = (x - x1) + (y - y1) * purseSpanX;
- if((i >= 0) && (i < ss.card.actionRoster.length)){
- buffer.push( ss.card.actionRoster[i] );
- }
- }
- buffer.push(`sel2dots`);
- drawImageStack(buffer,xOffset+
- gutterW * 2 + x * tileW,gutterH + y * tileH,tileW,tileH);
- }
- }
- ss.card.namesake = ucwords(ss.card.namesake);
- switch(true){
- case (ucwords(ss.card.namesake) === "Placeholder"):
- case (ucwords(ss.card.namesake) === "Out Of Bounds"):
- break;
- default:
- renderStats(px,py,z);
- drawText(gutterW + 0 * tileW, gutterH + 8 + 12,'16px Impact','white','" ' + ss.card.namesake + ' "');
- break;
- }
- return true;
- }
- function renderStatBar(x,y,width,height,caption,font,fg,bg){
- drawRectangle( x, y, width, height, 'black', bg );
- drawText( x, y, `${height}px ${font}`, fg, caption );
- }
- function renderStats(px,py,z){
- var [ px, py, pz ] = cursorState ( layers.critter );
- var gutterW = viewSpanX * tileW + 16;
- z = z || pz;
- let s = [];
- let pct = [];
- s['health'] = full_entity_stats[px][py][layers.critter].stats.health;
- s['stamina'] = full_entity_stats[px][py][layers.critter].stats.stamina;
- s['essence'] = full_entity_stats[px][py][layers.critter].stats.essence;
- renderStatusBar( s, 'health', tileW * viewSpanX + 16, 8 + 16 * 0, tileW * purseSpanX, 12, 'black', 'red' );
- renderStatusBar( s, 'stamina', tileW * viewSpanX + 16, 8 + 16 * 1, tileW * purseSpanX, 12, 'black', 'yellow' );
- renderStatusBar( s, 'essence', tileW * viewSpanX + 16, 8 + 16 * 2, tileW * purseSpanX, 12, 'black', 'cyan' );
- }
- function renderStatusBar(stat, attrName, gutterW, gutterH, width, height, fg, bg ) {
- var [ px, py, pz ] = cursorState ( );
- let s = stat[attrName];
- let pct = [];
- let w = [];
- s.minimum = s.minimum || 0;
- s.maximum = s.maximum || 1;
- s.current = s.current || 0;
- s.recovery = s.recovery || 0;
- pct['current'] = Math.round(100 * s.current / s.maximum);
- pct['minimum'] = Math.round(100 * s.minimum / s.maximum);
- pct['maximum'] = Math.round(100 * s.maximum / s.maximum);
- pct['recovery'] = Math.round(100 * (s.current + s.recovery) / s.maximum);
- let x = gutterW;
- let y = gutterH+24;
- // s.current, s.recovery
- // s.minimum, s.maximum
- let caption = `${attrName}: ${s.current} / ${s.maximum}`;
- let font = 'Small Fonts';
- // fg, bg
- w['current'] = width * curve(pct['current']) / 100;
- w['recovery'] = width * curve(pct['recovery']) / 100;
- w['minimum'] = 0;
- w['maximum'] = width * curve(1.0) / 100;
- drawRectangle( x, y, w['maximum'], height, 'black', 'gray' );
- drawRectangle( x, y + 4, w['current'], height - 4, 'black', bg );
- drawRectangle( x, y, w['recovery'], height - 4, 'rgba(0,0,0,0.0)', 'rgba(255,255,255,0.7)' );
- drawRectangle( x, y, width, height, 'black', 'rgba(0,0,0,0.0)' );
- drawText( x, y + 8, `${height*0.8}px ${font}`, 'black', caption );
- }
- var imageCache = [];
- var missingCache = [];
- var frontCanvas = false;
- var frontContext = false;
- var backCanvas = false
- var backContext = false;
- makeCanvas ( );
- function makeCanvas ( ) {
- //document.addEventListener("DOMContentLoaded", ( ) => {
- let fragment;
- // Create an on-screen canvas
- fragment = document.createDocumentFragment ( );
- frontCanvas = document.createElement('canvas');
- fragment.appendChild(frontCanvas);
- frontCanvas.style.zIndex = -1;
- frontCanvas.width = 320;
- frontCanvas.height = 240;
- frontCanvas.style.width = `320px`;
- frontCanvas.style.height = `240px`;
- frontCanvas.id = `frontCanvas`;
- frontContext = frontCanvas.getContext('2d');
- frontContext.width = 320;
- frontContext.height = 200;
- // Create an off-screen canvas
- backCanvas = document.createElement('canvas');
- fragment.appendChild(backCanvas);
- // Append all changes at once to reduce reflows
- document.body.appendChild(fragment);
- backCanvas.style.width = frontCanvas.style.width;
- backCanvas.style.height = frontCanvas.style.height;
- backCanvas.width = frontCanvas.width;
- backCanvas.height = frontCanvas.height;
- backContext.width = frontContext.width;
- backContext.height = frontContext.height;
- backCanvas.style.zIndex = -2;
- backCanvas.style.visibility = 'hidden';
- backCanvas.id = `backCanvas`;
- backContext = backCanvas.getContext('2d');
- }
- function selectCanvas(id){
- workCanvas = document.getElementById(id);
- }
- function drawRectangle(x, y, width, height, color = 'black',fill = 'gray'){
- backContext.strokeStyle = color;
- if(fill === ''){
- fill = 'rgba(0,0,0,0.0)';
- }
- backContext.fillStyle = fill;
- backContext.fillRect(x, y, width, height);
- backContext.strokeRect(x, y, width, height);
- }
- function drawLine(x,y,x2,y2,color = 'black',width = 5){
- backContext.strokeStyle = color;
- backContext.lineWidth = width;
- backContext.beginPath ( );
- backContext.moveTo(x, y);
- backContext.lineTo(x2, y2);
- backContext.stroke ( );
- }
- function drawCircle(x,y,radius = 50, color = 'black',fill = '#00FF00', width = 5){
- backContext.beginPath ( );
- backContext.arc(x, y, radius, 0, 2 * Math.PI);
- backContext.fillStyle = '#00FF00';
- backContext.fill ( );
- backContext.strokeStyle = '#000000';
- backContext.lineWidth = width;
- backContext.stroke ( );
- }
- function drawText(x,y,font = '30px Arial',fill = '#000000',text = 'Hello backcanvas!'){
- backContext.font = font;
- backContext.fillStyle = fill;
- backContext.fillText(text, x, y);
- }
- function drawImageStack(imageStack, x, y, width = 24, height = 24) {
- // console.log({imageStack: imageStack});
- for(index = 0; index < imageStack.length; index++){
- if( imageStack[index] === undefined ){
- continue;
- }
- imageStack[index] = basename(imageStack[index],`.png`);
- imageStack[index] = left( imageStack[index] + `________`, 8 );
- // console.log(imageStack[index]);
- drawImage( imageStack[index], x, y, width, height );
- }
- if(DEBUG.GUI){
- if( index > 0 ){
- // drawImage(`dooropen`, x, y, width, height);
- // drawRectangle(x, y, width, height, 'rgba(255,0,0,0.7)','');
- // drawText(x,y+16,'12px Impact', 'rgba(255,0,0,0.7)','TEST');
- }
- }
- }
- function drawImage(imagePath, x, y, width = 24, height = 24) {
- var cachedImage = loadImage(imagePath);
- if (cachedImage === undefined) {
- return;
- }
- backContext.drawImage(cachedImage, x, y, width, height);
- }
- function loadImageStack(imageStack, width = 24, height = 24) {
- if(!Array.isArray(imageStack)) {
- imageStack = [imageStack];
- }
- for(let index = 0; index < imageStack.length; index++){
- imageStack[index] = loadImage(imageStack[index], width, height);
- }
- return imageStack;
- }
- function loadImage(imagePath, width = 24, height = 24) {
- if (imagePath === undefined) {
- return undefined;
- }
- if(isObject(imagePath)) {
- return undefined;
- }
- if(Array.isArray(imagePath)) {
- return loadImageStack(imagePath, width, height)[0];
- }
- imagePath = basename(imagePath, `.png`);
- imagePath = left(imagePath + `________`, 8);
- let fullPath = `${host}/GFX/${imagePath}.png`;
- if (imagePath === `________`) {
- // logFeats(`Placeholder Image: ${fullPath}`);
- return undefined;
- }
- let cachedImage = imageCache.find(img => img.src === fullPath);
- if (!cachedImage) {
- cachedImage = new Image(width, height);
- cachedImage.src = fullPath;
- cachedImage.onload = function ( ) {
- imageCache.push(cachedImage);
- logFeats(`Loaded: ${cachedImage.src}`);
- // backContext.drawImage(cachedImage, x, y, width, height); // Draw image after loading
- };
- cachedImage.onerror = function ( ) {
- logFeats(`Failed to load: ${cachedImage.src}`);
- cachedImage = undefined;
- };
- } else {
- // logFeats(`Drawing Image: ${cachedImage.src}`);
- return cachedImage;
- }
- }
- function doubleBuffer ( ) {
- frontContext.clearRect(0, 0, frontCanvas.width, frontCanvas.height);
- frontContext.drawImage(backCanvas, 0, 0);
- }
- function getColorAtPoint(x, y) {
- const imageData = backCanvas.getImageData(x, y, 1, 1); // Step 4
- const data = imageData.data;
- const rgba = `rgba(${data[0]}, ${data[1]}, ${data[2]}, ${data[3] / 255})`; // Step 5
- return rgba;
- }
- function grabColor(fg){
- if(left(fg,1) === '#'){
- fg = mid(fg,2);
- fg = sections(fg,2);
- }else if( ( left( fg, 5 ) === 'rgba(' ) && ( right( fg, 1 ) === ')' ) ){
- fg = mid(fg,6);
- fg = left(fg,len(fg)-1);
- fg = fg.replace(' ','');
- fg = fg.split(',');
- }else{
- fg = grabColor(fg);
- }
- return fg;
- }
- var TILE_WIDTH = 64;
- var TILE_HEIGHT = 32;
- var BOX_HEIGHT = 64;
- function drawIsometricBox(x, y, z,imageStack) {
- var cached = loadImageStack(imageStack, tileW, tileH);
- const screenX = (x - y) * TILE_WIDTH / 2;
- const screenY = (x + y) * TILE_HEIGHT / 2 - z * BOX_HEIGHT;
- // drawRectangle(screenX, screenY - BOX_HEIGHT, tileW, tileH,'red','black');
- // Draw top
- drawImage(cached[0], screenX, screenY - BOX_HEIGHT);
- // drawRectangle( screenX, screenY - TILE_HEIGHT / 2, tileW, tileH,'red','black');
- // Draw side
- drawImage(cached[1], screenX, screenY - TILE_HEIGHT / 2);
- // drawRectangle( screenX - TILE_WIDTH / 2, screenY, tileW, tileH,'red','black');
- // Draw front
- drawImage(cached[2], screenX - TILE_WIDTH / 2, screenY);
- }
- function drawScene ( ) {
- // backContext.clearRect(0, 0, frontCanvas.width, frontCanvas.height);
- // Draw a grid of boxes for demonstration
- for (let x = 0; x < 5; x++) {
- for (let y = 0; y < 5; y++) {
- drawIsometricBox ( x, y, 1, [`wall____`,`wall____`,`wall____`]);
- }
- }
- }
- // drawScene ( );
- function createViewPortal (id) {
- id = id || `viewportal`;
- var newElement;
- const fragment = document.createDocumentFragment ( );
- for( let y = viewConstraints.viewMinY; y <= viewConstraints.viewMaxY; y++ ){
- for( let x = viewConstraints.viewMinX; x <= viewConstraints.viewMaxX; x++ ){
- let z = layers.gui;
- // logFeats(`z: ${z}`);
- newElement = document.createElement('div');
- newElement.style.width = `${tileW}px`;
- newElement.style.height = `${tileH}px`;
- newElement.style.position = `absolute`;
- newElement.style.left = `calc( 8px + ${tileW}px * (${x} + 3))`;
- newElement.style.top = `calc( 8px + ${tileH}px * (${y} + 3))`;
- newElement.className = `${id}`;
- newElement.id = `${id}_${x}_${y}_${z}`;
- newElement.style.zIndex = `${z}`;
- fragment.appendChild(newElement);
- }
- }
- document.body.appendChild(fragment);
- }
- function createGui ( ){
- createViewPortal ('viewportal');
- }
- function idParts(id){
- var parts = [];
- var rawParts = id.split(`_`);
- parts['id'] = rawParts[0];
- parts['x'] = rawParts[1];
- parts['y'] = rawParts[2];
- parts['z'] = rawParts[3];
- return parts;
- }
- function actionsList(px, py, z, crit, actionRoster) {
- actionRoster = actionRoster || [];
- if (Array.isArray(actionRoster)) {
- actionRoster = actionRoster.join(``);
- }
- z = z || layers.critter;
- px = px || cx + viewCursor.hover.x;
- py = py || cy + viewCursor.hover.y;
- if (oobMap([px, py]) !== true) {
- return false;
- }
- if (!crit) {
- crit = inlineName(full_map[px][py][layers.critter],2);
- }
- if(invalidName(crit,2)){
- return actionRoster;
- }
- // checkAndAssignDefaultStats(px, py, z);
- actionRoster = full_entity_stats[px][py][layers.critter].stats.card.action;
- return sections(actionRoster,4);
- }
- function cloneCell ( ) {
- for (let z = 0; z <= layers.gui; z++) {
- let elementView = document.getElementById(`view_${viewCursor.hover.x}_${viewCursor.hover.y}_${z}`);
- let elementTray = document.getElementById(`tray_0_0_${z}`);
- if (elementView && elementTray) {
- elementTray.style.backgroundImage = elementView.style.backgroundImage;
- }
- }
- return true;
- }
- function refreshGui ( ) {
- // console.log(`refreshGui`);
- backbuffer ( );
- }
- function checkAndAssignDefaultStats(px, py, z) {
- if (typeof full_entity_stats[px][py][z] === 'undefined' || full_entity_stats[px][py][z] == null || typeof full_entity_stats[px][py][z].stats === 'undefined' || typeof full_entity_stats[px][py][z].stats.card === 'undefined' || typeof full_entity_stats[px][py][z].stats.card.action === 'undefined') {
- full_entity_stats[px][py][z] = ent_stats;
- }
- }
- loadMap ( );
- createGui ( );
- backbuffer ( );
- function cursorState ( layer = layers.critter) {
- let state = [
- cx + viewCursor.hover.x,
- cy + viewCursor.hover.y
- ]
- let [ x, y ] = state;
- if(oobMap(state) !== true) {
- [x, y] = oobMap(state);
- }
- return [x,y,layer];
- }
- function backbuffer ( ) {
- var [ px, py, pz ] = cursorState ( layers.gui );
- canvasViewPortal ( );
- canvasScrollBars ( );
- canvasPurseTray ( );
- // drawScene ( );
- doubleBuffer ( );
- }
- var imageCache = [];
- var missingCache = [];
- var frontCanvas = false;
- var frontContext = false;
- var backCanvas = false
- var backContext = false;
- makeCanvas ( );
- function makeCanvas ( ) {
- //document.addEventListener("DOMContentLoaded", ( ) => {
- let fragment;
- // Create an on-screen canvas
- fragment = document.createDocumentFragment ( );
- frontCanvas = document.createElement('canvas');
- fragment.appendChild(frontCanvas);
- frontCanvas.style.zIndex = -1;
- frontCanvas.width = 320;
- frontCanvas.height = 240;
- frontCanvas.style.width = `320px`;
- frontCanvas.style.height = `240px`;
- frontCanvas.id = `frontCanvas`;
- frontContext = frontCanvas.getContext('2d');
- frontContext.width = 320;
- frontContext.height = 200;
- // Create an off-screen canvas
- backCanvas = document.createElement('canvas');
- fragment.appendChild(backCanvas);
- // Append all changes at once to reduce reflows
- document.body.appendChild(fragment);
- backCanvas.style.width = frontCanvas.style.width;
- backCanvas.style.height = frontCanvas.style.height;
- backCanvas.width = frontCanvas.width;
- backCanvas.height = frontCanvas.height;
- backContext.width = frontContext.width;
- backContext.height = frontContext.height;
- backCanvas.style.zIndex = -2;
- backCanvas.style.visibility = 'hidden';
- backCanvas.id = `backCanvas`;
- backContext = backCanvas.getContext('2d');
- }
- function selectCanvas(id){
- workCanvas = document.getElementById(id);
- }
- function drawRectangle(x, y, width, height, color = 'black',fill = 'gray'){
- backContext.strokeStyle = color;
- if(fill === ''){
- fill = 'rgba(0,0,0,0.0)';
- }
- backContext.fillStyle = fill;
- backContext.fillRect(x, y, width, height);
- backContext.strokeRect(x, y, width, height);
- }
- function drawLine(x,y,x2,y2,color = 'black',width = 5){
- backContext.strokeStyle = color;
- backContext.lineWidth = width;
- backContext.beginPath ( );
- backContext.moveTo(x, y);
- backContext.lineTo(x2, y2);
- backContext.stroke ( );
- }
- function drawCircle(x,y,radius = 50, color = 'black',fill = '#00FF00', width = 5){
- backContext.beginPath ( );
- backContext.arc(x, y, radius, 0, 2 * Math.PI);
- backContext.fillStyle = '#00FF00';
- backContext.fill ( );
- backContext.strokeStyle = '#000000';
- backContext.lineWidth = width;
- backContext.stroke ( );
- }
- function drawText(x,y,font = '30px Arial',fill = '#000000',text = 'Hello backcanvas!'){
- backContext.font = font;
- backContext.fillStyle = fill;
- backContext.fillText(text, x, y);
- }
- function drawImageStack(imageStack, x, y, width = 24, height = 24) {
- // console.log({imageStack: imageStack});
- for(index = 0; index < imageStack.length; index++){
- if( imageStack[index] === undefined ){
- continue;
- }
- imageStack[index] = basename(imageStack[index],`.png`);
- imageStack[index] = left( imageStack[index] + `________`, 8 );
- // console.log(imageStack[index]);
- drawImage( imageStack[index], x, y, width, height );
- }
- if(DEBUG.GUI){
- if( index > 0 ){
- // drawImage(`dooropen`, x, y, width, height);
- // drawRectangle(x, y, width, height, 'rgba(255,0,0,0.7)','');
- // drawText(x,y+16,'12px Impact', 'rgba(255,0,0,0.7)','TEST');
- }
- }
- }
- function drawImage(imagePath, x, y, width = 24, height = 24) {
- var cachedImage = loadImage(imagePath);
- if (cachedImage === undefined) {
- return;
- }
- backContext.drawImage(cachedImage, x, y, width, height);
- }
- function loadImageStack(imageStack, width = 24, height = 24) {
- if(!Array.isArray(imageStack)) {
- imageStack = [imageStack];
- }
- for(let index = 0; index < imageStack.length; index++){
- imageStack[index] = loadImage(imageStack[index], width, height);
- }
- return imageStack;
- }
- function loadImage(imagePath, width = 24, height = 24) {
- if (imagePath === undefined) {
- return undefined;
- }
- if(isObject(imagePath)) {
- return undefined;
- }
- if(Array.isArray(imagePath)) {
- return loadImageStack(imagePath, width, height)[0];
- }
- imagePath = basename(imagePath, `.png`);
- imagePath = left(imagePath + `________`, 8);
- let fullPath = `${host}/GFX/${imagePath}.png`;
- if (imagePath === `________`) {
- // logFeats(`Placeholder Image: ${fullPath}`);
- return undefined;
- }
- let cachedImage = imageCache.find(img => img.src === fullPath);
- if (!cachedImage) {
- cachedImage = new Image(width, height);
- cachedImage.src = fullPath;
- cachedImage.onload = function ( ) {
- imageCache.push(cachedImage);
- logFeats(`Loaded: ${cachedImage.src}`);
- // backContext.drawImage(cachedImage, x, y, width, height); // Draw image after loading
- };
- cachedImage.onerror = function ( ) {
- logFeats(`Failed to load: ${cachedImage.src}`);
- cachedImage = undefined;
- };
- } else {
- // logFeats(`Drawing Image: ${cachedImage.src}`);
- return cachedImage;
- }
- }
- function doubleBuffer ( ) {
- frontContext.clearRect(0, 0, frontCanvas.width, frontCanvas.height);
- frontContext.drawImage(backCanvas, 0, 0);
- }
- function getColorAtPoint(x, y) {
- const imageData = backCanvas.getImageData(x, y, 1, 1); // Step 4
- const data = imageData.data;
- const rgba = `rgba(${data[0]}, ${data[1]}, ${data[2]}, ${data[3] / 255})`; // Step 5
- return rgba;
- }
- function grabColor(fg){
- if(left(fg,1) === '#'){
- fg = mid(fg,2);
- fg = sections(fg,2);
- }else if( ( left( fg, 5 ) === 'rgba(' ) && ( right( fg, 1 ) === ')' ) ){
- fg = mid(fg,6);
- fg = left(fg,len(fg)-1);
- fg = fg.replace(' ','');
- fg = fg.split(',');
- }else{
- fg = grabColor(fg);
- }
- return fg;
- }
- var TILE_WIDTH = 64;
- var TILE_HEIGHT = 32;
- var BOX_HEIGHT = 64;
- function drawIsometricBox(x, y, z,imageStack) {
- var cached = loadImageStack(imageStack, tileW, tileH);
- const screenX = (x - y) * TILE_WIDTH / 2;
- const screenY = (x + y) * TILE_HEIGHT / 2 - z * BOX_HEIGHT;
- // drawRectangle(screenX, screenY - BOX_HEIGHT, tileW, tileH,'red','black');
- // Draw top
- drawImage(cached[0], screenX, screenY - BOX_HEIGHT);
- // drawRectangle( screenX, screenY - TILE_HEIGHT / 2, tileW, tileH,'red','black');
- // Draw side
- drawImage(cached[1], screenX, screenY - TILE_HEIGHT / 2);
- // drawRectangle( screenX - TILE_WIDTH / 2, screenY, tileW, tileH,'red','black');
- // Draw front
- drawImage(cached[2], screenX - TILE_WIDTH / 2, screenY);
- }
- function drawScene ( ) {
- // backContext.clearRect(0, 0, frontCanvas.width, frontCanvas.height);
- // Draw a grid of boxes for demonstration
- for (let x = 0; x < 5; x++) {
- for (let y = 0; y < 5; y++) {
- drawIsometricBox ( x, y, 1, [`wall____`,`wall____`,`wall____`]);
- }
- }
- }
- // drawScene ( );
- function canvasPurseTray ( ) {
- var purseSpanX = 5;
- var purseSpanY = 6;
- var ent_stats = [];
- var [ px, py, pz ] = cursorState ( layers.critter );
- var xOffset = viewSpanX * tileW;
- drawRectangle(xOffset+gutterW*2, gutterH, purseSpanX * tileW, purseSpanY * tileH, 'black', 'black');
- var ss = [];
- ent_stats.stats = default_entity_stats[full_map[px][py][pz]].stats;
- ss.push(ent_stats.stats);
- ss.card = {};
- ss.card.namesake = `Placeholder`;
- ss.card.actionRoster = [];
- switch(true){
- case (oobMap([px,py]) !== true):
- ss.push(ent_stats.stats);
- ss.card.namesake = `Out Of Bounds`;
- ss.card.actionRoster = [];
- break;
- case (invalidName(full_map[px][py][layers.critter],2)):
- ss.push(ent_stats.stats);
- ss.card.namesake = `Placeholder`;
- ss.card.actionRoster = [];
- break;
- case (oobMap([px,py]) === true):
- ss.push(full_entity_stats[px][py][layers.critter].stats);
- ss.card.namesake = ss.card.namesake;
- ss.card.actionRoster = sections(ss.card.action,4);
- break;
- }
- let buffer = [];
- for(let y = purseConstraints.viewMinY; y <= purseConstraints.viewMaxY; y++){
- for(let x = purseConstraints.viewMinX; x <= purseConstraints.viewMaxX; x++){
- buffer = [];
- if(y === 3){
- let z = x;
- if((z >= 0) && (z < layers.gui)){
- if(oobMap([px,py]) === true){
- buffer.push(
- full_map[px][py][z]
- );
- }
- }
- }
- let x1 = 0;
- let purseSpanX = 5;
- let y1 = 4;
- let purseSpanY = 3;
- if((x >= x1) && (x < x1 + purseSpanX) && (y >= y1) && (y < y1 + purseSpanY)){
- let i = (x - x1) + (y - y1) * purseSpanX;
- if((i >= 0) && (i < ss.card.actionRoster.length)){
- buffer.push( ss.card.actionRoster[i] );
- }
- }
- buffer.push(`sel2dots`);
- drawImageStack(buffer,xOffset+
- gutterW * 2 + x * tileW,gutterH + y * tileH,tileW,tileH);
- }
- }
- ss.card.namesake = ucwords(ss.card.namesake);
- switch(true){
- case (ucwords(ss.card.namesake) === "Placeholder"):
- case (ucwords(ss.card.namesake) === "Out Of Bounds"):
- break;
- default:
- renderStats(px,py,z);
- drawText(gutterW + 0 * tileW, gutterH + 8 + 12,'16px Impact','white','" ' + ss.card.namesake + ' "');
- break;
- }
- return true;
- }
- function renderStatBar(x,y,width,height,caption,font,fg,bg){
- drawRectangle( x, y, width, height, 'black', bg );
- drawText( x, y, `${height}px ${font}`, fg, caption );
- }
- function renderStats(px,py,z){
- var [ px, py, pz ] = cursorState ( layers.critter );
- var gutterW = viewSpanX * tileW + 16;
- z = z || pz;
- let s = [];
- let pct = [];
- s['health'] = full_entity_stats[px][py][layers.critter].stats.health;
- s['stamina'] = full_entity_stats[px][py][layers.critter].stats.stamina;
- s['essence'] = full_entity_stats[px][py][layers.critter].stats.essence;
- renderStatusBar( s, 'health', tileW * viewSpanX + 16, 8 + 16 * 0, tileW * purseSpanX, 12, 'black', 'red' );
- renderStatusBar( s, 'stamina', tileW * viewSpanX + 16, 8 + 16 * 1, tileW * purseSpanX, 12, 'black', 'yellow' );
- renderStatusBar( s, 'essence', tileW * viewSpanX + 16, 8 + 16 * 2, tileW * purseSpanX, 12, 'black', 'cyan' );
- }
- function renderStatusBar(stat, attrName, gutterW, gutterH, width, height, fg, bg ) {
- var [ px, py, pz ] = cursorState ( );
- let s = stat[attrName];
- let pct = [];
- let w = [];
- s.minimum = s.minimum || 0;
- s.maximum = s.maximum || 1;
- s.current = s.current || 0;
- s.recovery = s.recovery || 0;
- pct['current'] = Math.round(100 * s.current / s.maximum);
- pct['minimum'] = Math.round(100 * s.minimum / s.maximum);
- pct['maximum'] = Math.round(100 * s.maximum / s.maximum);
- pct['recovery'] = Math.round(100 * (s.current + s.recovery) / s.maximum);
- let x = gutterW;
- let y = gutterH+24;
- // s.current, s.recovery
- // s.minimum, s.maximum
- let caption = `${attrName}: ${s.current} / ${s.maximum}`;
- let font = 'Small Fonts';
- // fg, bg
- w['current'] = width * curve(pct['current']) / 100;
- w['recovery'] = width * curve(pct['recovery']) / 100;
- w['minimum'] = 0;
- w['maximum'] = width * curve(1.0) / 100;
- drawRectangle( x, y, w['maximum'], height, 'black', 'gray' );
- drawRectangle( x, y + 4, w['current'], height - 4, 'black', bg );
- drawRectangle( x, y, w['recovery'], height - 4, 'rgba(0,0,0,0.0)', 'rgba(255,255,255,0.7)' );
- drawRectangle( x, y, width, height, 'black', 'rgba(0,0,0,0.0)' );
- drawText( x, y + 8, `${height*0.8}px ${font}`, 'black', caption );
- }
- function canvasViewPortal ( ){
- var [ px, py, pz ] = cursorState ( layers.gui );
- drawRectangle(gutterW, gutterH, viewConstraints.viewSpanX * tileW, viewConstraints.viewSpanY * tileH, 'black', 'black');
- let buffer = [];
- for(let y = viewConstraints.viewMinY; y <= viewConstraints.viewMaxY; y++){
- for(let x = viewConstraints.viewMinX; x <= viewConstraints.viewMaxX; x++){
- buffer = [];
- px = cx + x;
- py = cy + y;
- if(oobMap([px,py]) !== true){
- buffer.push(special.stonwall);
- }
- if(oobMap([px,py]) === true){
- for(let z = 0; z <= pz; z++){
- buffer.push(`${sections(full_map[px][py][z])[0]}____`);
- }
- if( ( x === 0 ) && ( y === 0 ) ){
- buffer.push(special.sel1dash);
- }
- }
- // logFeats(hover);
- if( ( x === viewCursor.hover.x ) && ( y === viewCursor.hover.y ) ){
- buffer.push(special.sel2dash);
- }
- buffer.push(special.sel2dots);
- drawImageStack(buffer,gutterW+(x - viewConstraints.viewMinX)*tileW,gutterH+(y - viewConstraints.viewMinY)*tileH,tileW,tileH);
- }
- }
- return true;
- }
- function canvasScrollBars ( ) {
- var [ px, py, pz ] = cursorState ( layers.gui );
- var gutterW = 0;
- var gutterH = 0;
- let scrollX1 = ( cx - viewSpanX / 2 ) / full_map.length;
- let scrollX2 = ( cx + viewSpanX / 2 ) / full_map.length;
- let scrollY1 = ( cy - viewSpanY / 2 ) / full_map[0].length;
- let scrollY2 = ( cy + viewSpanY / 2 ) / full_map[0].length;
- scrollX1 = viewSpanX * tileW * scrollX1;
- scrollX2 = viewSpanX * tileW * scrollX2;
- scrollY1 = viewSpanY * tileH * scrollY1;
- scrollY2 = viewSpanY * tileH * scrollY2;
- if( scrollX1 < 0 ){
- scrollX1 = 0;
- }
- if( scrollY1 < 0 ){
- scrollY1 = 0;
- }
- if( scrollX1 > viewSpanX * tileW ){
- scrollX1 = viewSpanX * tileW;
- }
- if( scrollY1 > viewSpanY * tileH ){
- scrollY1 = viewSpanY * tileH;
- }
- if( scrollX2 < 0 ){
- scrollX2 = 0;
- }
- if( scrollY2 < 0 ){
- scrollY2 = 0;
- }
- if( scrollX2 > viewSpanX * tileW ){
- scrollX2 = viewSpanX * tileW;
- }
- if( scrollY2 > viewSpanY * tileH ){
- scrollY2 = viewSpanY * tileH;
- }
- scrollW = scrollX2 - scrollX1;
- scrollH = scrollY2 - scrollY1;
- // left backbar
- drawRectangle(
- gutterW,
- gutterH,
- 8,
- viewSpanY*tileH,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // top backbar
- drawRectangle(
- gutterW,
- gutterH,
- viewSpanX*tileW,
- 8,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- gutterW = 0;
- gutterH = 0;
- // right backbar
- drawRectangle(
- gutterW+viewSpanX*tileW,
- gutterH,
- 8,
- viewSpanY*tileH,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // bottom backbar
- drawRectangle(
- gutterW,
- gutterH+viewSpanY*tileH,
- viewSpanX*tileW,
- 8,
- 'rgba(0,0,0,0.0)',
- 'red'
- );
- // right scrollbar
- drawRectangle(
- gutterW*2+viewSpanX*tileW,
- gutterH*2+scrollY1,
- 8,
- scrollH,
- 'black',
- '#00ff00'
- );
- // bottom scrollbar
- drawRectangle(
- gutterW*2+scrollX1,
- gutterH*2+viewSpanY*tileH,
- scrollW,
- 8,
- 'black',
- '#00ff00'
- );
- return true;
- }
- window.onmousemove = e => {
- canvasViewCursor ( { x: e.pageX, y: e.pageY } );
- }
- window.onclick = e => {
- canvasViewCursor ( { x: e.pageX, y: e.pageY } );
- [ cx, cy ] = [ cx + viewCursor.hover.x, cy + viewCursor.hover.y ];
- }
- function canvasViewCursor ( coords ) {
- viewCursor.prev.x = canvasCursor.x;
- viewCursor.prev.y = canvasCursor.y;
- viewCursor.prev.z = 4;
- // = viewCursor.hover.z;
- canvasCursor.x = coords.x;
- canvasCursor.y = coords.y;
- var viewRangeMinX = gutterW;
- var viewRangeMinY = gutterH;
- var viewRangeMaxX = gutterW + (viewConstraints.viewMaxX - viewConstraints.viewMinX + 1 ) * tileW;
- var viewRangeMaxY = gutterH + (viewConstraints.viewMaxY - viewConstraints.viewMinY + 1 ) * tileH;
- if (
- (canvasCursor.x > viewRangeMinX)
- &&
- (canvasCursor.x < viewRangeMaxX)
- &&
- (canvasCursor.y > viewRangeMinY)
- &&
- (canvasCursor.y < viewRangeMaxY)
- )
- {
- x = canvasCursor.x;
- y = canvasCursor.y;
- x -= gutterW;
- y -= gutterH;
- x /= tileW;
- y /= tileH;
- x = Math.round(x);
- y = Math.round(y);
- x += viewConstraints.viewMinX;
- y += viewConstraints.viewMinY;
- }else{
- x = 0;
- y = 0;
- }
- if (oobView([x,y]) !== true){
- [x,y] = oobView([x,y]);
- }
- [ viewCursor.hover.x, viewCursor.hover.y ] =
- [ x, y ];
- console.log({x: x, y: y});
- return;
- }
- /*
- function handleViewPortalHover(event) {
- viewCursor.prev.x = viewCursor.hover.x;
- viewCursor.prev.y = viewCursor.hover.y;
- viewCursor.prev.z = viewCursor.hover.z;
- const hoverId = event.target.id;
- const parts = idParts(hoverId);
- viewCursor.hover.x = parts.x;
- viewCursor.hover.y = parts.y;
- viewCursor.hover.z = parts.z;
- // refreshGui ( );
- }
- function handleViewPortalClick(event) {
- const clickedId = event.target.id;
- const parts = idParts(clickedId);
- const id = parts.id;
- const x = parts.x;
- const y = parts.y;
- const z = parts.z;
- if (oobMap([cx + x, cy + y]) === true) {
- cx += x;
- cy += y;
- }
- }
- function attachListeners(id) {
- const elements = document.querySelectorAll(`.${id}`);
- elements.forEach(element => {
- switch (id) {
- case 'viewportal':
- element.addEventListener('mousemove', handleViewPortalHover);
- element.addEventListener('mouseover', handleViewPortalHover);
- element.addEventListener('click', handleViewPortalClick);
- break;
- case 'trayportal':
- element.addEventListener('mousemove', handleTrayPortalHover);
- element.addEventListener('mouseover', handleTrayPortalHover);
- element.addEventListener('click', handleTrayPortalClick);
- break;
- }
- });
- }
- function linkGui ( ) {
- // console.log('linkGui');
- attachListeners('viewportal');
- // attachListeners('trayportal');
- // attachListeners('viewframe');
- // attachListeners('trayframe');
- }
- */
- const turnIntervalId = setInterval(takeTurns, 50);
- const refreshIntervalId = setInterval(refreshGui, 50);
- // const cursorIntervalId = setInterval(canvasViewCursor, 50);
- // linkGui ( );
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment