From 880d2ef7c45f2596a15e7a661764ef43005f30fe Mon Sep 17 00:00:00 2001 From: Jakob Haag Date: Thu, 25 Jun 2020 18:09:38 +0200 Subject: [PATCH] Check if the attacked base is an enemy base or not and update the label according to this --- GoldWars/GoldWars/Entities/Base.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Entities/Base.swift b/GoldWars/GoldWars/Entities/Base.swift index 65e0c3c..8166bad 100644 --- a/GoldWars/GoldWars/Entities/Base.swift +++ b/GoldWars/GoldWars/Entities/Base.swift @@ -51,7 +51,11 @@ class Base: GKEntity{ self.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(self.unitCount)" if base.component(ofType: TeamComponent.self)?.unitcountLabel.text != "" { - base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)" + if base.ownershipPlayer != self.ownershipPlayer { + base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(abs(base.unitCount - units * 2))" + } else { + base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)" + } } DataService.sharedInstance.addMove(playerMove: PlayerMove(fromBase: self.baseID, toBase: base.baseID,