diff --git a/GoldWars/GoldWars/Entities/Base.swift b/GoldWars/GoldWars/Entities/Base.swift index 8f14a8b..ba1bbdc 100644 --- a/GoldWars/GoldWars/Entities/Base.swift +++ b/GoldWars/GoldWars/Entities/Base.swift @@ -49,9 +49,11 @@ class Base: GKEntity{ self.unitCount -= units base.unitCount += units self.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(self.unitCount)" - if base.ownershipPlayer == GKLocalPlayer.local { + + if base.component(ofType: TeamComponent.self)?.unitcountLabel.text != "" { base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)" } + base.ownershipPlayer = self.ownershipPlayer DataService.sharedInstance.addMove(playerMove: PlayerMove(fromBase: self.baseID, toBase: base.baseID, diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 7dcce67..412e736 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -109,10 +109,11 @@ class Modal: GKEntity{ } func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, gameScene: GameScene, collisionBase: Base?){ + let moveType: PlayerMoveType = self.type == ModalType.BaseAttack ? .AtkMove : .TxnMove for base in currentDraggedBase!.adjacencyList { if base == collisionBase { RoundCalculatorService.sharedInstance.increaseMoveCounter(ownBase: currentDraggedBase?.ownershipPlayer == base.ownershipPlayer) - entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: Int(GameScene.sendUnits)))!) + entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: moveType, units: Int(GameScene.sendUnits)))!) GameScene.sendUnits = 0 } } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 812e3fc..f4f431b 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -264,7 +264,7 @@ class GameScene: SKScene{ } func isAttackMove() -> Bool { - return collisionBase?.ownershipPlayer != currentDraggedBase?.ownershipPlayer + return collisionBase?.ownershipPlayer != currentDraggedBase?.ownershipPlayer && !(collisionBase?.changeOwnership ?? false) } @objc func pauseGame() -> Void {