Complete interactive front-end overlay. Add back-end extra data

main
sigonasr2 3 years ago
parent ddcfdb5d76
commit 4924eb3649
  1. 52
      src/App.css
  2. 81
      src/App.css.bak
  3. 132
      src/App.js
  4. 133
      src/App.js.bak
  5. BIN
      src/ProFontWindows-Bold.ttf
  6. 49
      src/backend/data.json
  7. 17
      src/backend/logreader.js
  8. 31
      src/backend/logreader.js.bak
  9. 6
      src/bootstrap.css
  10. 10837
      src/bootstrap.css.bak
  11. 9
      src/index.css
  12. 18
      src/index.css.bak
  13. BIN
      src/layout.png

@ -1,3 +1,55 @@
@font-face {
font-family: ProFontWindows;
src: url('./ProFontWindows-Bold.ttf');
}
.dot {
background-color:rgba(0,0,0,0.0);
border:4px solid rgba(150,255,150,1);
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width:56px;
height:56px;
}
.smoldotgreen {
background-color:rgba(0,0,0,0.0);
border:4px solid rgba(150,255,150,0.8);
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width:48px;
height:52px;
}
.smoldot {
background-color:rgba(0,0,0,0.0);
border:4px solid rgba(255,150,150,0.8);
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width:48px;
height:52px;
}
.right{
margin: auto;
position: absolute;
text-align:right;
}
.floating{
position:absolute;
}
.current{
color: #fff !important;
text-shadow: 0 0 4px #438992,0 0 8px #438992,0 0 12px #438992, 0 0 16px #fff,0 0 20px #438992;
}
.alltime{
color: #fff !important;
text-shadow: 0 0 4px #812c58,0 0 8px #812c58,0 0 12px #812c58, 0 0 16px #fff,0 0 20px #812c58;
}
.App {
text-align: center;
}

