|
@@ -7,6 +7,7 @@ import CardHolder from '../base/CardHolder';
|
|
// import CollectionHolder from '../base/CollectionHolder';
|
|
// import CollectionHolder from '../base/CollectionHolder';
|
|
import Injector from '../../services/Injector';
|
|
import Injector from '../../services/Injector';
|
|
import Text from '../misc/Text';
|
|
import Text from '../misc/Text';
|
|
|
|
+import Card from '../base/Card';
|
|
|
|
|
|
class BoardHandler extends GuiableContainer{
|
|
class BoardHandler extends GuiableContainer{
|
|
constructor(props) {
|
|
constructor(props) {
|
|
@@ -47,8 +48,6 @@ class BoardHandler extends GuiableContainer{
|
|
bg.scale.set(1.75);
|
|
bg.scale.set(1.75);
|
|
this.addChild(bg);
|
|
this.addChild(bg);
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
this.holders = [];
|
|
this.holders = [];
|
|
this.holders.push(new CardHolder({GameLayer, 'x': -220, 'y': -230, team: 0, id: 4}).scaleTo(BoardScale).onDrop((c) => this.placeCard(0, c)));
|
|
this.holders.push(new CardHolder({GameLayer, 'x': -220, 'y': -230, team: 0, id: 4}).scaleTo(BoardScale).onDrop((c) => this.placeCard(0, c)));
|
|
this.holders.push(new CardHolder({GameLayer, 'x': -50, 'y': -230, team: 1, id: 5}).scaleTo(BoardScale).onDrop((c) => this.placeCard(1, c)));
|
|
this.holders.push(new CardHolder({GameLayer, 'x': -50, 'y': -230, team: 1, id: 5}).scaleTo(BoardScale).onDrop((c) => this.placeCard(1, c)));
|
|
@@ -68,6 +67,22 @@ class BoardHandler extends GuiableContainer{
|
|
this.addChild(this.score);
|
|
this.addChild(this.score);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ sync = (board) => {
|
|
|
|
+ const owners = board.owners;
|
|
|
|
+ const data = board.data;
|
|
|
|
+
|
|
|
|
+ this.holders.forEach((holder, index) => {
|
|
|
|
+ if ( data[index] && holder.isEmpty() ) {
|
|
|
|
+ const card = new Card(data[index]);
|
|
|
|
+ this.addChild(card);
|
|
|
|
+ card.attach(holder);
|
|
|
|
+ }
|
|
|
|
+ if ( data[index] ) {
|
|
|
|
+ holder.getCard().setTeam(owners[index]);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
updateScore() {
|
|
updateScore() {
|
|
let score = this.holders.reduce((a,b) => {
|
|
let score = this.holders.reduce((a,b) => {
|
|
if(!b.isEmpty()){
|
|
if(!b.isEmpty()){
|