Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WorkAdventure Dialogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FS Info TU Dortmund
Events
WorkAdventure Dialogs
Commits
ca24bffc
Commit
ca24bffc
authored
4 years ago
by
Jonas Zohren
Browse files
Options
Downloads
Patches
Plain Diff
Show problems with dialog in debugger
parent
9828e712
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Debugger.svelte
+11
-1
11 additions, 1 deletion
src/Debugger.svelte
src/utils.ts
+56
-1
56 additions, 1 deletion
src/utils.ts
with
67 additions
and
2 deletions
src/Debugger.svelte
+
11
−
1
View file @
ca24bffc
<script
lang=
"ts"
>
import
{
gameFactsStore
,
addGameFactToFactArray
,
toggleFactInFactArray
}
from
'
./gameFacts
'
import
type
{
Dialog
,
DialogMap
,
DialogSet
}
from
'
./types
'
;
import
{
findDialogSetProblems
}
from
"
./utils
"
export
let
currentDialog
:
Dialog
;
export
let
dialogSet
:
DialogSet
;
...
...
@@ -28,7 +29,16 @@
{
dialogName
}
</option>
{
/each
}
</select>
</select>
<br>
<ol>
{
#each
findDialogSetProblems
(
dialogSet
)
as
{
sourceDialog
,
text
}
}
<li>
{
sourceDialog
}
:
<code
style=
"color: orange"
>
{
text
}
</code>
</li>
{
/each
}
</ol>
<hr>
<h3>
Quest-Debugger
</h3>
...
...
This diff is collapsed.
Click to expand it.
src/utils.ts
+
56
−
1
View file @
ca24bffc
import
type
{
DialogSet
}
from
"
./types
"
;
import
type
{
DialogMap
,
DialogOption
,
DialogSet
}
from
"
./types
"
;
/**
* Returns true, if input is a valid name of a dialogSet.
...
...
@@ -39,3 +39,58 @@ export async function fetchDialogSet(): Promise<DialogSet> {
throw
error
;
}
}
export
function
findDialogSetProblems
(
dialogSet
:
DialogSet
)
{
const
dialogReferenceProblems
=
checkForInvalidDialogReferences
(
dialogSet
);
return
[...
dialogReferenceProblems
];
}
interface
DialogReferenceProblem
{
type
:
"
DialogReferenceProblem
"
;
sourceDialog
:
string
;
text
:
string
;
}
function
checkForInvalidDialogReferences
(
dialogSet
:
DialogSet
):
DialogReferenceProblem
[]
{
const
dialogs
=
dialogSet
.
dialogs
;
const
problems
:
DialogReferenceProblem
[]
=
[];
const
allDialogKeys
=
Object
.
keys
(
dialogs
);
const
allLinkedToDialogKeys
:
Set
<
string
>
=
new
Set
();
for
(
const
dialogName
of
allDialogKeys
)
{
// TODO check all buttons for invalid references
for
(
const
{
text
,
linksToDialog
}
of
dialogs
[
dialogName
].
options
)
{
allLinkedToDialogKeys
.
add
(
linksToDialog
);
if
(
!
allDialogKeys
.
includes
(
linksToDialog
))
{
problems
.
push
({
type
:
"
DialogReferenceProblem
"
,
sourceDialog
:
dialogName
,
text
:
`Dialog
${
dialogName
}
's option "
${
text
}
" links to unknown dialog '
${
linksToDialog
}
'`
,
});
}
if
(
linksToDialog
===
dialogName
)
{
problems
.
push
({
type
:
"
DialogReferenceProblem
"
,
sourceDialog
:
dialogName
,
text
:
`Dialog
${
dialogName
}
's option "
${
text
}
" links to itself!`
,
});
}
}
}
for
(
const
dialogName
of
allDialogKeys
)
{
if
(
!
allLinkedToDialogKeys
.
has
(
dialogName
)
&&
dialogSet
.
startDialogName
!==
dialogName
)
{
problems
.
push
({
type
:
"
DialogReferenceProblem
"
,
sourceDialog
:
dialogName
,
text
:
`Dialog
${
dialogName
}
is unreachable: Neither linked to from any other dialog, nor startDialog`
,
});
}
}
return
problems
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment