Skip to content

Commit e01477b

Browse files
committed
Merge pull request #2 from ossas/develop
Develop 최신반영
2 parents 365c206 + 9995cc6 commit e01477b

File tree

7 files changed

+121
-8
lines changed

7 files changed

+121
-8
lines changed

dist/gameview.bundle.js

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19700,7 +19700,8 @@
1970019700
var gameData = sdm.getGameData('random');
1970119701
_this.state = {
1970219702
gameData: gameData,
19703-
userData: cloneObject(gameData.data)
19703+
userData: cloneObject(gameData.data),
19704+
failCells: []
1970419705
};
1970519706
return _this;
1970619707
}
@@ -19713,6 +19714,7 @@
1971319714

1971419715
for (var i = 0; i < 9; i++) {
1971519716
boxes.push(_react2.default.createElement(_box2.default, {
19717+
ref: i,
1971619718
key: i,
1971719719
position: i,
1971819720
data: this.state.gameData.data[i],
@@ -19738,6 +19740,43 @@
1973819740
var _k = _cell$props._k;
1973919741

1974019742
this.state.userData[_i][_j][_k] = value;
19743+
19744+
var check_data = sdm.gameDataCheck(this.state.userData);
19745+
19746+
this.state.failCells.forEach(function (cell) {
19747+
cell.setState({
19748+
isFail: false
19749+
});
19750+
});
19751+
19752+
if (check_data.state === 'fail') {
19753+
for (var key in check_data.box) {
19754+
var coord = check_data.box[key];
19755+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
19756+
cell.setState({
19757+
isFail: true
19758+
});
19759+
this.state.failCells.push(cell);
19760+
}
19761+
for (var key in check_data.rows) {
19762+
var coord = check_data.rows[key];
19763+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
19764+
cell.setState({
19765+
isFail: true
19766+
});
19767+
this.state.failCells.push(cell);
19768+
}
19769+
for (var key in check_data.cols) {
19770+
var coord = check_data.cols[key];
19771+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
19772+
cell.setState({
19773+
isFail: true
19774+
});
19775+
this.state.failCells.push(cell);
19776+
}
19777+
} else if (check_data.state === 'complete') {
19778+
alert('게임완료');
19779+
}
1974119780
}
1974219781
}
1974319782
}, {
@@ -19804,6 +19843,7 @@
1980419843
Cells.push(_react2.default.createElement(
1980519844
_cell2.default,
1980619845
{
19846+
ref: '' + i + j,
1980719847
key: '' + i + j,
1980819848
_i: this.props.position,
1980919849
_j: i,
@@ -19868,11 +19908,24 @@
1986819908

1986919909
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Cell).call(this, props));
1987019910

19871-
_this.state = { value: props.value };
19911+
_this.state = {
19912+
value: props.value,
19913+
isFail: false
19914+
};
1987219915
return _this;
1987319916
}
1987419917

1987519918
_createClass(Cell, [{
19919+
key: 'getClassName',
19920+
value: function getClassName() {
19921+
var class_name = 'cell';
19922+
if (this.state.isFail && !this.props.value) {
19923+
class_name += ' fail';
19924+
}
19925+
19926+
return class_name;
19927+
}
19928+
}, {
1987619929
key: 'clickItem',
1987719930
value: function clickItem() {
1987819931
if (!this.props.value) {
@@ -19890,7 +19943,7 @@
1989019943
value: function render() {
1989119944
return _react2.default.createElement(
1989219945
'div',
19893-
{ className: 'cell', onClick: this.clickItem.bind(this) },
19946+
{ className: this.getClassName(), onClick: this.clickItem.bind(this) },
1989419947
this.state.value
1989519948
);
1989619949
}
@@ -19936,7 +19989,7 @@
1993619989

1993719990

1993819991
// module
19939-
exports.push([module.id, "/* prefix 영역 */\n.flex-box {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n}\n/* prefix 영역 */\n* {\n -webkit-user-select: none;\n /* Chrome all / Safari all */\n -moz-user-select: none;\n /* Firefox all */\n -ms-user-select: none;\n /* IE 10+ */\n user-select: none;\n /* Likely future */\n}\nhtml,\nbody {\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n justify-content: center;\n align-items: center;\n}\n.game {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n width: 450px;\n}\n.box {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n width: 150px;\n -moz-box-shadow: inset 0 0 1px #ccc;\n -webkit-box-shadow: inset 0 0 1px #ccc;\n box-shadow: inset 0 0 1px #ccc;\n}\n.cell {\n cursor: pointer;\n width: 50px;\n height: 50px;\n align-items: center;\n display: flex;\n justify-content: center;\n}\n.box:nth-child(even) {\n background: #ccc;\n}\n.cell:nth-child(odd) {\n background: rgba(1, 1, 1, 0.1);\n}\n", ""]);
19992+
exports.push([module.id, "/* prefix 영역 */\n.flex-box {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n}\n/* prefix 영역 */\n* {\n -webkit-user-select: none;\n /* Chrome all / Safari all */\n -moz-user-select: none;\n /* Firefox all */\n -ms-user-select: none;\n /* IE 10+ */\n user-select: none;\n /* Likely future */\n}\nhtml,\nbody {\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n justify-content: center;\n align-items: center;\n}\n.game {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n width: 450px;\n}\n.box {\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n -webkit-flex-flow: row wrap;\n justify-content: space-around;\n width: 150px;\n -moz-box-shadow: inset 0 0 1px #ccc;\n -webkit-box-shadow: inset 0 0 1px #ccc;\n box-shadow: inset 0 0 1px #ccc;\n}\n.cell {\n cursor: pointer;\n width: 50px;\n height: 50px;\n align-items: center;\n display: flex;\n justify-content: center;\n}\n.cell.fail {\n box-shadow: inset 0 0 7px #f00;\n}\n.box:nth-child(even) {\n background: #ccc;\n}\n.cell:nth-child(odd) {\n background: rgba(1, 1, 1, 0.1);\n}\n", ""]);
1994019993

1994119994
// exports
1994219995

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<script src="bower_components/sdoku_maker/dist/js/sdm.min.js"></script>
9+
<!--<script src="bower_components/sdoku_maker/src/pattern.js"></script>
10+
<script src="bower_components/sdoku_maker/src/sdm.js"></script>-->
911
</head>
1012
<body>
1113
<div id="title">

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"jasmine": "^2.4.1",
3939
"less-loader": "^2.2.2",
4040
"react-bootstrap": "^0.28.2",
41+
"selenium-webdriver": "^2.48.2",
4142
"style-loader": "^0.13.0",
4243
"webpack": "^1.12.10"
4344
}

src/box.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default class Box extends Component{
1313
for(let j = 0; j < 3; j++) {
1414
Cells.push(
1515
<Cell
16+
ref={''+ i + j}
1617
key={''+ i + j}
1718
_i= {this.props.position}
1819
_j= {i}

src/cell.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ import './index.less';
44
export default class Cell extends Component{
55
constructor(props) {
66
super(props);
7-
this.state = {value: props.value};
7+
this.state = {
8+
value: props.value,
9+
isFail: false
10+
};
11+
}
12+
13+
getClassName() {
14+
var class_name = 'cell';
15+
if(this.state.isFail && !this.props.value) {
16+
class_name += ' fail';
17+
}
18+
19+
return class_name;
820
}
921

1022
clickItem(...args) {
@@ -15,7 +27,7 @@ export default class Cell extends Component{
1527

1628
render() {
1729
return (
18-
<div className='cell' onClick={this.clickItem.bind(this)}>
30+
<div className={this.getClassName()} onClick={this.clickItem.bind(this)}>
1931
{this.state.value}
2032
</div>
2133
);

src/gameview.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ function cloneObject(object) {
1010
export default class Gameview extends Component{
1111
constructor() {
1212
super();
13-
const gameData = sdm.getGameData('random');
13+
let gameData = sdm.getGameData('random');
1414
this.state = {
1515
gameData: gameData,
16-
userData : cloneObject(gameData.data)
16+
userData: cloneObject(gameData.data),
17+
failCells: []
1718
};
1819
}
1920

@@ -24,6 +25,7 @@ export default class Gameview extends Component{
2425
for(let i = 0; i < 9; i++) {
2526
boxes.push(
2627
<Box
28+
ref={i}
2729
key={i}
2830
position={i}
2931
data={this.state.gameData.data[i]}
@@ -46,6 +48,44 @@ export default class Gameview extends Component{
4648

4749
let {_i, _j, _k} = cell.props;
4850
this.state.userData[_i][_j][_k] = value;
51+
52+
var check_data = sdm.gameDataCheck(this.state.userData);
53+
54+
this.state.failCells.forEach(function (cell) {
55+
cell.setState({
56+
isFail: false
57+
});
58+
});
59+
60+
if(check_data.state === 'fail') {
61+
for(let key in check_data.box) {
62+
var coord = check_data.box[key];
63+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
64+
cell.setState({
65+
isFail : true
66+
});
67+
this.state.failCells.push(cell);
68+
}
69+
for(let key in check_data.rows) {
70+
var coord = check_data.rows[key];
71+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
72+
cell.setState({
73+
isFail : true
74+
});
75+
this.state.failCells.push(cell);
76+
}
77+
for(let key in check_data.cols) {
78+
var coord = check_data.cols[key];
79+
var cell = this.refs[coord._i].refs['' + coord._j + coord._k];
80+
cell.setState({
81+
isFail : true
82+
});
83+
this.state.failCells.push(cell);
84+
}
85+
86+
} else if(check_data.state === 'complete') {
87+
alert('게임완료');
88+
}
4989
}
5090
}
5191

src/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ html, body {
5252
justify-content: center;
5353
}
5454

55+
.cell.fail {
56+
box-shadow: inset 0 0 7px #f00;
57+
}
58+
5559
.box:nth-child(even) {
5660
background: #ccc
5761
}

0 commit comments

Comments
 (0)