Fix bugs with detectrion

main
sigonasr2 3 years ago
parent 4924eb3649
commit e1ef49e33b
  1. 1
      package-lock.json
  2. 1
      package.json
  3. 2
      src/App.js
  4. 35
      src/App.js.bak
  5. 150
      src/backend/data.json
  6. 186
      src/backend/data.json.bak
  7. 33
      src/backend/logreader.js
  8. 28
      src/backend/logreader.js.bak

1
package-lock.json generated

@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.16.2", "@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3", "@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"express": "^4.17.3",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",

@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.16.2", "@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3", "@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"express": "^4.17.3",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",

@ -51,9 +51,11 @@ function App() {
(key==="intuition"&&i===13)|| (key==="intuition"&&i===13)||
(key==="raising"&&i===14)|| (key==="raising"&&i===14)||
(key==="resolution"&&i===15)) { (key==="resolution"&&i===15)) {
if (data.floor_storage[key]>0) {
return true return true
} }
} }
}
return false return false
} }
return ( return (

@ -35,25 +35,27 @@ function App() {
function NameMatches(i) { function NameMatches(i) {
for (var key of Object.keys(data.floor_storage)) { for (var key of Object.keys(data.floor_storage)) {
if (key==="safety"&&i===0|| if ((key==="safety"&&i===0)||
key==="sight"&&i===1|| (key==="sight"&&i===1)||
key==="strength"&&i===2|| (key==="strength"&&i===2)||
key==="steel"&&i===3|| (key==="steel"&&i===3)||
key==="affluence"&&i===4|| (key==="affluence"&&i===4)||
key==="flight"&&i===5|| (key==="flight"&&i===5)||
key==="alteration"&&i===6|| (key==="alteration"&&i===6)||
key==="purity"&&i===7|| (key==="purity"&&i===7)||
key==="fortune"&&i===8|| (key==="fortune"&&i===8)||
key==="witching"&&i===9|| (key==="witching"&&i===9)||
key==="serenity"&&i===10|| (key==="serenity"&&i===10)||
key==="rage"&&i===11|| (key==="rage"&&i===11)||
key==="lust"&&i===12|| (key==="lust"&&i===12)||
key==="intuition"&&i===13|| (key==="intuition"&&i===13)||
key==="raising"&&i===14|| (key==="raising"&&i===14)||
key==="resolution"&&i===15) { (key==="resolution"&&i===15)) {
if (data.floor_storage[key]>0) {
return true return true
} }
} }
}
return false return false
} }
return ( return (
@ -115,6 +117,7 @@ function App() {
{data.death_count[0]}</div> {data.death_count[0]}</div>
{ {
data.floor_effects.map((eff,i)=>{ data.floor_effects.map((eff,i)=>{
console.log(data.floor_buff_storage)
return <> 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}}/>} {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}}> <div className="floating current" style={{left:96+Math.floor(i/3)*96,top:534+(i%3)*48,fontSize:16}}>

@ -1,90 +1,90 @@
{ {
"pomander": [ "pomander": [
[ [
0, 3,
0, 1,
0 6
], ],
[ [
0, 3,
0, 3,
0 12
], ],
[ [
0, 3,
0, 1,
0 24
], ],
[ [
0, 3,
0, 1,
0 17
], ],
[ [
3,
0, 0,
0, 7
0
], ],
[ [
0, 3,
0, 1,
0 5
], ],
[ [
3,
0, 0,
0, 14
0
], ],
[ [
3,
0, 0,
0, 8
0
], ],
[ [
0, 3,
0, 3,
0 14
], ],
[ [
0, 3,
4, 1,
4 20
], ],
[ [
3,
0, 0,
0, 13
0
], ],
[ [
0, 3,
0, 1,
0 13
], ],
[ [
9, 2,
19, 0,
19 8
], ],
[ [
0, 3,
0, 1,
0 13
], ],
[ [
3,
0, 0,
4,
4 4
], ],
[ [
0, 1,
0, 1,
0 8
] ]
], ],
"accursed_hoard": [ "accursed_hoard": [
[ [
2, 0,
3 0
], ],
[ [
0, 0,
@ -92,37 +92,37 @@
], ],
[ [
0, 0,
0 3
], ],
[ [
0, 0,
0 8
] ]
], ],
"mimics": [ "mimics": [
20, 14,
3 0
], ],
"traps": [ "traps": [
[ [
0, 1,
0 2
], ],
[ [
0, 0,
0 2
], ],
[ [
3, 1,
4 2
], ],
[ [
0, 0,
0 4
], ],
[ [
3, 0,
4 1
] ]
], ],
"floor_effects": [ "floor_effects": [
@ -132,56 +132,56 @@
], ],
[ [
0, 0,
0 2
], ],
[ [
0, 0,
0 4
], ],
[ [
0, 1,
0 5
], ],
[ [
0, 1,
0 2
], ],
[ [
0, 0,
0 0
], ],
[ [
0, 1,
0 2
], ],
[ [
0, 0,
0 1
], ],
[ [
0, 0,
0 1
], ],
[ [
2, 0,
3 0
], ],
[ [
0, 0,
0 3
] ]
], ],
"death_count": [ "death_count": [
4, 0,
6 3
], ],
"floor": 13, "floor": 64,
"accursed_hoard_detected": false, "accursed_hoard_detected": false,
"previous_pomander": "lust", "previous_pomander": "fortune",
"floor_storage": { "floor_storage": {
"lust": 1 "fortune": 1
}, },
"floor_buff_storage": { "floor_buff_storage": {
"9": true "4": true
} }
} }

@ -0,0 +1,186 @@
{
"pomander": [
[
3,
1,
6
],
[
3,
0,
9
],
[
3,
0,
23
],
[
3,
0,
16
],
[
3,
0,
7
],
[
3,
0,
4
],
[
3,
0,
14
],
[
3,
0,
8
],
[
3,
0,
11
],
[
3,
1,
20
],
[
3,
0,
13
],
[
2,
0,
12
],
[
3,
0,
8
],
[
3,
0,
12
],
[
0,
0,
4
],
[
0,
0,
7
]
],
"accursed_hoard": [
[
0,
0
],
[
0,
0
],
[
0,
3
],
[
0,
8
]
],
"mimics": [
2,
0
],
"traps": [
[
0,
1
],
[
0,
2
],
[
0,
1
],
[
0,
4
],
[
0,
1
]
],
"floor_effects": [
[
0,
0
],
[
0,
2
],
[
0,
4
],
[
0,
4
],
[
0,
1
],
[
0,
0
],
[
0,
1
],
[
0,
1
],
[
0,
1
],
[
0,
0
],
[
0,
3
]
],
"death_count": [
0,
3
],
"floor": 0,
"accursed_hoard_detected": false,
"previous_pomander": "safety",
"floor_storage": {
"witching": 1,
"safety": 0
},
"floor_buff_storage": {}
}

@ -160,6 +160,13 @@ function ParseString(str) {
pomander[pomander_slot][0]-=1 pomander[pomander_slot][0]-=1
update_file=true update_file=true
} else } else
if (split[4].includes("uses a pomander of ")) {
var pomander_name=split[4].substring(split[4].indexOf("uses a pomander of ")+"uses a pomander of ".length)
pomander_name=pomander_name.substring(0,pomander_name.length-1)
var pomander_slot = GetPomanderSlot(pomander_name)
pomander[pomander_slot][0]-=1
update_file=true
} else
if (split[4].includes("You cannot carry any more of that item.")) { if (split[4].includes("You cannot carry any more of that item.")) {
var pomander_name=split[4].substring("You return the pomander of ".length) var pomander_name=split[4].substring("You return the pomander of ".length)
pomander_name=pomander_name.replace(" to the coffer. You cannot carry any more of that item.","") pomander_name=pomander_name.replace(" to the coffer. You cannot carry any more of that item.","")
@ -206,6 +213,7 @@ function ParseString(str) {
accursed_hoard_detected=false accursed_hoard_detected=false
for (var i=0;i<pomander.length;i++) { for (var i=0;i<pomander.length;i++) {
pomander[i][0]=0 pomander[i][0]=0
pomander[i][1]=0
} }
for (var i=0;i<accursed_hoard.length;i++) { for (var i=0;i<accursed_hoard.length;i++) {
accursed_hoard[i][0]=0 accursed_hoard[i][0]=0
@ -252,8 +260,9 @@ function ParseString(str) {
pomander_name=pomander_name.substring(0,pomander_name.length-1) pomander_name=pomander_name.substring(0,pomander_name.length-1)
var pomander_slot = GetPomanderSlot(pomander_name) var pomander_slot = GetPomanderSlot(pomander_name)
pomander[pomander_slot][0]++ pomander[pomander_slot][0]++
if (floor_storage.hasOwnProperty(pomander_name)&&floor_storage[pomander_name]>0) { if (pomander_name in floor_storage&&floor_storage[pomander_name]>0) {
floor_storage[pomander_name]-- floor_storage[pomander_name]--
previous_pomander=""
} else { } else {
pomander[pomander_slot][1]++ pomander[pomander_slot][1]++
pomander[pomander_slot][2]++ pomander[pomander_slot][2]++
@ -292,67 +301,67 @@ function ParseString(str) {
if (split[4].includes("An ancient enchantment stimulates your humours, increasing the speed with which you act.")) { if (split[4].includes("An ancient enchantment stimulates your humours, increasing the speed with which you act.")) {
floor_effects[0][0]++ floor_effects[0][0]++
floor_effects[0][1]++ floor_effects[0][1]++
floor_buff_storage={0:true} floor_buff_storage={...floor_buff_storage,0:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment revitalizes your body and mind.")) { if (split[4].includes("An ancient enchantment revitalizes your body and mind.")) {
floor_effects[1][0]++ floor_effects[1][0]++
floor_effects[1][1]++ floor_effects[1][1]++
floor_buff_storage={1:true} floor_buff_storage={...floor_buff_storage,1:true}
update_file=true update_file=true
} else } else
if (split[4].includes("The gathering gloom appears to invigorate the floor's denizens.")) { if (split[4].includes("The gathering gloom appears to invigorate the floor's denizens.")) {
floor_effects[2][0]++ floor_effects[2][0]++
floor_effects[2][1]++ floor_effects[2][1]++
floor_buff_storage={2:true} floor_buff_storage={...floor_buff_storage,2:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment clouds your eyes, making it difficult to discern your quarry.")) { if (split[4].includes("An ancient enchantment clouds your eyes, making it difficult to discern your quarry.")) {
floor_effects[3][0]++ floor_effects[3][0]++
floor_effects[3][1]++ floor_effects[3][1]++
floor_buff_storage={3:true} floor_buff_storage={...floor_buff_storage,3:true}
update_file=true update_file=true
} else } else
if (split[4].includes("The items in your bag have temporarily transformed into worthless stone.")) { if (split[4].includes("The items in your bag have temporarily transformed into worthless stone.")) {
floor_effects[4][0]++ floor_effects[4][0]++
floor_effects[4][1]++ floor_effects[4][1]++
floor_buff_storage={4:true} floor_buff_storage={...floor_buff_storage,4:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment clouds your mind, making it impossible to remember previously learned abilities.")) { 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][0]++
floor_effects[5][1]++ floor_effects[5][1]++
floor_buff_storage={5:true} floor_buff_storage={...floor_buff_storage,5:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment saps your health.")) { if (split[4].includes("An ancient enchantment saps your health.")) {
floor_effects[6][0]++ floor_effects[6][0]++
floor_effects[6][1]++ floor_effects[6][1]++
floor_buff_storage={6:true} floor_buff_storage={...floor_buff_storage,6:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment saps your very strength, weakening your blows.")) { if (split[4].includes("An ancient enchantment saps your very strength, weakening your blows.")) {
floor_effects[7][0]++ floor_effects[7][0]++
floor_effects[7][1]++ floor_effects[7][1]++
floor_buff_storage={7:true} floor_buff_storage={...floor_buff_storage,7:true}
update_file=true update_file=true
} else } else
if (split[4].includes("Your body is fatigued and wounds refuse to heal on their own.")) { if (split[4].includes("Your body is fatigued and wounds refuse to heal on their own.")) {
floor_effects[8][0]++ floor_effects[8][0]++
floor_effects[8][1]++ floor_effects[8][1]++
floor_buff_storage={8:true} floor_buff_storage={...floor_buff_storage,8:true}
update_file=true update_file=true
} else } else
if (split[4].includes("Your entire body feels heavy.")) { if (split[4].includes("Your entire body feels heavy.")) {
floor_effects[9][0]++ floor_effects[9][0]++
floor_effects[9][1]++ floor_effects[9][1]++
floor_buff_storage={9:true} floor_buff_storage={...floor_buff_storage,9:true}
update_file=true update_file=true
} else } else
if (split[4].includes("You find yourself short of breath, unable to sprint.")) { if (split[4].includes("You find yourself short of breath, unable to sprint.")) {
floor_effects[10][0]++ floor_effects[10][0]++
floor_effects[10][1]++ floor_effects[10][1]++
floor_buff_storage={10:true} floor_buff_storage={...floor_buff_storage,10:true}
update_file=true update_file=true
} }

@ -96,6 +96,7 @@ var options = {
var previous_pomander="" var previous_pomander=""
var floor_storage={} var floor_storage={}
var floor_buff_storage={}
var update_file=false; var update_file=false;
tail = new Tail(process.argv[2], options); tail = new Tail(process.argv[2], options);
@ -114,6 +115,7 @@ if (fs.existsSync('./data.json')) {
accursed_hoard_detected=master_obj.accursed_hoard_detected accursed_hoard_detected=master_obj.accursed_hoard_detected
previous_pomander=master_obj.previous_pomander previous_pomander=master_obj.previous_pomander
floor_storage=master_obj.floor_storage 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, accursed_hoard_detected:accursed_hoard_detected,
previous_pomander:previous_pomander, previous_pomander:previous_pomander,
floor_storage:floor_storage, floor_storage:floor_storage,
floor_buff_storage:floor_buff_storage,
} }
} }
@ -157,6 +160,13 @@ function ParseString(str) {
pomander[pomander_slot][0]-=1 pomander[pomander_slot][0]-=1
update_file=true update_file=true
} else } else
if (split[4].includes("uses a pomander of ")) {
var pomander_name=split[4].substring(split[4].indexOf("uses a pomander of ")+"uses a pomander of ".length)
pomander_name=pomander_name.substring(0,pomander_name.length-1)
var pomander_slot = GetPomanderSlot(pomander_name)
pomander[pomander_slot][0]-=1
update_file=true
} else
if (split[4].includes("You cannot carry any more of that item.")) { if (split[4].includes("You cannot carry any more of that item.")) {
var pomander_name=split[4].substring("You return the pomander of ".length) var pomander_name=split[4].substring("You return the pomander of ".length)
pomander_name=pomander_name.replace(" to the coffer. You cannot carry any more of that item.","") pomander_name=pomander_name.replace(" to the coffer. You cannot carry any more of that item.","")
@ -179,6 +189,7 @@ function ParseString(str) {
floor=Number(fl) floor=Number(fl)
previous_pomander="" previous_pomander=""
floor_storage={} floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false accursed_hoard_detected=false
update_file=true update_file=true
} else } else
@ -188,6 +199,7 @@ function ParseString(str) {
floor=Number(fl) floor=Number(fl)
previous_pomander="" previous_pomander=""
floor_storage={} floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false accursed_hoard_detected=false
update_file=true update_file=true
} else } else
@ -197,9 +209,11 @@ function ParseString(str) {
floor=0 floor=0
previous_pomander="" previous_pomander=""
floor_storage={} floor_storage={}
floor_buff_storage={}
accursed_hoard_detected=false accursed_hoard_detected=false
for (var i=0;i<pomander.length;i++) { for (var i=0;i<pomander.length;i++) {
pomander[i][0]=0 pomander[i][0]=0
pomander[i][1]=0
} }
for (var i=0;i<accursed_hoard.length;i++) { for (var i=0;i<accursed_hoard.length;i++) {
accursed_hoard[i][0]=0 accursed_hoard[i][0]=0
@ -246,8 +260,9 @@ function ParseString(str) {
pomander_name=pomander_name.substring(0,pomander_name.length-1) pomander_name=pomander_name.substring(0,pomander_name.length-1)
var pomander_slot = GetPomanderSlot(pomander_name) var pomander_slot = GetPomanderSlot(pomander_name)
pomander[pomander_slot][0]++ pomander[pomander_slot][0]++
if (floor_storage.hasOwnProperty(pomander_name)&&floor_storage[pomander_name]>0) { if (pomander_name in floor_storage&&floor_storage[pomander_name]>0) {
floor_storage[pomander_name]-- floor_storage[pomander_name]--
previous_pomander=""
} else { } else {
pomander[pomander_slot][1]++ pomander[pomander_slot][1]++
pomander[pomander_slot][2]++ pomander[pomander_slot][2]++
@ -286,56 +301,67 @@ function ParseString(str) {
if (split[4].includes("An ancient enchantment stimulates your humours, increasing the speed with which you act.")) { if (split[4].includes("An ancient enchantment stimulates your humours, increasing the speed with which you act.")) {
floor_effects[0][0]++ floor_effects[0][0]++
floor_effects[0][1]++ floor_effects[0][1]++
floor_buff_storage={0:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment revitalizes your body and mind.")) { if (split[4].includes("An ancient enchantment revitalizes your body and mind.")) {
floor_effects[1][0]++ floor_effects[1][0]++
floor_effects[1][1]++ floor_effects[1][1]++
floor_buff_storage={1:true}
update_file=true update_file=true
} else } else
if (split[4].includes("The gathering gloom appears to invigorate the floor's denizens.")) { if (split[4].includes("The gathering gloom appears to invigorate the floor's denizens.")) {
floor_effects[2][0]++ floor_effects[2][0]++
floor_effects[2][1]++ floor_effects[2][1]++
floor_buff_storage={2:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment clouds your eyes, making it difficult to discern your quarry.")) { if (split[4].includes("An ancient enchantment clouds your eyes, making it difficult to discern your quarry.")) {
floor_effects[3][0]++ floor_effects[3][0]++
floor_effects[3][1]++ floor_effects[3][1]++
floor_buff_storage={3:true}
update_file=true update_file=true
} else } else
if (split[4].includes("The items in your bag have temporarily transformed into worthless stone.")) { if (split[4].includes("The items in your bag have temporarily transformed into worthless stone.")) {
floor_effects[4][0]++ floor_effects[4][0]++
floor_effects[4][1]++ floor_effects[4][1]++
floor_buff_storage={4:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment clouds your mind, making it impossible to remember previously learned abilities.")) { 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][0]++
floor_effects[5][1]++ floor_effects[5][1]++
floor_buff_storage={5:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment saps your health.")) { if (split[4].includes("An ancient enchantment saps your health.")) {
floor_effects[6][0]++ floor_effects[6][0]++
floor_effects[6][1]++ floor_effects[6][1]++
floor_buff_storage={6:true}
update_file=true update_file=true
} else } else
if (split[4].includes("An ancient enchantment saps your very strength, weakening your blows.")) { if (split[4].includes("An ancient enchantment saps your very strength, weakening your blows.")) {
floor_effects[7][0]++ floor_effects[7][0]++
floor_effects[7][1]++ floor_effects[7][1]++
floor_buff_storage={7:true}
update_file=true update_file=true
} else } else
if (split[4].includes("Your body is fatigued and wounds refuse to heal on their own.")) { if (split[4].includes("Your body is fatigued and wounds refuse to heal on their own.")) {
floor_effects[8][0]++ floor_effects[8][0]++
floor_effects[8][1]++ floor_effects[8][1]++
floor_buff_storage={8:true}
update_file=true update_file=true
} else } else
if (split[4].includes("Your entire body feels heavy.")) { if (split[4].includes("Your entire body feels heavy.")) {
floor_effects[9][0]++ floor_effects[9][0]++
floor_effects[9][1]++ floor_effects[9][1]++
floor_buff_storage={9:true}
update_file=true update_file=true
} else } else
if (split[4].includes("You find yourself short of breath, unable to sprint.")) { if (split[4].includes("You find yourself short of breath, unable to sprint.")) {
floor_effects[10][0]++ floor_effects[10][0]++
floor_effects[10][1]++ floor_effects[10][1]++
floor_buff_storage={10:true}
update_file=true update_file=true
} }

Loading…
Cancel
Save