Browse Source

Connects 2 players on board

Nikatlas 6 years ago
parent
commit
27191c78b3

+ 1 - 0
src/Game/game/machine/Card.js

@@ -6,6 +6,7 @@ let deck = dg();
 class Card {
     constructor(id = 0) {
         this.attack = deck[id];
+        this.id = id;
     }
 
     setAttack(attack) {

+ 1 - 1
src/Game/services/GameService.js

@@ -32,7 +32,7 @@ class GameService {
         const card = new Game.Card(cardid);
         const move = new Game.GameMoves.PlaceMove(card, position, player);
         try{
-            this.GameMachine.performMove(move);
+            this.GameMachine.runMove(move);
         } catch(e) {
             console.log(e);
             throw e;

+ 4 - 3
src/Game/views/base/Card.js

@@ -127,10 +127,11 @@ class Card extends GuiableContainer{
     }
 
     loadCard(number) {
-        number = parseInt(number+0.5, 10) % 4;
+        const mod = 4;
+        number = parseInt(number+0.5, 10);
         this.card = number;
-        this.imageURL = Deck.Filenames[number];
-        this.sprite.texture = Deck.Textures[number];
+        this.imageURL = Deck.Filenames[number%mod];
+        this.sprite.texture = Deck.Textures[number%mod];
 
         this.machineCard = new Machine.Card(number);
         this.machineCard.attack.forEach((a,i) => this.numbers[i].setText(a));

+ 5 - 5
src/Game/views/buildings/Board.js

@@ -72,13 +72,13 @@ class BoardHandler extends GuiableContainer{
         const data = board.data;
 
         this.holders.forEach((holder, index) => {
-            if ( data[index] && holder.isEmpty() ) {
-                const card = new Card(data[index]);
+            if ( data[index] && !holder.isEmpty() ) {
+                holder.getCard().setTeam(owners[index]);
+            } else if ( data[index] ) {
+                const card = new Card({id: data[index].id});
                 this.addChild(card);
                 card.attach(holder);
-            }
-            if ( data[index] ) {
-                holder.getCard().setTeam(owners[index]);
+                card.setTeam(owners[index]);
             }
         })
     }