|
|
|
@ -9,7 +9,6 @@ import { MathJax } from "better-react-mathjax";
|
|
|
|
import List from '@mui/material/List';
|
|
|
|
import List from '@mui/material/List';
|
|
|
|
import ListItem from '@mui/material/ListItem';
|
|
|
|
import ListItem from '@mui/material/ListItem';
|
|
|
|
import { Paper, Box, Typography, Alert, FormControlLabel, FormGroup, Switch, Collapse } from '@mui/material';
|
|
|
|
import { Paper, Box, Typography, Alert, FormControlLabel, FormGroup, Switch, Collapse } from '@mui/material';
|
|
|
|
const errorRegex = /<stdin>:1:(?<col>[^:]*): (?<msg>.*)/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Dead variables (x✝) are not displayed correctly.
|
|
|
|
// TODO: Dead variables (x✝) are not displayed correctly.
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,26 +56,13 @@ function TacticState({ goals, errors, completed }) {
|
|
|
|
const hasError = typeof errors === "object" && errors.length > 0
|
|
|
|
const hasError = typeof errors === "object" && errors.length > 0
|
|
|
|
const hasGoal = goals !== null && goals.length > 0
|
|
|
|
const hasGoal = goals !== null && goals.length > 0
|
|
|
|
const hasManyGoal = hasGoal && goals.length > 1
|
|
|
|
const hasManyGoal = hasGoal && goals.length > 1
|
|
|
|
var col = ""
|
|
|
|
|
|
|
|
var msg = ""
|
|
|
|
|
|
|
|
if (hasError) {
|
|
|
|
|
|
|
|
const m = errors[0].match(errorRegex)
|
|
|
|
|
|
|
|
if (m) {
|
|
|
|
|
|
|
|
col = `Column ${m.groups.col}: `
|
|
|
|
|
|
|
|
msg = m.groups.msg
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
msg = errors[0]
|
|
|
|
|
|
|
|
if (msg === "Unrecognized tactic") { msg = "Unknown spell!" }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Box sx={{ height: "100%" }}>
|
|
|
|
<Box sx={{ height: "100%" }}>
|
|
|
|
{goals === null && <Typography variant="h6">No goals at cursor position</Typography>}
|
|
|
|
{goals === null && <Typography variant="h6">No goals at cursor position</Typography>}
|
|
|
|
{hasGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}><Typography variant="h5">Main goal at cursor</Typography> <Goal goal={goals[0]} /></Paper>}
|
|
|
|
{hasGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}><Typography variant="h5">Main goal at cursor</Typography> <Goal goal={goals[0]} /></Paper>}
|
|
|
|
{completed && <Typography variant="h6">Level completed ! 🎉</Typography>}
|
|
|
|
{completed && <Typography variant="h6">Level completed ! 🎉</Typography>}
|
|
|
|
{hasError && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}><Typography variant="h5" color="error">Spell invocation failed</Typography>
|
|
|
|
{hasError && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}>
|
|
|
|
<Typography component="pre" sx={{ my: 1 }}>{col}{msg}</Typography>
|
|
|
|
{errors.map(({severity, message}) => <Typography color={{1: "red", 2:"orange", 3:"blue", 4:"gray"}[severity]}>{message}</Typography>)}
|
|
|
|
<Typography>Use the undo button to go back to a sane state.</Typography>
|
|
|
|
|
|
|
|
</Paper>}
|
|
|
|
</Paper>}
|
|
|
|
{hasManyGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, mt: 1 }}>
|
|
|
|
{hasManyGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, mt: 1 }}>
|
|
|
|
<Typography variant="h6" sx={{ mb: 2 }}>Other goals</Typography>
|
|
|
|
<Typography variant="h6" sx={{ mb: 2 }}>Other goals</Typography>
|
|
|
|
|