Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
03e422e9
Commit
03e422e9
authored
3 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
feat: #fe #be fetch actual data
parent
5c190576
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/src/index.ts
+13
-15
13 additions, 15 deletions
backend/src/index.ts
frontend/.env.development
+1
-1
1 addition, 1 deletion
frontend/.env.development
frontend/src/js/fight_scene.js
+16
-22
16 additions, 22 deletions
frontend/src/js/fight_scene.js
with
30 additions
and
38 deletions
backend/src/index.ts
+
13
−
15
View file @
03e422e9
...
...
@@ -26,34 +26,32 @@ server.route({
method
:
"
POST
"
,
url
:
"
/GetImage
"
,
schema
:
{
body
:
{
type
:
"
object
"
,
properties
:
{
sessionImages
:
{
type
:
"
array
"
,
items
:
{
type
:
"
number
"
},
},
},
},
// body: {},
response
:
{
200
:
{
type
:
"
object
"
,
properties
:
{
id
:
{
type
:
"
number
"
},
id
:
{
type
:
"
string
"
,
format
:
"
uuid
"
},
image
:
{
type
:
"
string
"
},
ocr_confidence
:
{
type
:
"
number
"
,
minimum
:
0
,
maximum
:
1
},
ocr_transcript
:
{
type
:
"
string
"
},
},
},
},
},
handler
:
async
function
(
request
,
reply
)
{
// TODO: skip images already used in current game
const
image
=
await
connection
.
table
(
"
images
"
)
// TODO: skip images already used in current game (overkill? we prolly have thousands so collisions should be irrelevant...)
const
word
=
await
connection
.
table
(
"
words
"
)
.
whereBetween
(
"
ocr_confidence
"
,
[
0.4
,
0.8
])
// i.e. needs improvement but it's not trash
.
whereRaw
(
`"ocr_transcript" ~ '^[[:alpha:]]+$'`
)
// i.e. no numbers nor symbols
.
orderByRaw
(
"
RANDOM()
"
)
.
first
();
reply
.
send
({
id
:
image
.
id
,
image
:
image
.
image
,
id
:
word
.
id
,
image
:
word
.
image
,
ocr_confidence
:
word
.
ocr_confidence
,
ocr_transcript
:
word
.
ocr_transcript
,
});
},
});
...
...
This diff is collapsed.
Click to expand it.
frontend/.env.development
+
1
−
1
View file @
03e422e9
BACKEND_URL=http://localhost:8080
/
BACKEND_URL=http://localhost:8080
This diff is collapsed.
Click to expand it.
frontend/src/js/fight_scene.js
+
16
−
22
View file @
03e422e9
...
...
@@ -320,28 +320,22 @@ function dispatchEnemy(scene) {
let
e
=
new
enemy
(
scene
);
window
.
onscreenEnemies
.
push
(
e
);
backend
.
post
(
"
GetImage
"
,
{
sessionImages
:
[],
})
.
then
(
function
(
response
)
{
e
.
refData
=
response
.
data
;
const
imageData
=
`data:image/png;base64,
${
response
.
data
.
image
}
`
;
scene
.
textures
.
addBase64
(
`WORD-
${
response
.
data
.
id
}
`
,
imageData
);
scene
.
textures
.
once
(
"
addtexture
"
,
function
()
{
e
.
run
((
v
)
=>
{
setTimeout
(()
=>
{
dispatchEnemy
(
scene
);
},
Math
.
floor
(
Math
.
random
()
*
10000
+
3000
));
});
},
scene
,
);
});
backend
.
post
(
"
GetImage
"
,
{}).
then
(
function
(
response
)
{
e
.
refData
=
response
.
data
;
scene
.
textures
.
addBase64
(
`WORD-
${
response
.
data
.
id
}
`
,
response
.
data
.
image
);
scene
.
textures
.
once
(
"
addtexture
"
,
function
()
{
e
.
run
((
v
)
=>
{
setTimeout
(()
=>
{
dispatchEnemy
(
scene
);
},
Math
.
floor
(
Math
.
random
()
*
10000
+
3000
));
});
},
scene
,
);
});
}
export
default
fightScene
;
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