Impl. global unit count increasement functionality after each round

This commit is contained in:
Aldin Duraki 2020-05-31 11:09:48 +02:00
parent f0a5f5d15c
commit 96eb25de65

View File

@ -125,6 +125,27 @@ class RoundCalculatorService {
DataService.sharedInstance.localRoundData.localPlayerMoves.removeAll()
DataService.sharedInstance.localRoundData.hasAttackBoost = false
DataService.sharedInstance.localRoundData.hasDefenceBoost = false
var player1BaseCount = 0;
var player2BaseCount = 0;
let player1 = Array(allPlayerMoves)[0].key
let player2 = Array(allPlayerMoves)[1].key
for baseEntry in currentSnapshotModel!.baseEntites {
if baseEntry.ownership == player1 {
player1BaseCount += 1
} else if baseEntry.ownership == player2 {
player2BaseCount += 1
}
}
currentSnapshotModel?.baseEntites = currentSnapshotModel!.baseEntites.map { (BaseEntityModel) -> BaseEntityModel in
if BaseEntityModel.ownership == player1 {
BaseEntityModel.unitCount += lround(Double(player1BaseCount / 2))
} else if BaseEntityModel.ownership == player2 {
BaseEntityModel.unitCount += lround(Double(player2BaseCount / 2))
}
return BaseEntityModel
}
allPlayerMoves.removeAll()
DataService.sharedInstance.localPlayerMoves.removeAll()
MultiplayerNetwork.sharedInstance.sendSnapshotModelToPlayers()
DataService.sharedInstance.snapshotModel = currentSnapshotModel
entityManager.updateSnapshotModel(snapshotModel: currentSnapshotModel!)