public object ExecuteCommand(dynamic args, GameState gameState) { dynamic payload = args.jsonObj.payload; string uuidFrom = payload.uuidFrom; (Tower towerFrom, Tower towerTo) = GetTowersFromJsonArgs(args as Object, gameState); Tower towerFromCopy = towerFrom.Clone(); towerFromCopy.owner = uuidFrom; IMoveToStrategy moveToStrategy = DetermineStrategy(towerFromCopy, towerTo); int movingUnitCount = payload.unitCount; moveToStrategy.ExecuteStrategy(towerFromCopy, towerTo, movingUnitCount); return(FormatCommand(towerTo)); }
public object ExecuteCommand(dynamic args, GameState gameState) { (Tower towerFrom, Tower towerTo) = GetTowersFromJsonArgs(args as Object, gameState); ValidateMovementBetweenTowers(towerFrom, towerTo); int movingUnitCount = GetMovingUnitCountFromTower(towerFrom); IMoveToStrategy strategy = DetermineStrategy(towerFrom, towerTo); strategy.ExecuteStrategy(towerFrom, towerTo, movingUnitCount); int movementTimeInSeconds = CalculateMovementTimeBetweenTwoTowers(towerFrom, towerTo, gameState.GetGameSpeed()); string uuidFrom = towerFrom.owner; return(FormatCommand(towerFrom, towerTo, movementTimeInSeconds, movingUnitCount)); }