Exemple #1
0
 private AssetViewModel CreateAssetViewModel(AssetDef assetDef)
 {
     return(new AssetViewModel {
         Definition = AssetDefinitionViewModel.Create(assetDef),
         Built = assetRepository.HasAsset(currentUserContext.PlayerId, assetDef.Id),
         Prerequisites = string.Join(", ", gameDef.GetAssetNames(assetDef.Prerequisites)),
         PrerequisitesMet = assetRepository.PrerequisitesMet(currentUserContext.PlayerId, assetDef),
         Cost = CostViewModel.Create(assetDef.Cost),
         CanAfford = resourceRepository.CanAfford(currentUserContext.PlayerId, assetDef.Cost),
         AlreadyQueued = assetRepository.IsBuildQueued(currentUserContext.PlayerId, assetDef.Id),
         TicksLeftForBuild = assetRepository.TicksLeft(currentUserContext.PlayerId, assetDef.Id),
         AvailableUnits = gameDef.GetUnitsForAsset(assetDef.Id)
                          .Select(x => UnitDefinitionViewModel.Create(x, unitRepository.PrerequisitesMet(currentUserContext.PlayerId, x))).ToList()
     });
 }