public TradeCardInfo ModifyTradeCard(TradeCard tradeCard) { ModifyTradeCards(new List <TradeCard> { tradeCard }, out IEnumerable <TradeCardOperationResult> errors, out IEnumerable <TradeCardInfo> success); if (errors != null && errors.Count() > 0) { throw new EKAERException(errors.First().Result); } return(success.FirstOrDefault()); }
public TradeCardOperationResult ValidateTradeCard(TradeCard tradeCard) { var result = ValidateTradeCards(new List <TradeCard> { tradeCard }); if (result != null && result.Count > 0) { return(result.First()); } return(null); }
public async Task ProcessOtherAsync() { (int yours, int others) = CardsChosen(); if (IsValidMove(yours, others) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (yours == 0 && others == 0) { throw new BasicBlankException("Must have chosen at least one"); } int decks; if (yours == 0) { decks = others; } else if (others == 0) { decks = yours; } else { decks = 0; } if (decks > 0) { if (_gameContainer.BasicData !.MultiPlayer) { await _gameContainer.Network !.SendAllAsync("cardchosen", decks); } var tempCard = _gameContainer.DeckList !.GetSpecificItem(decks); CommandContainer !.ManuelFinish = true; await _mainGame.ChoseSingleCardAsync(tempCard); return; } if (_gameContainer.BasicData !.MultiPlayer) { TradeCard thisTrade = new TradeCard(); thisTrade.YourCard = yours; thisTrade.OtherCard = others; await _gameContainer.Network !.SendAllAsync("cardstraded", thisTrade); } var yourCard = _gameContainer.DeckList !.GetSpecificItem(yours); var opponentCard = _gameContainer.DeckList.GetSpecificItem(others); CommandContainer !.ManuelFinish = true; await _mainGame.TradeCardsAsync(yourCard, opponentCard); }
public TradeCardInfo CreateTradeCard(TradeCard tradeCard) { CreateTradeCards(new List <TradeCard>() { tradeCard }, out IEnumerable <TradeCardOperationResult> errors, out IEnumerable <TradeCardInfo> success); if (errors != null && errors.Count() > 0) { throw new EKAERException(errors.First().Result); } var newCard = success.FirstOrDefault(); return(newCard); }
static TradeCard BuildNewTradeCard() { var tradeCard = new TradeCard { OrderNumber = "1224345", TradeCardType = Schema.Common.TradeCardType.Normal, TradeType = Schema.Common.TradeType.Domestic, SellerName = "Minta eladó Kft.", SellerVatNumber = VATNumber, SellerCountry = "HU", SellerAddress = "4024 Debrecen, Egyik utca 1", DestinationCountry = "HU", DestinationAddress = "1220 Budapest, Másik utca 1", DestinationName = "Minta vevő Kft.", DestinationVatNumber = "12345676", ArrivalDate = DateTime.Now.AddDays(1), ArrivalDateSpecified = true, LoadDate = DateTime.Now, Vehicle = new Vehicle { PlateNumber = "ABC123" } }; var deliveryPlan = new DeliveryPlan { IsDestinationCompanyIdentical = false, LoadLocation = new Location { Country = "HU", Name = "Minta eladó Kft.", VATNumber = "12345676", StreetType = "utca", City = "Debrecen", ZipCode = "4024", Street = "Minta", StreetNumber = "1" }, UnloadLocation = new Location { Country = "HU", Name = "Minta vevő Kft", VATNumber = "12345676", StreetType = "utca", City = "Budapest", ZipCode = "1223", Street = "Minta", StreetNumber = "1" } }; var item = new TradeCardItemType { ProductName = "Sajtos pogácsa", TradeReason = Schema.Common.TradeReason.Sale, Weight = 7500, Value = 1000000, ValueSpecified = true, ProductVtsz = "38248400", ItemOperation = ItemOperation.Create }; deliveryPlan.Items.Add(item); tradeCard.DeliveryPlans.Add(deliveryPlan); return(tradeCard); }
public static List <Card> ReadAllCards() { string strCommand = File.ReadAllText("Database/select_cards_script.sql"); var result = new List <Card>(); using (SQLiteConnection objConnection = new SQLiteConnection(strConnection)) { objConnection.Open(); using (SQLiteCommand command = new SQLiteCommand(strCommand, objConnection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { Card card; var type = (CardType)reader.GetInt32(3); switch (type) { case CardType.MilitaryCard: card = new MilitaryCard(); break; case CardType.CultureCard: card = new CultureCard(); break; case CardType.ResourceCard: card = new ResourceCard(); break; case CardType.ScienceCard: card = new ScienceCard(); break; default: card = new TradeCard(); break; } Read(reader, card); result.Add(card); } } } objConnection.Close(); } return(result); }
public void ExportBussinessCard() { int start = 3101; int end = 3115; //AppDomain.CurrentDomain.ExecuteAssembly //Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); start = Convert.ToInt32(config.AppSettings.Settings["TraderStart"].Value); end = Convert.ToInt32(config.AppSettings.Settings["TraderEnd"].Value); DateTime begin = DateTime.Now; TradeCard card = new TradeCard(); TraderParser parser = new TraderParser(card); parser.Parse(start, end); DateTime finish = DateTime.Now; TimeSpan diff = finish - begin; Console.WriteLine("Finish extract {0} companies in {1}", end - start + 1, diff); Console.Read(); }
public void SetChosenTradeCard(Card card) { chosenTradeCard = card as TradeCard; toPlanet = new List <Card>(); toPlayer = new List <Card>(); }
public bool CheckValidTrade(TradeCard trade, List <Card> toPlayer, List <Card> toPlanet, int fuel) { return(trade.IsLegalTrade(fuel, toPlanet, toPlayer)); }
public void LocalValidate(TradeCard tradeCard) { if (!Validators.IsValidVatNumber(tradeCard.SellerVatNumber)) { throw new ArgumentException("Seller VAT number is not valid"); } if (!Validators.IsValidVatNumber(tradeCard.DestinationVatNumber)) { throw new ArgumentException("Destination VAT number is not valid"); } if (tradeCard.SellerCountry == "HU" && tradeCard.SellerVatNumber.Length != 8) { throw new ArgumentException(string.Format("{0} is not a valid hungarian VAT number", tradeCard.SellerVatNumber)); } if (tradeCard.DestinationCountry == "HU" && tradeCard.DestinationVatNumber.Length != 8) { throw new ArgumentException(string.Format("{0} is not a valid hungarian VAT number", tradeCard.SellerVatNumber)); } if (tradeCard.TradeType == Schema.Common.TradeType.Domestic || tradeCard.TradeType == Schema.Common.TradeType.Export) { if (string.IsNullOrEmpty(tradeCard.SellerCountry)) { throw new ArgumentException("Seller country required when TradeType is Export or Domestic"); } if (string.IsNullOrEmpty(tradeCard.SellerAddress)) { throw new ArgumentException("Seller address required when TradeType is Export or Domestic"); } } if (tradeCard.TradeType == Schema.Common.TradeType.Domestic || tradeCard.TradeType == Schema.Common.TradeType.Import) { if (string.IsNullOrEmpty(tradeCard.DestinationCountry)) { throw new ArgumentException("Destination country required when TradeType is Import or Domestic"); } if (string.IsNullOrEmpty(tradeCard.DestinationAddress)) { throw new ArgumentException("Destination address required when TradeType is Import or Domestic"); } } if (tradeCard.TradeType == Schema.Common.TradeType.Import && tradeCard.SellerCountry.Equals("HU")) { throw new ArgumentException("Seller country must not be HU when TradeType is import"); } if (tradeCard.TradeType == Schema.Common.TradeType.Export && !tradeCard.SellerCountry.Equals("HU")) { throw new ArgumentException("Seller country must be HU when tradeType is Export"); } if (string.IsNullOrEmpty(tradeCard.SellerName)) { throw new ArgumentNullException("SellerName"); } if (string.IsNullOrEmpty(tradeCard.DestinationName)) { throw new ArgumentNullException("DestinationName"); } if (tradeCard.ModByCarrierEnabled && string.IsNullOrEmpty(tradeCard.Carrier)) { throw new ArgumentNullException("If ModByCarrierEnabled then Carrier must not be null"); } if (tradeCard.Items != null) { foreach (var item in tradeCard.Items) { if (item.Value < 0) { throw new ArgumentOutOfRangeException("TradeCardItem.Value must be greater or equal to zero"); } if (item.Value > 0) { item.ValueSpecified = true; } if (item.Weight < 0) { throw new ArgumentOutOfRangeException("Weight must be greater or equal to zero"); } if (string.IsNullOrEmpty(item.ProductName)) { throw new ArgumentNullException("ProductName"); } if (string.IsNullOrEmpty(item.ProductVtsz)) { throw new ArgumentNullException("ProductVTSZ"); } if (!Validators.IsValidVTSZ(item.ProductVtsz)) { throw new ArgumentException("ProductVTSZ"); } } } }