Skip to content

Commit dce2891

Browse files
author
ernestodebesto
committed
zadania
1 parent 9b2b3d3 commit dce2891

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

.DS_Store

2 KB
Binary file not shown.

css/style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
.row {
23
display:flex;
34
}
@@ -35,6 +36,7 @@ button {
3536
align-items: center;
3637
flex-direction: column;
3738
margin-top: 100px;
39+
3840
}
3941

4042
.game-title {

img/.DS_Store

6 KB
Binary file not shown.

img/bck.gif

1.98 MB
Loading

js/out.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9812,21 +9812,27 @@ document.addEventListener('DOMContentLoaded', function () {
98129812
if (winner === 'human') {
98139813
var num = _this.state.humanPoints + 1;
98149814
_this.setState({
9815-
humanPoints: num
9815+
humanPoints: num,
9816+
end: true
98169817
});
98179818
_this.stopAndReset();
98189819
} else {
98199820
console.log('komputer wygral');
98209821
var _num = _this.state.computerPoints + 1;
98219822
_this.setState({
9822-
computerPoints: _num
9823+
computerPoints: _num,
9824+
end: true
98239825
});
98249826
_this.stopAndReset();
98259827
}
98269828
};
98279829

98289830
_this.moveAI = function () {
9829-
_this.checkWinAI();
9831+
if (_this.state.end) {
9832+
console.log('koniec gry');
9833+
} else {
9834+
_this.checkWinAI();
9835+
}
98309836
};
98319837

98329838
_this.stopAndReset = function () {
@@ -9856,7 +9862,9 @@ document.addEventListener('DOMContentLoaded', function () {
98569862
_this.checkDraw = function () {
98579863
if (_this.state.moveNumber === 9) {
98589864
console.log('remis');
9859-
_this.stopAndReset();
9865+
_this.setState({
9866+
end: true
9867+
});
98609868
} //pokaz przycisk restart, zatrzymaj gre, wywolaj metode endgame(remis, kazdy po punkcie)
98619869
};
98629870

@@ -10046,7 +10054,8 @@ document.addEventListener('DOMContentLoaded', function () {
1004610054
moveNumber: 0,
1004710055
player: 'human',
1004810056
computerPoints: 0,
10049-
humanPoints: 0
10057+
humanPoints: 0,
10058+
end: false
1005010059
};
1005110060
return _this;
1005210061
}
@@ -10148,18 +10157,13 @@ document.addEventListener('DOMContentLoaded', function () {
1014810157
// kiedy gracz zaczyna
1014910158

1015010159

10151-
//niech gra sie zaczyna - 2 divy - graj pierwszy (obrazek) graj drugi(obrezaek) jeden pod drugim.
10152-
// Jesli bedzie czas to dodac licznik. podzielic jakos plansze na czlowiek kontra komputer.
10153-
10154-
//jeden przycisk - zamien strony. kroy zaczyna dzialanie ai. dwa rodzaje buttonow - ludzki i komputerowy. i wtedy klasa x zawsze bedzie dla komputera i wyeliminuje to problem zmiany klas.
10155-
//dodaj tez do kazdego z tych warunkow to ze przy wygranej ukazuje sie animacja
10156-
1015710160
// akcja dla wygranej
1015810161
//zatrzymaj cala gre, dodaj punkt, pokaz przycisk restart, pokaz animacje w miejscu gdzie trzeba zrobic animacje
1015910162

1016010163

1016110164
//tu bedzie caly ai
1016210165

10166+
1016310167
//generator losowego ruchu
1016410168

1016510169
//sprawdz remis

js/zadanie01.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ document.addEventListener('DOMContentLoaded', function() {
2424
player: 'human',
2525
computerPoints: 0,
2626
humanPoints: 0,
27+
end : false
2728
}
2829
}
2930
render() {
@@ -86,25 +87,21 @@ document.addEventListener('DOMContentLoaded', function() {
8687
}
8788
}
8889

89-
//niech gra sie zaczyna - 2 divy - graj pierwszy (obrazek) graj drugi(obrezaek) jeden pod drugim.
90-
// Jesli bedzie czas to dodac licznik. podzielic jakos plansze na czlowiek kontra komputer.
91-
92-
//jeden przycisk - zamien strony. kroy zaczyna dzialanie ai. dwa rodzaje buttonow - ludzki i komputerowy. i wtedy klasa x zawsze bedzie dla komputera i wyeliminuje to problem zmiany klas.
93-
//dodaj tez do kazdego z tych warunkow to ze przy wygranej ukazuje sie animacja
94-
9590
// akcja dla wygranej
9691
endGame = (winner) => {
9792
if (winner === 'human'){
9893
let num = this.state.humanPoints+1
9994
this.setState({
10095
humanPoints : num,
96+
end : true
10197
});
10298
this.stopAndReset();
10399
} else {
104100
console.log('komputer wygral');
105101
let num = this.state.computerPoints+1
106102
this.setState({
107103
computerPoints : num,
104+
end : true,
108105
});
109106
this.stopAndReset();
110107
}
@@ -113,13 +110,20 @@ document.addEventListener('DOMContentLoaded', function() {
113110

114111
//tu bedzie caly ai
115112
moveAI = () => {
113+
if (this.state.end) {
114+
console.log('koniec gry');
115+
} else {
116116
this.checkWinAI();
117117
}
118+
}
118119

119120

120121
stopAndReset = () => {
121122
console.log('restee');
122123
}
124+
125+
126+
123127
//generator losowego ruchu
124128
randomMove = () => {
125129
let randomMove = Math.floor(Math.random() * 9);
@@ -146,7 +150,9 @@ document.addEventListener('DOMContentLoaded', function() {
146150
checkDraw = () => {
147151
if (this.state.moveNumber === 9) {
148152
console.log('remis');
149-
this.stopAndReset();
153+
this.setState({
154+
end : true,
155+
});
150156
} //pokaz przycisk restart, zatrzymaj gre, wywolaj metode endgame(remis, kazdy po punkcie)
151157
}
152158
restartGame = () => {}

0 commit comments

Comments
 (0)