Exemplo n.º 1
0
 private void VerifyAsset(GameDef gameDef, PlayerImmutable player, AssetImmutable asset)
 {
     gameDef.ValidateAssetDefId(asset.AssetDefId, $"Player '{player.PlayerId}' Assets");
     if (!gameDef.GetAssetsByPlayerType(player.PlayerType).Any(x => x.Id.Equals(asset.AssetDefId)))
     {
         throw new InvalidGameDefException($"Asset '{asset.AssetDefId}' does not match player's type '{player.PlayerType}'");
     }
 }
Exemplo n.º 2
0
 private void VerifyUnit(GameDef gameDef, PlayerImmutable player, UnitImmutable unit)
 {
     gameDef.ValidateUnitDefId(unit.UnitDefId, $"Player '{player.PlayerId}' Units");
     if (!gameDef.GetUnitsByPlayerType(player.PlayerType).Any(x => x.Id.Equals(unit.UnitDefId)))
     {
         throw new InvalidGameDefException($"Unit {unit.UnitDefId} does not match player's type '{player.PlayerType}'");
     }
 }
Exemplo n.º 3
0
 public static PublicPlayerViewModel ToPublicPlayerViewModel(this PlayerImmutable player, ScoreRepository scoreRepository)
 {
     return(new PublicPlayerViewModel {
         PlayerId = player.PlayerId.Id,
         PlayerName = player.Name,
         Score = scoreRepository.GetScore(player.PlayerId)
     });
 }
Exemplo n.º 4
0
 private void VerifyPlayer(GameDef gameDef, PlayerImmutable player)
 {
     gameDef.ValidatePlayerType(player.PlayerType, $"Player '{player.PlayerId}' PlayerType");
     foreach (var x in player.State.Resources.Keys.ToList())
     {
         VerifyResource(gameDef, player.PlayerId, x);
     }
     foreach (var x in player.State.Units)
     {
         VerifyUnit(gameDef, player, x);
     }
     foreach (var x in player.State.Assets)
     {
         VerifyAsset(gameDef, player, x);
     }
 }