void CreateEntity(string uid, dynamic obj) { obj.timestamp = DateTime.UtcNow.ToString(); int price = -1; Location location = new Location(-1, -1); Building building = new Building(); RoadTile roadTile = new RoadTile(); Entity entity = Entity.ParseToEntity(obj); dynamic errorReason = new ExpandoObject(); if (entity.entityType.Equals(EntityType.BUILDING)) { building = Building.ParseToBuilding(obj); price = building.size * building.size * Constants.Gameplay.BASE_BUILDING_COST; location = building.location; } if (entity.entityType.Equals(EntityType.ROAD)) { roadTile = RoadTile.ParseToRoadTile(obj); price = Constants.Gameplay.ROAD_TILE_COST; location = roadTile.location; } if (city.money - price > 0) { if (!ValidateLocation(location)) { if (entity.entityType.Equals(EntityType.BUILDING)) { buildings.TryAdd(location, building); } else if (entity.entityType.Equals(EntityType.ROAD)) { roadTiles.TryAdd(location, roadTile); } obj.tileTimestamp = UpdateTile(location); Packet okPacket = new Packet(Constants.Networking.PacketTypes.ENTITY_CREATE, obj); server.broadcastPackets.Add(okPacket); return; } else { errorReason.reason = Constants.Networking.PacketTypes.FailReason.ILLEGAL_LOCATION; } } else { errorReason.reason = Constants.Networking.PacketTypes.FailReason.NO_MONEY; } Packet errorPacket = new Packet(Constants.Networking.PacketTypes.OPERATION_FAILED, errorReason); server.GetClient(uid).outgoingPackets.Add(errorPacket); }