@ -0,0 +1,81 @@
@font-face {
font-family: ProFontWindows;
src: url('./ProFontWindows-Bold.ttf');
}
.dot {
background-color:rgba(0,0,0,0.0);
border:4px solid rgba(150,255,150,1);
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width:56px;
height:56px;
}
.smoldot {
background-color:rgba(0,0,0,0.0);
border:4px solid rgba(255,150,150,0.8);
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width:48px;
height:52px;
}
.right{
margin: auto;
position: absolute;
text-align:right;
}
.floating{
position:absolute;
}
.current{
color: #fff !important;
text-shadow: 0 0 4px #438992,0 0 8px #438992,0 0 12px #438992, 0 0 16px #fff,0 0 20px #438992;
}
.alltime{
color: #fff !important;
text-shadow: 0 0 4px #812c58,0 0 8px #812c58,0 0 12px #812c58, 0 0 16px #fff,0 0 20px #812c58;
}
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@ -2,21 +2,129 @@
import logo from './logo.svg';
import './App.css';
import './bootstrap.css';
import {useState,useEffect} from 'react'
function FormatFloor(numb) {
while (String(numb).length<3) {
numb = "0"+numb
}
return numb
}
function CenterAlignAdjust(str,size) {
return Math.round((String(str).length/2)*(size/2.1))
}
function App() {
var pomanderCount = [0,0,0,0,0,0,5,3,0,0,0,0,0,0,0,0];
useEffect(()=>{
const interval = setInterval(()=>{
fetch("http://localhost:4600")
.then((resp)=>{
return resp.json()
})
.then((data)=>{
setData(data)
})
},1000)
return ()=>clearInterval(interval)
},[])
const [data,setData] = useState(undefined)
function NameMatches(i) {
for (var key of Object.keys(data.floor_storage)) {
if ((key==="safety"&&i===0)||
(key==="sight"&&i===1)||
(key==="strength"&&i===2)||
(key==="steel"&&i===3)||
(key==="affluence"&&i===4)||
(key==="flight"&&i===5)||
(key==="alteration"&&i===6)||
(key==="purity"&&i===7)||
(key==="fortune"&&i===8)||
(key==="witching"&&i===9)||
(key==="serenity"&&i===10)||
(key==="rage"&&i===11)||
(key==="lust"&&i===12)||
(key==="intuition"&&i===13)||
(key==="raising"&&i===14)||
(key==="resolution"&&i===15)) {
return true
}
}
return false
}
return (
<>
<div class="container">
{[0,1,2].map((count)=>
<div class="row">{
[0+count*6,1+count*6,2+count*6,3+count*6,4+count*6,5+count*6].map((num)=>
<div class="col">
{pomanderCount[num]}
</div>
)}
</div>)
}
</div>
<img src="./layout.png"/>
{data&&<>
<div className="floating" style={{left:403,top:40,fontSize:42,color:"rgb(219,209,200)"}}>
{FormatFloor(data.floor)}</div>
{
data.pomander.map((pom,i)=>{
return <>
{NameMatches(i)&&<div className="floating dot" style={{left:50+(i%6)*64,top:88+Math.floor(i/6)*64,fontSize:24}}/>}
<div className="floating current" style={{left:48+(i%6)*64,top:80+Math.floor(i/6)*64,fontSize:24}}>
{pom[1]}</div>
<div className="floating alltime" style={{left:48+(i%6)*64,top:104+Math.floor(i/6)*64,fontSize:24}}>
{pom[2]}</div>
<div className="floating" style={{left:82+(i%6)*64,top:120+Math.floor(i/6)*64,fontSize:24,color:pom[0]!==0?"white":"gray"}}>
x{pom[0]}</div></>
})
}
{
data.accursed_hoard.map((acc,i)=>{
return <>
<div className="floating current" style={{left:342+(i%2)*76,top:210+Math.floor(i/2)*32,fontSize:16}}>
{acc[0]}</div>
<div className="floating alltime" style={{left:342+(i%2)*76,top:224+Math.floor(i/2)*32,fontSize:16}}>
{acc[1]}</div></>
})
}
{
data.mimics.map((mm,i)=>{
return <>
<div className={"floating "+(i===0?"current":"alltime")} style={{left:342+i*99-CenterAlignAdjust(mm,28),top:286,fontSize:28}}>
{mm}</div>
</>
})
}
{
data.traps.map((trap,i)=>{
return (i<=2)?
<>
<div className="floating current" style={{left:90+i*122,top:336,fontSize:24}}>
{trap[0]}</div>
<div className="floating alltime" style={{left:90+i*122,top:368,fontSize:24}}>
{trap[1]}</div></>
:
<>
<div className="floating current" style={{left:142+(i-3)*122,top:408,fontSize:24}}>
{trap[0]}</div>
<div className="floating alltime" style={{left:142+(i-3)*122,top:440,fontSize:24}}>
{trap[1]}</div></>
})
}
<div className="floating current" style={{left:345-CenterAlignAdjust(data.death_count[0],32),top:416,fontSize:32}}>
{data.death_count[0]}</div>
<div className="floating alltime" style={{left:422-CenterAlignAdjust(data.death_count[0],32),top:464,fontSize:32}}>
{data.death_count[0]}</div>
{
data.floor_effects.map((eff,i)=>{
return <>
{i in data.floor_buff_storage&&<div className={"floating "+((i<=1)?"smoldotgreen":"smoldot")} style={{left:48+Math.floor(i/3)*96,top:528+(i%3)*48+((i<=1)?-4:0),fontSize:16}}/>}
<div className="floating current" style={{left:96+Math.floor(i/3)*96,top:534+(i%3)*48,fontSize:16}}>
{eff[0]}</div>
<div className="floating alltime" style={{left:96+Math.floor(i/3)*96,top:554+(i%3)*48,fontSize:16}}>
{eff[1]}</div></>
})
}
</>
}
</>
);
}

