* Minor fixes
* Open up calculator service
This commit is contained in:
parent
f60e97a866
commit
2ac82e5159
@ -21,7 +21,6 @@
|
||||
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */; };
|
||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; };
|
||||
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */; };
|
||||
3FE19DB3246C690B004827AB /* RoundSimulatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB2246C690B004827AB /* RoundSimulatorService.swift */; };
|
||||
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; };
|
||||
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; };
|
||||
9E11FF79245CD81100EED3BE /* Fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E11FF77245CD81100EED3BE /* Fire.sks */; };
|
||||
@ -92,7 +91,6 @@
|
||||
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterHelper.swift; sourceTree = "<group>"; };
|
||||
3EBD242D245D9332003CECE7 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = "<group>"; };
|
||||
3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerMoveType.swift; sourceTree = "<group>"; };
|
||||
3FE19DB2246C690B004827AB /* RoundSimulatorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundSimulatorService.swift; sourceTree = "<group>"; };
|
||||
3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundCalculatorService.swift; sourceTree = "<group>"; };
|
||||
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = "<group>"; };
|
||||
9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = "<group>"; };
|
||||
@ -283,7 +281,6 @@
|
||||
children = (
|
||||
110360DC244B101A008610AF /* Main.storyboard */,
|
||||
110360E1244B101B008610AF /* LaunchScreen.storyboard */,
|
||||
3FE19DB2246C690B004827AB /* RoundSimulatorService.swift */,
|
||||
);
|
||||
path = Storyboards;
|
||||
sourceTree = "<group>";
|
||||
@ -421,7 +418,6 @@
|
||||
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */,
|
||||
110360D9244B101A008610AF /* GameScene.swift in Sources */,
|
||||
C04783F024685995004961FB /* SettingsScene.swift in Sources */,
|
||||
3FE19DB3246C690B004827AB /* RoundSimulatorService.swift in Sources */,
|
||||
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */,
|
||||
C064E9AA246C114C0022B228 /* LabelComponent.swift in Sources */,
|
||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
|
||||
|
@ -26,6 +26,7 @@ class TimerComponent: GKComponent {
|
||||
|
||||
func startWithDuration(duration: TimeInterval){
|
||||
endTime = Date().addingTimeInterval(duration)
|
||||
RoundCalculatorService.sharedInstance.isCalculating = false
|
||||
}
|
||||
|
||||
func timeLeft() -> Int {
|
||||
|
@ -46,6 +46,7 @@ class MultiplayerNetwork{
|
||||
let encoded = (try? encoder.encode(playerMoves))!
|
||||
sendDataToHost(data: encoded)
|
||||
}
|
||||
DataService.sharedInstance.localPlayerMoves.removeAll()
|
||||
}
|
||||
|
||||
func sendHostIdentifier() {
|
||||
|
@ -73,27 +73,29 @@ class RoundCalculatorService {
|
||||
combinePotentionalForces[playerMoves.key]!.unitCount += move.unitCount
|
||||
}
|
||||
}
|
||||
|
||||
let sortedPotentionalCombinedForces = combinePotentionalForces.sorted { $0.1.unitCount > $1.1.unitCount }
|
||||
|
||||
var playerMoveWithMaxUnits = sortedPotentionalCombinedForces[0]
|
||||
if playerMovesByBase.count >= 2 {
|
||||
let playerMoveWithSecMaxUnits = sortedPotentionalCombinedForces[1]
|
||||
playerMoveWithMaxUnits.value.unitCount -= playerMoveWithSecMaxUnits.value.unitCount
|
||||
}
|
||||
|
||||
for base in currentSnapshotModel!.baseEntites {
|
||||
if base.baseId == playerMoveWithMaxUnits.value.toBase {
|
||||
base.unitCount += playerMoveWithMaxUnits.value.unitCount
|
||||
if playerMoveWithMaxUnits.value.unitCount == 0 {
|
||||
base.ownership = nil
|
||||
} else {
|
||||
base.ownership = playerMoveWithMaxUnits.key
|
||||
if(combinePotentionalForces.count > 0) {
|
||||
let sortedPotentionalCombinedForces = combinePotentionalForces.sorted { $0.1.unitCount > $1.1.unitCount }
|
||||
|
||||
var playerMoveWithMaxUnits = sortedPotentionalCombinedForces[0]
|
||||
if playerMovesByBase.count >= 2 {
|
||||
let playerMoveWithSecMaxUnits = sortedPotentionalCombinedForces[1]
|
||||
playerMoveWithMaxUnits.value.unitCount -= playerMoveWithSecMaxUnits.value.unitCount
|
||||
}
|
||||
|
||||
for base in currentSnapshotModel!.baseEntites {
|
||||
if base.baseId == playerMoveWithMaxUnits.value.toBase {
|
||||
base.unitCount += playerMoveWithMaxUnits.value.unitCount
|
||||
if playerMoveWithMaxUnits.value.unitCount == 0 {
|
||||
base.ownership = nil
|
||||
} else {
|
||||
base.ownership = playerMoveWithMaxUnits.key
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
baseSpecificMoves.removeValue(forKey: baseId)
|
||||
}
|
||||
allPlayerMoves.removeAll()
|
||||
MultiplayerNetwork.sharedInstance.sendSnapshotModelToPlayers()
|
||||
EntityManager.sharedInstance.updateSnapshotModel(snapshotModel: currentSnapshotModel!)
|
||||
os_log("Finished calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
||||
|
Loading…
Reference in New Issue
Block a user