@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
2
2
import { connect } from "react-redux" ;
3
3
import { setCorrectchr } from "../redux/correct/actions" ;
4
4
import { setWrongchr } from "../redux/wrong/actions" ;
5
+ import { setSpacechr } from "../redux/space/actions" ;
5
6
import getFilecontents from "../utils/filecontents" ;
6
7
import AutoCompletion from "./AutoCompletion" ;
7
8
@@ -10,7 +11,8 @@ function Text(props) {
10
11
const [ textSplit , setTextSplit ] = useState ( [ ] ) ;
11
12
const [ themeColor , setThemeColor ] = useState ( "" ) ;
12
13
let wrong = 0 ,
13
- correct = 0 ;
14
+ correct = 0 ,
15
+ space = 0 ;
14
16
const user = props . userInput ;
15
17
const userSplit = user . split ( "" ) ;
16
18
@@ -32,6 +34,7 @@ function Text(props) {
32
34
useEffect ( ( ) => {
33
35
props . setCorrectchr ( correct ) ;
34
36
props . setWrongchr ( wrong ) ;
37
+ props . setSpacechr ( space ) ;
35
38
// eslint-disable-next-line react-hooks/exhaustive-deps
36
39
} ) ;
37
40
@@ -56,6 +59,10 @@ function Text(props) {
56
59
color = "#ff5c5c" ;
57
60
colortxt = "white" ;
58
61
wrong ++ ;
62
+ if ( userSplit [ i ] === " " || userSplit [ i ] === "\n" ) {
63
+ // 공백이나 개행으로 틀린 경우 속도 패널티 부여
64
+ space ++ ;
65
+ }
59
66
}
60
67
}
61
68
@@ -111,13 +118,15 @@ const mapStateToProps = (state) => {
111
118
return {
112
119
Correctchr : state . correct . Correctchr ,
113
120
Wrongchr : state . wrong . Wrongchr ,
121
+ Spacechr : state . space . Spacechr ,
114
122
} ;
115
123
} ;
116
124
117
125
const mapDispatchToProps = ( dispatch ) => {
118
126
return {
119
127
setCorrectchr : ( cor ) => dispatch ( setCorrectchr ( cor ) ) ,
120
128
setWrongchr : ( wr ) => dispatch ( setWrongchr ( wr ) ) ,
129
+ setSpacechr : ( sp ) => dispatch ( setSpacechr ( sp ) ) ,
121
130
} ;
122
131
} ;
123
132
0 commit comments