@ -2,22 +2,129 @@
import logo from './logo.svg';
import './App.css';
import './bootstrap.css';
Tail = require('tail').Tail;
import {useState,useEffect} from 'react'
function FormatFloor(numb) {
while (String(numb).length<3) {
numb = "0"+numb
}
return numb
}
function CenterAlignAdjust(str,size) {
return Math.round((String(str).length/2)*(size/2.1))
}
function App() {
var pomanderCount = [0,0,0,0,0,0,5,3,0,0,0,0,0,0,0,0];
useEffect(()=>{
const interval = setInterval(()=>{
fetch("http://localhost:4600")
.then((resp)=>{
return resp.json()
})
.then((data)=>{
setData(data)
})
},1000)
return ()=>clearInterval(interval)
},[])
const [data,setData] = useState(undefined)
function NameMatches(i) {
for (var key of Object.keys(data.floor_storage)) {
if (key==="safety"&&i===0||
key==="sight"&&i===1||
key==="strength"&&i===2||
key==="steel"&&i===3||
key==="affluence"&&i===4||
key==="flight"&&i===5||
key==="alteration"&&i===6||
key==="purity"&&i===7||
key==="fortune"&&i===8||
key==="witching"&&i===9||
key==="serenity"&&i===10||
key==="rage"&&i===11||
key==="lust"&&i===12||
key==="intuition"&&i===13||
key==="raising"&&i===14||
key==="resolution"&&i===15) {
return true
}
}
return false
}
return (
<>
<div class="container">
{[0,1,2].map((count)=>
<div class="row">{
[0+count*6,1+count*6,2+count*6,3+count*6,4+count*6,5+count*6].map((num)=>
<div class="col">
{pomanderCount[num]}
</div>
)}
</div>)
}
</div>
<img src="./layout.png"/>
{data&&<>
<div className="floating" style={{left:403,top:40,fontSize:42,color:"rgb(219,209,200)"}}>
{FormatFloor(data.floor)}</div>
{
data.pomander.map((pom,i)=>{
return <>
{NameMatches(i)&&<div className="floating dot" style={{left:50+(i%6)*64,top:88+Math.floor(i/6)*64,fontSize:24}}/>}
<div className="floating current" style={{left:48+(i%6)*64,top:80+Math.floor(i/6)*64,fontSize:24}}>
{pom[1]}</div>
<div className="floating alltime" style={{left:48+(i%6)*64,top:104+Math.floor(i/6)*64,fontSize:24}}>
{pom[2]}</div>
<div className="floating" style={{left:82+(i%6)*64,top:120+Math.floor(i/6)*64,fontSize:24,color:pom[0]!==0?"white":"gray"}}>
x{pom[0]}</div></>
})
}
{
data.accursed_hoard.map((acc,i)=>{
return <>
<div className="floating current" style={{left:342+(i%2)*76,top:210+Math.floor(i/2)*32,fontSize:16}}>
{acc[0]}</div>
<div className="floating alltime" style={{left:342+(i%2)*76,top:224+Math.floor(i/2)*32,fontSize:16}}>
{acc[1]}</div></>
})
}
{
data.mimics.map((mm,i)=>{
return <>
<div className={"floating "+(i===0?"current":"alltime")} style={{left:342+i*99-CenterAlignAdjust(mm,28),top:286,fontSize:28}}>
{mm}</div>
</>
})
}
{
data.traps.map((trap,i)=>{
return (i<=2)?
<>
<div className="floating current" style={{left:90+i*122,top:336,fontSize:24}}>
{trap[0]}</div>
<div className="floating alltime" style={{left:90+i*122,top:368,fontSize:24}}>
{trap[1]}</div></>
:
<>
<div className="floating current" style={{left:142+(i-3)*122,top:408,fontSize:24}}>
{trap[0]}</div>
<div className="floating alltime" style={{left:142+(i-3)*122,top:440,fontSize:24}}>
{trap[1]}</div></>
})
}
<div className="floating current" style={{left:345-CenterAlignAdjust(data.death_count[0],32),top:416,fontSize:32}}>
{data.death_count[0]}</div>
<div className="floating alltime" style={{left:422-CenterAlignAdjust(data.death_count[0],32),top:464,fontSize:32}}>
{data.death_count[0]}</div>
{
data.floor_effects.map((eff,i)=>{
return <>
{i in data.floor_buff_storage&&<div className={"floating "+((i<=1)?"smoldotgreen":"smoldot")} style={{left:48+Math.floor(i/3)*96,top:528+(i%3)*48+((i<=1)?-4:0),fontSize:16}}/>}
<div className="floating current" style={{left:96+Math.floor(i/3)*96,top:534+(i%3)*48,fontSize:16}}>
{eff[0]}</div>
<div className="floating alltime" style={{left:96+Math.floor(i/3)*96,top:554+(i%3)*48,fontSize:16}}>
{eff[1]}</div></>
})
}
</>
}
</>
);
}

