Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mathe-Skribbl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
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
Ben Eltschig
Mathe-Skribbl
Commits
e3b21907
"...psco-2019-gp.git" did not exist on "d49018a64ed3dde2e702022bad2467043e647e7f"
Verified
Commit
e3b21907
authored
4 years ago
by
Ben Eltschig
Browse files
Options
Downloads
Patches
Plain Diff
kleinere Verbesserungen
parent
af03f1ea
1 merge request
!5
Custom server
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/logic/SkribblServer.js
+8
-48
8 additions, 48 deletions
client/logic/SkribblServer.js
with
8 additions
and
48 deletions
client/logic/SkribblServer.js
+
8
−
48
View file @
e3b21907
...
@@ -267,7 +267,7 @@ export default class SkribblServer {
...
@@ -267,7 +267,7 @@ export default class SkribblServer {
if
(
this
.
_hasGameStarted
){
if
(
this
.
_hasGameStarted
){
if
(
player
.
guessedWord
||
playerIndex
==
this
.
_drawingPlayer
){
if
(
player
.
guessedWord
||
playerIndex
==
this
.
_drawingPlayer
){
// TODO let people who already know the word send ghost messages to others who already know it too
// TODO let people who already know the word send ghost messages to others who already know it too
}
else
if
(
word
===
this
.
_word
){
}
else
if
(
typeof
this
.
_word
==
"
string
"
&&
SkribblServer
.
_isCorrect
(
word
,
this
.
_word
)
)
{
player
.
guessedWord
=
true
;
player
.
guessedWord
=
true
;
player
.
guessedIndex
=
Math
.
max
(...
this
.
_clients
.
map
(
client
=>
client
.
guessedIndex
))
+
1
;
player
.
guessedIndex
=
Math
.
max
(...
this
.
_clients
.
map
(
client
=>
client
.
guessedIndex
))
+
1
;
this
.
_clients
.
forEach
((
client
,
index
)
=>
{
this
.
_clients
.
forEach
((
client
,
index
)
=>
{
...
@@ -323,10 +323,10 @@ export default class SkribblServer {
...
@@ -323,10 +323,10 @@ export default class SkribblServer {
* @param {string} word
* @param {string} word
*/
*/
static
_isClose
(
guess
,
word
)
{
static
_isClose
(
guess
,
word
)
{
guess
=
guess
.
toLowerCase
();
guess
=
guess
.
toLowerCase
()
.
replace
(
/-/g
,
"
"
)
;
word
=
word
.
toLowerCase
();
word
=
word
.
toLowerCase
()
.
replace
(
/-/g
,
"
"
)
;
word
.
replace
(
/-/g
,
"
"
);
const
wordArray
=
Array
.
from
(
word
);
guess
.
replace
(
/-/g
,
"
"
);
const
guessArray
=
Array
.
from
(
guess
);
//if equal
//if equal
if
(
guess
==
word
)
{
if
(
guess
==
word
)
{
...
@@ -335,19 +335,9 @@ export default class SkribblServer {
...
@@ -335,19 +335,9 @@ export default class SkribblServer {
//either one letter wrong or two letters swapped
//either one letter wrong or two letters swapped
if
(
guess
.
length
==
word
.
length
)
{
if
(
guess
.
length
==
word
.
length
)
{
let
wordArray
=
[];
let
guessArray
=
[];
//makes the string into an array
for
(
var
i
=
0
;
i
<
word
.
length
;
i
++
)
{
wordArray
[
i
]
=
word
.
charAt
(
i
);
guessArray
[
i
]
=
guess
.
charAt
(
i
);
}
//Counts the mistakes and their position
//Counts the mistakes and their position
let
errorCounter
=
0
;
let
errorCounter
=
0
;
let
errorPos
=
0
;
let
errorPos
=
0
;
for
(
var
i
=
0
;
i
<
wordArray
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
wordArray
.
length
;
i
++
)
{
if
(
wordArray
[
i
]
!=
guessArray
[
i
])
{
if
(
wordArray
[
i
]
!=
guessArray
[
i
])
{
if
(
errorCounter
==
0
)
{
if
(
errorCounter
==
0
)
{
...
@@ -363,24 +353,13 @@ export default class SkribblServer {
...
@@ -363,24 +353,13 @@ export default class SkribblServer {
errorCounter
++
;
errorCounter
++
;
}
}
}
}
//if it hasnt returned false by now, the guess is close
//if it hasnt returned false by now, the guess is close
return
true
;
return
true
;
}
}
//if one letter too much
//if one letter too much
if
(
guess
.
length
-
1
==
word
.
length
)
{
if
(
guess
.
length
-
1
==
word
.
length
)
{
let
wordArray
=
[];
let
guessArray
=
[];
for
(
var
i
=
0
;
i
<
word
.
length
;
i
++
)
{
wordArray
[
i
]
=
word
.
charAt
(
i
);
guessArray
[
i
]
=
guess
.
charAt
(
i
);
}
guessArray
[
guessArray
.
length
]
=
guess
.
charAt
(
guessArray
.
length
);
let
errorCounter
=
0
;
//also the offset
let
errorCounter
=
0
;
//also the offset
for
(
var
i
=
0
;
i
<
wordArray
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
wordArray
.
length
;
i
++
)
{
if
(
wordArray
[
i
]
!=
guessArray
[
i
+
errorCounter
])
{
if
(
wordArray
[
i
]
!=
guessArray
[
i
+
errorCounter
])
{
errorCounter
++
;
errorCounter
++
;
...
@@ -389,23 +368,12 @@ export default class SkribblServer {
...
@@ -389,23 +368,12 @@ export default class SkribblServer {
}
}
}
}
}
}
return
true
;
return
true
;
}
}
//if one letter too little
//if one letter too little
if
(
guess
.
length
+
1
==
word
.
length
)
{
if
(
guess
.
length
+
1
==
word
.
length
)
{
let
wordArray
=
[];
let
guessArray
=
[];
for
(
var
i
=
0
;
i
<
guess
.
length
;
i
++
)
{
wordArray
[
i
]
=
word
.
charAt
(
i
);
guessArray
[
i
]
=
guess
.
charAt
(
i
);
}
wordArray
[
wordArray
.
length
]
=
word
.
charAt
(
wordArray
.
length
);
let
errorCounter
=
0
;
//also the offset
let
errorCounter
=
0
;
//also the offset
for
(
var
i
=
0
;
i
<
guessArray
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
guessArray
.
length
;
i
++
)
{
if
(
wordArray
[
i
+
errorCounter
]
!=
guessArray
[
i
])
{
if
(
wordArray
[
i
+
errorCounter
]
!=
guessArray
[
i
])
{
errorCounter
++
;
errorCounter
++
;
...
@@ -414,7 +382,6 @@ export default class SkribblServer {
...
@@ -414,7 +382,6 @@ export default class SkribblServer {
}
}
}
}
}
}
return
true
;
return
true
;
}
}
...
@@ -427,15 +394,8 @@ export default class SkribblServer {
...
@@ -427,15 +394,8 @@ export default class SkribblServer {
* @param {string} word
* @param {string} word
*/
*/
static
_isCorrect
(
guess
,
word
)
{
static
_isCorrect
(
guess
,
word
)
{
guess
=
guess
.
toLowerCase
();
guess
=
guess
.
toLowerCase
().
replace
(
/-/g
,
"
"
);
word
=
word
.
toLowerCase
();
word
=
word
.
toLowerCase
().
replace
(
/-/g
,
"
"
);
word
.
replace
(
/-/g
,
"
"
);
return
guess
==
word
;
guess
.
replace
(
/-/g
,
"
"
);
if
(
guess
==
word
)
{
return
true
;
}
else
{
return
true
;
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
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