Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sejong25
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Tear of Sejong
sejong25
Commits
12e22ec6
Commit
12e22ec6
authored
Jul 09, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
한글 자모를 이용한 편집 거리 구하는 함수 구현 wip
parent
ece8a72e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
14 deletions
+67
-14
GameServer.js
GameServer.js
+1
-1
WordObject.js
js/WordObject.js
+4
-4
WordReader.js
js/WordReader.js
+4
-4
WordSpace.js
js/WordSpace.js
+57
-5
main.js
js/main.js
+1
-0
No files found.
GameServer.js
View file @
12e22ec6
var
GameServer
=
GameServer
||
{};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
startCount
=
5
;
GameServer
.
startCount
=
1
;
GameServer
.
currentPlayer
=
[];
GameServer
.
playingRoom
=
[];
...
...
js/WordObject.js
View file @
12e22ec6
...
...
@@ -146,13 +146,13 @@ class AttackWord extends WordObject
class
NameWord
extends
WordObject
{
constructor
(
name
,
_isStrong
=
false
)
constructor
(
player
,
_isStrong
=
false
)
{
super
(
name
.
nickname
);
this
.
ownerId
=
name
.
id
;
super
(
player
.
nickname
);
this
.
ownerId
=
player
.
id
;
this
.
wordWeight
=
2
;
this
.
isStrong
=
_isStrong
;
console
.
log
(
'
Name :
'
+
name
.
nickname
+
'
, Strong :
'
+
this
.
isStrong
+
'
, Weight :
'
+
this
.
wordWeight
);
console
.
log
(
'
Name :
'
+
player
.
nickname
+
'
, Strong :
'
+
this
.
isStrong
+
'
, Weight :
'
+
this
.
wordWeight
);
}
destroy
()
{
...
...
js/WordReader.js
View file @
12e22ec6
var
WordReader
=
WordReader
||
{};
//초성의 타수를 반환함
function
firstSound
(
charText
)
WordReader
.
firstSound
=
function
(
charText
)
{
var
r
=
parseInt
(((
charText
.
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
/
21
);
//쌍자음일 경우
...
...
@@ -10,7 +10,7 @@ function firstSound(charText)
}
//중성의 타수를 반환함
function
middleSound
(
charText
)
WordReader
.
middleSound
=
function
(
charText
)
{
var
r
=
parseInt
(((
charText
.
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
%
21
);
//'ㅒ' 또는 'ㅖ'일 경우
...
...
@@ -21,7 +21,7 @@ function middleSound(charText)
}
//종성의 타수를 반환함
function
lastSound
(
charText
)
WordReader
.
lastSound
=
function
(
charText
)
{
var
r
=
parseInt
((
charText
.
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
%
28
);
//쌍자음일 경우
...
...
@@ -40,7 +40,7 @@ WordReader.getWordTyping = function(stringText)
for
(
var
i
=
0
;
i
<
stringText
.
length
;
i
++
)
{
if
(
stringText
.
charCodeAt
(
i
)
<
parseInt
(
'
0xac00
'
,
16
)
||
stringText
.
charCodeAt
(
i
)
>
parseInt
(
'
0xd7af
'
,
16
))
return
-
1
;
temp
+=
parseFloat
(
firstSound
(
stringText
.
charAt
(
i
)))
+
middleSound
(
stringText
.
charAt
(
i
))
+
lastSound
(
stringText
.
charAt
(
i
));
temp
+=
parseFloat
(
WordReader
.
firstSound
(
stringText
.
charAt
(
i
)))
+
WordReader
.
middleSound
(
stringText
.
charAt
(
i
))
+
WordReader
.
lastSound
(
stringText
.
charAt
(
i
));
}
return
temp
;
}
...
...
js/WordSpace.js
View file @
12e22ec6
...
...
@@ -70,7 +70,7 @@ WordSpace.gameOverCycle = new Cycle(gameOver);
//호패 생성 사이클
WordSpace
.
nameCycle
=
new
Cycle
(
function
()
{
WordSpace
.
generateWord
.
Name
(
WordSpace
.
gameSceneForTest
,
false
);
//
WordSpace.generateWord.Name(WordSpace.gameSceneForTest, false);
});
//이건 뭐지
WordSpace
.
varAdjustCycle
=
new
Cycle
(
function
()
...
...
@@ -288,7 +288,6 @@ WordSpace.setGameOverTimer = function()
{
this
.
isTimerOn
=
true
;
WordSpace
.
gameOverCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
gameOver
,
0
,
false
);
console
.
log
(
'
Game over timer On
'
);
}
}
...
...
@@ -298,7 +297,6 @@ WordSpace.resetGameOverTimer = function()
{
this
.
isTimerOn
=
false
;
WordSpace
.
gameOverCycle
.
currentCycle
.
paused
=
true
;
console
.
log
(
'
Game over timer Off
'
);
}
}
...
...
@@ -334,9 +332,26 @@ WordSpace.findWord = function(wordText)
WordSpace
.
attackGauge
.
pauseCycle
(
true
);
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
}
else
else
// 오타 체크
{
WordSpace
.
wordGroup
.
forEach
(
function
(
element
)
{
let
inputWord
=
[],
checkWord
=
[],
diff
=
[];
let
inputUnused
=
0
,
checkUnused
=
0
;
for
(
let
i
=
0
;
i
<
wordText
.
lenRate
;
i
++
)
{
inputWord
.
push
(
WordReader
.
firstSound
(
wordText
[
i
]));
inputWord
.
push
(
WordReader
.
middleSound
(
wordText
[
i
]));
inputWord
.
push
(
WordReader
.
lastSound
(
wordText
[
i
]));
}
for
(
let
i
=
0
;
i
<
element
.
lenRate
;
i
++
)
{
// 오타 체크
checkWord
.
push
(
WordReader
.
firstSound
(
element
[
i
]));
checkWord
.
push
(
WordReader
.
middleSound
(
element
[
i
]));
checkWord
.
push
(
WordReader
.
lastSound
(
element
[
i
]));
}
});
}
}
...
...
@@ -424,3 +439,40 @@ WordSpace.nameQueue =
this
.
shuffle
();
}
}
WordSpace
.
testDistance
=
function
(
input
,
check
)
{
var
inputWords
=
[],
checkWords
=
[]
for
(
let
i
=
0
;
i
<
input
.
length
;
i
++
)
{
inputWords
.
push
(
parseInt
(((
input
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
/
21
)
+
parseInt
(
'
0x1100
'
,
16
));
inputWords
.
push
(
parseInt
(((
input
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
%
21
)
+
parseInt
(
'
0x1161
'
,
16
));
inputWords
.
push
(
parseInt
((
input
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
%
28
)
+
parseInt
(
'
0x11A8
'
)
-
1
);
}
for
(
let
i
=
0
;
i
<
check
.
length
;
i
++
)
{
checkWords
.
push
(
parseInt
(((
check
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
/
21
)
+
parseInt
(
'
0x1100
'
,
16
));
checkWords
.
push
(
parseInt
(((
check
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
/
28
)
%
21
)
+
parseInt
(
'
0x1161
'
,
16
));
checkWords
.
push
(
parseInt
((
check
[
i
].
charCodeAt
(
0
)
-
parseInt
(
'
0xac00
'
,
16
))
%
28
)
+
parseInt
(
'
0x11A8
'
)
-
1
);
}
var
matrix
=
[];
// increment along the first column of each row
var
i
,
j
;
for
(
i
=
0
;
i
<=
checkWords
.
length
;
i
++
)
matrix
[
i
]
=
[
i
];
// increment each column in the first row
for
(
j
=
0
;
j
<=
inputWords
.
length
;
j
++
)
matrix
[
0
][
j
]
=
j
;
// Fill in the rest of the matrix
for
(
i
=
1
;
i
<=
checkWords
.
length
;
i
++
)
for
(
j
=
1
;
j
<=
inputWords
.
length
;
j
++
){
if
(
checkWords
[
i
-
1
]
==
inputWords
[
j
-
1
])
matrix
[
i
][
j
]
=
matrix
[
i
-
1
][
j
-
1
];
else
matrix
[
i
][
j
]
=
Math
.
min
(
matrix
[
i
-
1
][
j
-
1
]
+
1
,
// substitution
Math
.
min
(
matrix
[
i
][
j
-
1
]
+
1
,
// insertion
matrix
[
i
-
1
][
j
]
+
1
));
// deletion
}
console
.
log
(
'
edit distance is
'
+
matrix
[
checkWords
.
length
][
inputWords
.
length
]);
}
\ No newline at end of file
js/main.js
View file @
12e22ec6
...
...
@@ -21,6 +21,7 @@ var PlayerData = PlayerData || {};
PlayerData
.
idNum
=
-
1
;
//플레이어 아이디, 고유 번호
PlayerData
.
nickname
=
'
홍길동
'
;
//플레이어 닉네임
// 현재 들어가있는 Game Room의 정보
var
RoomData
=
RoomData
||
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment