Skip to content

Commit 2154b8d

Browse files
committed
added the revert-last-move button
1 parent 2cbb5e1 commit 2154b8d

19 files changed

+264
-47
lines changed

Chess/ApplicationComponent.html

+5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ <h3 class="panel-title">{{title}}</h3>
1414
<div class="row">
1515
<div class="col-md-9">
1616
<chessboard></chessboard>
17+
<br />
18+
<button type="button" class="btn btn-primary" (click)="suggestMove()">Suggest move</button>
19+
<button type="button" class="btn btn-primary" (click)="turnSides()">Turn sides</button>
20+
<button type="button" class="btn btn-danger" (click)="revertLastMove()">Revert last move</button>
1721
</div>
22+
1823
<div class="col-md-3">
1924
<captured-pieces />
2025
</div>

Chess/FieldComponent.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
(click)="onclick(row, col)"
1111
/>
1212
</div>
13-
<div style="position: absolute; top: 0px; left: 0px;">
13+
<!--
14+
<div style="position: absolute; top: 0px; left: 0px" >
1415
{{ownThreats(row, col)}} / {{opponentThreats(row, col)}}
1516
</div>
17+
-->
1618
</div>

Chess/applicationcomponent.js

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/applicationcomponent.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chess/applicationcomponent.ts

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ class ApplicationComponent {
3131
result += " Player is in check!";
3232
return result
3333
}
34+
35+
public suggestMove(): boolean {
36+
alert("Suggest move hasn't been implemented yet");
37+
return false;
38+
}
39+
40+
public turnSides(): boolean {
41+
alert("Turn sides hasn't been implemented yet");
42+
return false;
43+
}
44+
45+
public revertLastMove(): boolean {
46+
this.chessboard.revertLastMove();
47+
return false;
48+
}
3449
}
3550

3651
bootstrap(ApplicationComponent);

Chess/cheat.sheet

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ Dependency Injection:
8585
TypeScript modules:
8686
http://typescript.codeplex.com/wikipage?title=Modules%20in%20TypeScript&referringTitle=TypeScript%20Documentation
8787

88+
TypeScript:
89+
Never forget to add "this." to refer to instance methods and variables
90+
interesting / intuitive approach to getters and setters
91+
8892
Everything is a tree!
8993
* You always have to define the component you want to use as child components in the parent component. Otherwise,
9094
they simply won't be rendered. More precisely, their source code or pseudo tag will be rendered.

Chess/chess.css

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@
1818
top:0px;
1919
position:relative;
2020
}
21+
22+
.threatenedField {
23+
border: 2px solid red;
24+
width:52px;
25+
height:52px;
26+
top:0px;
27+
position:relative;
28+
}

Chess/engine/chessboard.js

+54-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)