Skip to content

Commit 4ce1992

Browse files
committed
on the way to checking which moves are possible
1 parent 51d232b commit 4ce1992

28 files changed

+447
-27
lines changed

Chess/ApplicationComponent.html

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
<h1>AngularJS 2.0 plays Chess!</h1>
1+
<div class="container">
2+
<div class="row">
3+
<div class="col-md-12">
4+
<h1>AngularJS 2.0 plays Chess!</h1>
5+
</div>
6+
</div>
7+
<div class="row">
8+
<div class="col-md-8">
9+
<div class="panel panel-primary">
10+
<div class="panel-heading">
11+
<h3 class="panel-title">{{title}}</h3>
12+
</div>
13+
<div class="panel-body">
14+
<div class="row">
15+
<div class="col-md-10">
16+
<chessboard></chessboard>
17+
</div>
18+
<div class="col-md-2">
19+
<captured-pieces />
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
</div>
225

3-
4-
<chessboard></chessboard>
26+
<div class="col-md-4">
27+
<div class="panel panel-primary">
28+
<div class="panel-heading">
29+
<h3 class="panel-title">History</h3>
30+
</div>
31+
<div class="panel-body">
32+
<history></history>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</div>

Chess/CapturedPiecesComponent.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<img src="wikimediaimages/w_pawn.png" style="height:68px; width:68px" />
2+
<img src="wikimediaimages/w_bishop.png" style="height:68px; width:68px" />

Chess/FieldComponent.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div style="position: relative; left: 0px; top: 0px; width: 70px; height: 70px;margin-right:-4px; display: inline-block" >
1+
<div style="position: relative; left: 0px; top: 0px; width: 70px; height: 70px;margin-right:-6px; margin-bottom:-1px; display: inline-block" >
22
<div style="position: relative; top: 0px; left: 0px" >
33
<img class="{{borderClass(row,col)}}" src="{{backgroundFileName(row,col)}}" />
44
</div>

Chess/HistoryComponent.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In a future version, this will show the move history.

Chess/applicationcomponent.js

+10-4
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/// <reference path="chessboard.ts" />
33
import {Component, View, bootstrap} from 'angular2/angular2';
44
import {ChessBoardComponent} from "./chessboardcomponent";
5+
import {CapturedPiecesComponent} from './capturedpiecescomponent';
56
import {Engine} from "./engine/chessboard";
7+
import {HistoryComponent} from './historycomponent';
68

79
// Annotation section
810
@Component({
@@ -11,10 +13,13 @@ import {Engine} from "./engine/chessboard";
1113
})
1214
@View({
1315
templateUrl: 'ApplicationComponent.html',
14-
directives: [ChessBoardComponent]
16+
directives: [ChessBoardComponent, HistoryComponent, CapturedPiecesComponent]
1517
})
1618
// Component controller
1719
class ApplicationComponent {
20+
constructor(private chessboard:Engine.ChessboardUI) {}
21+
22+
public get title(): String { return this.chessboard.isWhitePlaying?"White move":"Black move"}
1823
}
1924

2025
bootstrap(ApplicationComponent);

Chess/capturedpiecescomponent.js

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

Chess/capturedpiecescomponent.js.map

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

Chess/capturedpiecescomponent.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="typings/angular2/angular2.d.ts" />
2+
import {Component, View, NgFor, bootstrap, Query, QueryList} from 'angular2/angular2';
3+
import {Engine} from './engine/chessboard';
4+
5+
@Component({
6+
selector: 'captured-pieces'
7+
})
8+
@View({
9+
directives: [NgFor],
10+
templateUrl: 'CapturedPiecesComponent.html'
11+
})
12+
export class CapturedPiecesComponent {
13+
constructor(private chessboard:Engine.ChessboardUI) { console.log("Cap ")}
14+
}

Chess/cheat.sheet

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ EmberJS vs. Backbone.js vs. Angular:
6464
Atom:
6565
install package atomatigit for full GIT support (open the panel by hitting cmd-alt-g)
6666
install atom-typescript
67+
install atom-beautify (optional)
6768

6869
Error messages:
6970
"The selector "chessboard" did not match any elements" means that the HTML file doesn't contain a widget corresponding to the
@@ -75,6 +76,10 @@ Dependency Injection:
7576
add the service implementation class to the app's list of component bindings,
7677
and add the service to the parameter list of the component that needs the service.
7778

79+
Everything is a tree!
80+
* You always have to define the component you want to use as child components in the parent component. Otherwise,
81+
they simply won't be rendered. More precisely, their source code or pseudo tag will be rendered.
82+
7883
Links:
7984
http://www.angular2.com/
8085
https://github.com/stephanrauh/ExploringAngular

Chess/chess.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.field {
22
border: 1px solid black;
3-
width:68px;height:68px;
3+
width:69px;height:69px;
44
}
55

66
.selectedField { border: 2px solid red;
7-
width:66px;
8-
height:64px;
9-
top:-2px;
7+
width:68px;
8+
height:68px;
9+
top:0px;
1010
position:relative;
1111
}

Chess/engine/chessboard.js

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

0 commit comments

Comments
 (0)