Fixed scope issue on collected playerMoves

This commit is contained in:
Aldin Duraki 2020-06-02 11:01:15 +02:00
parent eaa71d1d73
commit 42f4537dc6

View File

@ -35,7 +35,7 @@ class RoundCalculatorService {
var baseSpecificMoves = collectBaseSpecificMoves() var baseSpecificMoves = collectBaseSpecificMoves()
// TODO: Refactor to a less complex way // TODO: Refactor to a less complex way
for (baseId, var playerMovesByBase) in baseSpecificMoves { for (baseId, playerMovesByBase) in baseSpecificMoves {
let targetBase = currentSnapshotModel?.baseEntites.filter { $0.baseId == baseId }[0] let targetBase = currentSnapshotModel?.baseEntites.filter { $0.baseId == baseId }[0]
let possiblyOwnershipMoves = playerMovesByBase.filter { $0.key == targetBase?.ownership} let possiblyOwnershipMoves = playerMovesByBase.filter { $0.key == targetBase?.ownership}
@ -50,10 +50,10 @@ class RoundCalculatorService {
} }
} }
} }
playerMovesByBase.removeValue(forKey: playerName) baseSpecificMoves[baseId]!.removeValue(forKey: playerName)
} }
for (_, playerMoves) in playerMovesByBase { for playerMoves in baseSpecificMoves[baseId]!.values {
for playerMove in playerMoves { for playerMove in playerMoves {
for base in currentSnapshotModel!.baseEntites { for base in currentSnapshotModel!.baseEntites {
if base.baseId == playerMove.fromBase { if base.baseId == playerMove.fromBase {