Binary file not shown.

@ -47,8 +47,8 @@
],
[
0,
1,
1
4,
4
],
[
0,
@ -61,9 +61,9 @@
0
],
[
0,
5,
5
9,
19,
19
],
[
0,
@ -72,8 +72,8 @@
],
[
0,
1,
1
4,
4
],
[
0,
@ -83,8 +83,8 @@
],
"accursed_hoard": [
[
0,
1
2,
3
],
[
0,
@ -100,8 +100,8 @@
]
],
"mimics": [
0,
0
20,
3
],
"traps": [
[
@ -113,16 +113,16 @@
0
],
[
0,
1
3,
4
],
[
0,
0
],
[
0,
1
3,
4
]
],
"floor_effects": [
@ -163,8 +163,8 @@
0
],
[
0,
1
2,
3
],
[
0,
@ -172,11 +172,16 @@
]
],
"death_count": [
1,
2
4,
6
],
"floor": 0,
"floor": 13,
"accursed_hoard_detected": false,
"previous_pomander": "",
"floor_storage": {}
"previous_pomander": "lust",
"floor_storage": {
"lust": 1
},
"floor_buff_storage": {
"9": true
}
}

@ -96,6 +96,7 @@ var options = {
var previous_pomander=""
var floor_storage={}
var floor_buff_storage={}
var update_file=false;
tail = new Tail(process.argv[2], options);
@ -114,6 +115,7 @@ if (fs.existsSync('./data.json')) {
accursed_hoard_detected=master_obj.accursed_hoard_detected
previous_pomander=master_obj.previous_pomander
floor_storage=master_obj.floor_storage
floor_buff_storage=master_obj.floor_buff_storage
}
@ -139,6 +141,7 @@ function CreateMasterObj() {
accursed_hoard_detected:accursed_hoard_detected,
previous_pomander:previous_pomander,
floor_storage:floor_storage,
floor_buff_storage:floor_buff_storage,
}
}
@ -179,6 +182,7 @@ function ParseString(str) {
floor=Number(fl)
previous_pomander=""
floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false
update_file=true
} else
@ -188,6 +192,7 @@ function ParseString(str) {
floor=Number(fl)
previous_pomander=""
floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false
update_file=true
} else
@ -197,6 +202,7 @@ function ParseString(str) {
floor=0
previous_pomander=""
floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false
for (var i=0;i<pomander.length;i++) {
pomander[i][0]=0
@ -286,56 +292,67 @@ function ParseString(str) {
if (split[4].includes("An ancient enchantment stimulates your humours, increasing the speed with which you act.")) {
floor_effects[0][0]++
floor_effects[0][1]++
floor_buff_storage={0:true}
update_file=true
} else
if (split[4].includes("An ancient enchantment revitalizes your body and mind.")) {
floor_effects[1][0]++
floor_effects[1][1]++
floor_buff_storage={1:true}
update_file=true
} else
if (split[4].includes("The gathering gloom appears to invigorate the floor's denizens.")) {
floor_effects[2][0]++
floor_effects[2][1]++
floor_buff_storage={2:true}
update_file=true
} else
if (split[4].includes("An ancient enchantment clouds your eyes, making it difficult to discern your quarry.")) {
floor_effects[3][0]++
floor_effects[3][1]++
floor_buff_storage={3:true}
update_file=true
} else
if (split[4].includes("The items in your bag have temporarily transformed into worthless stone.")) {
floor_effects[4][0]++
floor_effects[4][1]++
floor_buff_storage={4:true}
update_file=true
} else
if (split[4].includes("An ancient enchantment clouds your mind, making it impossible to remember previously learned abilities.")) {
floor_effects[5][0]++
floor_effects[5][1]++
floor_buff_storage={5:true}
update_file=true
} else
if (split[4].includes("An ancient enchantment saps your health.")) {
floor_effects[6][0]++
floor_effects[6][1]++
floor_buff_storage={6:true}
update_file=true
} else
if (split[4].includes("An ancient enchantment saps your very strength, weakening your blows.")) {
floor_effects[7][0]++
floor_effects[7][1]++
floor_buff_storage={7:true}
update_file=true
} else
if (split[4].includes("Your body is fatigued and wounds refuse to heal on their own.")) {
floor_effects[8][0]++
floor_effects[8][1]++
floor_buff_storage={8:true}
update_file=true
} else
if (split[4].includes("Your entire body feels heavy.")) {
floor_effects[9][0]++
floor_effects[9][1]++
floor_buff_storage={9:true}
update_file=true
} else
if (split[4].includes("You find yourself short of breath, unable to sprint.")) {
floor_effects[10][0]++
floor_effects[10][1]++
floor_buff_storage={10:true}
update_file=true
}

@ -127,6 +127,21 @@ function GetPomanderSlot(str) {
return -1
}
function CreateMasterObj() {
return {
pomander:pomander,
accursed_hoard:accursed_hoard,
mimics:mimics,
traps:traps,
floor_effects:floor_effects,
death_count:death_count,
floor:floor,
accursed_hoard_detected:accursed_hoard_detected,
previous_pomander:previous_pomander,
floor_storage:floor_storage,
}
}
function ParseString(str) {
var split = str.split("|")
if (split.length===6) {
@ -326,18 +341,7 @@ function ParseString(str) {
if (update_file) {
update_file=false
var master_obj = {
pomander:pomander,
accursed_hoard:accursed_hoard,
mimics:mimics,
traps:traps,
floor_effects:floor_effects,
death_count:death_count,
floor:floor,
accursed_hoard_detected:accursed_hoard_detected,
previous_pomander:previous_pomander,
floor_storage:floor_storage,
}
var master_obj = CreateMasterObj()
fs.writeFileSync('./data.json', JSON.stringify(master_obj, null, 2) , 'utf-8');
}
}
@ -354,5 +358,6 @@ tail.on("error", function(error) {
app.get('/',async(req,res)=>{
res.status(200).send('Hello World')
var master_obj = CreateMasterObj()
res.status(200).json(master_obj)
})

6
src/bootstrap.css vendored

@ -1,3 +1,9 @@
@font-face {
font-family: ProFontWindows;
src: url('./ProFontWindows-Bold.ttf');
}
@charset "UTF-8";
/*!
* Bootstrap v5.0.2 (https://getbootstrap.com/)

File diff suppressed because it is too large Load Diff

@ -1,8 +1,13 @@
@font-face {
font-family: ProFontWindows;
src: url('./ProFontWindows-Bold.ttf');
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
font-family: ProFontWindows,-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
sans-serif !important;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

@ -0,0 +1,18 @@
@font-face {
font-family: ProFontWindows;
src: url('./ProFontWindows-Bold.ttf');
}
body {
margin: 0;
font-family: ProFontWindows,-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif; !important
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Loading…
Cancel
Save