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
0afbc7f8
Commit
0afbc7f8
authored
Jul 09, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
오타 인식 구현 완료, 공격 단어가 이젠 공격자 이름만이 아니라 아이디까지 담음
parent
12e22ec6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
39 deletions
+27
-39
GameServer.js
GameServer.js
+1
-1
WordObject.js
js/WordObject.js
+5
-5
WordSpace.js
js/WordSpace.js
+21
-32
main.js
js/main.js
+0
-1
No files found.
GameServer.js
View file @
0afbc7f8
var
GameServer
=
GameServer
||
{};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
startCount
=
1
;
GameServer
.
startCount
=
3
;
GameServer
.
currentPlayer
=
[];
GameServer
.
playingRoom
=
[];
...
...
js/WordObject.js
View file @
0afbc7f8
...
...
@@ -114,19 +114,19 @@ class NormalWord extends WordObject
class
AttackWord
extends
WordObject
{
constructor
(
text
,
_wordGrade
,
_
attacker
,
isStrong
)
constructor
(
text
,
_wordGrade
,
_
playerData
,
isStrong
)
{
super
(
text
);
this
.
wordGrade
=
_wordGrade
;
this
.
wordWeight
=
WordReader
.
getWordWeight
(
this
.
wordGrade
);
if
(
WordReader
.
getWordTyping
(
_
attacker
)
<=
9
)
this
.
wordWeight
+=
this
.
wordWeight
*
0.2
*
(
WordReader
.
getWordTyping
(
P
layerData
.
nickname
)
-
9
);
if
(
WordReader
.
getWordTyping
(
_
playerData
.
nickname
)
<=
9
)
this
.
wordWeight
+=
this
.
wordWeight
*
0.2
*
(
WordReader
.
getWordTyping
(
_p
layerData
.
nickname
)
-
9
);
this
.
wordWeight
*=
isStrong
?
3
:
2
;
this
.
attacker
=
_
attacker
;
this
.
attacker
=
_
playerData
;
//서버 사용하게 되면 PlayerTyping을 피격자의 것으로 바꿔야 함
this
.
counterTime
=
WordSpace
.
gameTimer
.
now
+
1000
*
(
this
.
wordTyping
<=
(
5
-
_wordGrade
)
*
2.5
?
this
.
wordTyping
*
(
WordSpace
.
playerTyping
/
60
)
*
2
:
((
5
-
_wordGrade
)
*
2.5
+
(
this
.
wordTyping
-
(
5
-
_wordGrade
)
*
2.5
)
*
3
)
*
(
WordSpace
.
playerTyping
/
60
)
*
2
);
console
.
log
(
'
Attack text :
'
+
text
+
'
, Attacker :
'
+
this
.
attacker
+
'
, Weight :
'
+
this
.
wordWeight
);
console
.
log
(
'
Attack text :
'
+
text
+
'
, Attacker :
'
+
this
.
attacker
.
nickname
+
'
, Weight :
'
+
this
.
wordWeight
);
console
.
log
(
'
Counter time :
'
+
this
.
counterTime
);
}
destroy
()
...
...
js/WordSpace.js
View file @
0afbc7f8
...
...
@@ -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
()
...
...
@@ -334,23 +334,24 @@ WordSpace.findWord = function(wordText)
}
else
// 오타 체크
{
let
minDist
=
5
,
tempDist
=
0
;
let
attackWords
=
[];
WordSpace
.
wordGroup
.
forEach
(
function
(
element
)
{
let
inputWord
=
[],
checkWord
=
[],
diff
=
[];
let
inputUnused
=
0
,
checkUnused
=
0
;
for
(
let
i
=
0
;
i
<
wordText
.
lenRate
;
i
++
)
if
(
element
instanceof
AttackWord
)
{
inputWord
.
push
(
WordReader
.
firstSound
(
wordText
[
i
])
);
inputWord
.
push
(
WordReader
.
middleSound
(
wordText
[
i
])
);
i
nputWord
.
push
(
WordReader
.
lastSound
(
wordText
[
i
]))
;
tempDist
=
WordSpace
.
getEditDistance
(
wordText
,
element
.
wordText
);
attackWords
.
push
(
element
);
i
f
(
tempDist
<=
minDist
)
minDist
=
tempDist
;
}
for
(
let
i
=
0
;
i
<
element
.
lenRate
;
i
++
)
});
attackWords
.
forEach
(
function
(
element
)
{
if
(
WordSpace
.
getEditDistance
(
wordText
,
element
.
wordText
)
==
minDist
)
{
checkWord
.
push
(
WordReader
.
firstSound
(
element
[
i
]));
checkWord
.
push
(
WordReader
.
middleSound
(
element
[
i
]));
checkWord
.
push
(
WordReader
.
lastSound
(
element
[
i
]));
//강호패 보내야 함
console
.
log
(
'
Attack word of
'
+
element
.
attacker
.
nickname
+
'
오타임
'
);
}
});
}
}
...
...
@@ -384,23 +385,20 @@ WordSpace.attack = function(wordText, grade)
let
attackData
=
{
roomNum
:
RoomData
.
roomNum
,
attacker
:
PlayerData
.
nickname
,
attacker
:
PlayerData
,
target
:
element
.
ownerId
,
text
:
wordText
,
grade
:
grade
,
isStrong
:
element
.
isStrong
}
socket
.
emit
(
'
attack
'
,
attackData
);
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData.nickname, element.isStrong);
});
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData, false);
WordSpace
.
nameGroup
=
[];
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
}
else
{
WordSpace
.
attackGauge
.
cutValue
(
0.3
);
}
else
WordSpace
.
attackGauge
.
cutValue
(
0.3
);
Input
.
maxInput
=
6
;
Input
.
attackMode
=
false
;
WordSpace
.
attackGauge
.
pauseCycle
(
false
);
...
...
@@ -424,8 +422,6 @@ WordSpace.nameQueue =
if
(
element
.
nickname
!=
PlayerData
.
nickname
&&
element
.
isAlive
)
WordSpace
.
nameQueue
.
queue
.
push
(
element
);
});
/*console.log(WordSpace.nameQueue.queue);
console.log(RoomData.aliveCount);*/
},
pop
:
function
()
{
...
...
@@ -440,9 +436,7 @@ WordSpace.nameQueue =
}
}
WordSpace
.
testDistance
=
function
(
input
,
check
)
{
WordSpace
.
getEditDistance
=
function
(
input
,
check
)
{
var
inputWords
=
[],
checkWords
=
[]
for
(
let
i
=
0
;
i
<
input
.
length
;
i
++
)
{
...
...
@@ -457,22 +451,17 @@ WordSpace.testDistance = function(input, check) {
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
++
)
for
(
i
=
0
;
i
<=
checkWords
.
length
;
i
++
)
// increment along the first column of each row
matrix
[
i
]
=
[
i
];
// increment each column in the first row
for
(
j
=
0
;
j
<=
inputWords
.
length
;
j
++
)
for
(
j
=
0
;
j
<=
inputWords
.
length
;
j
++
)
// increment each column in the first row
matrix
[
0
][
j
]
=
j
;
// Fill in the rest of the matrix
for
(
i
=
1
;
i
<=
checkWords
.
length
;
i
++
)
for
(
i
=
1
;
i
<=
checkWords
.
length
;
i
++
)
// Fill in the rest of the matrix
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
])
;
return
matrix
[
checkWords
.
length
][
inputWords
.
length
]
;
}
\ No newline at end of file
js/main.js
View file @
0afbc7f8
...
...
@@ -21,7 +21,6 @@ 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