public PlayerPilesViewModel(CommandContainer commandContainer, FlinchGameContainer gameContainer, FlinchVMData model, FlinchMainGameClass mainGame) { gameContainer.SingleInfo = gameContainer.PlayerList !.GetWhoPlayer(); CommandContainer = commandContainer; _model = model; _mainGame = mainGame; _model.StockPile.ClearCards(); //model.StockPile = new Piles.StockViewModel(commandContainer, gameContainer.Aggregator); gameContainer.SingleInfo !.StockList.ForEach(x => { model.StockPile.AddCard(x); }); //model.StockPile.StockFrame.PileList!.ReplaceRange(gameContainer.SingleInfo!.StockList); _model.DiscardPiles = new DiscardPilesVM <FlinchCardInformation>(commandContainer, gameContainer.Aggregator); _model.DiscardPiles.Init(HowManyDiscards); if (gameContainer.SingleInfo !.DiscardList.Count > 0) { model.DiscardPiles !.PileList !.ReplaceRange(gameContainer.SingleInfo.DiscardList); } _model.DiscardPiles.PileClickedAsync += DiscardPiles_PileClickedAsync; _model.StockPile !.StockClickedAsync += StockPile_StockClickedAsync; }
public void SetPriceEffect(PriceEffect effect) { StopCoroutine("PriceEffectTimeout"); StockList.ForEach(stock => { if (stock.CompanyIndustry == effect.AffectedIndustry) { stock.SetExternalEffect(effect); } }); StartCoroutine("PriceEffectTimeout"); }
public void BeginDay() { SetState(MarketState.DayStarted); if (TimeTracker != null) { TimeTracker.StartTracking(); } StockList.ForEach(stock => StartCoroutine(ProcessStock(stock))); DisplayMarketDayStartedMessages(); OnDayStarted(); }
public bool SaveSample(SampleFullInfoModel sample) { using (SunginDataContext sc = new SunginDataContext()) { //基本信息 //BaseInfo.StyleId = (string)sample.styleId; BaseInfo.StyleNo = sample.StyleNo; BaseInfo.DeptName = sample.DeptName; BaseInfo.Color = sample.Color; BaseInfo.Size = sample.Size; BaseInfo.Gauge = sample.Gauge; BaseInfo.Weight = sample.Weight; BaseInfo.CanLendOut = sample.CanLendOut; BaseInfo.Kinds = sample.Kinds; BaseInfo.Counts = sample.Counts; BaseInfo.Material = JsonHelper.ToJson(sample.MaterialItems); BaseInfo.StyleTag = JsonHelper.ToJson(sample.StyleTagItems); if (IsNewSample) { BaseInfo.DdId = currentUser.DdId; } BaseInfo.HaveStock = sample.HaveStock; BaseInfo.CostPrice = sample.CostPrice; BaseInfo.FactoryPrice = sample.FactoryPrice; BaseInfo.SalePrice = sample.SalePrice; BaseInfo.DiscountPrice = sample.DiscountPrice; //大货信息 ProductInfo.StyleId = BaseInfo.StyleId; ProductInfo.ClientName = sample.ClientName; ProductInfo.ProductFactory = sample.ProductFactory; ProductInfo.ProductNum = sample.ProductNum; ProductInfo.Price = sample.Price; if (sample.ProductDate != "") { ProductInfo.ProductDate = DateTime.Parse(sample.ProductDate); } //打样信息 ProofingInfo.StyleId = BaseInfo.StyleId; ProofingInfo.ProofingCompany = (string)sample.ProofingCompany; ProofingInfo.TechnologyPeople = (string)sample.TechnologyPeople; ProofingInfo.ProgamPeople = (string)sample.ProgamPeople; ProofingInfo.WeaveTime = sample.WeaveTime; ProofingInfo.LinkTime = sample.LinkTime; if (sample.ProofingDate != "") { ProofingInfo.ProofingDate = DateTime.Parse(sample.ProofingDate); } //开始保存 //库存信息 if (BaseInfo.HaveStock && sample.StockDataItems.Count > 0) { //如已有数据,则更新,如无则删除 StockList.ForEach(p => { var re = sample.StockDataItems.SingleOrDefault(w => w.Size == p.Size && w.Color == p.Color); if (re != null) { p.Num = re.Num; } else { p.IsDelete = true; } sc.Entry(p).State = System.Data.Entity.EntityState.Modified; sample.StockDataItems.Remove(re); }); //新增数据 sample.StockDataItems.ForEach(p => { sc.GarmentStocks.Add(new GarmentStock { Color = p.Color, Size = p.Size, Num = p.Num, StyleId = BaseInfo.StyleId, StockId = KeyMange.GetKey("Stock") }); }); } if (IsNewSample) { Files.ForEach(p => { if (p.IsDelete) { File.Delete(p.FileUrl); } }); Files.RemoveAll(p => p.IsDelete); BaseInfo.SetCreateUser(currentUser.UserName); sc.SampleBaseInfos.Add(BaseInfo); //写入打样信息 ProofingInfo.SetCreateUser(currentUser.UserName); sc.Proofings.Add(ProofingInfo); //写入文件信息 sc.StyleFiles.AddRange(Files); //写入大货信息 ProductInfo.SetCreateUser(currentUser.UserName); sc.ProductionRecords.Add(ProductInfo); } else { Files.ForEach(p => { if (p.Id == 0) { sc.StyleFiles.Add(p); } else if (p.IsDelete == true) { sc.Entry(p).State = System.Data.Entity.EntityState.Modified; } }); BaseInfo.SetEditUser(currentUser.UserName); ProofingInfo.SetEditUser(currentUser.UserName); ProductInfo.SetEditUser(currentUser.UserName); sc.Entry(BaseInfo).State = System.Data.Entity.EntityState.Modified; if (ProofingInfo.Id > 0) { sc.Entry(ProofingInfo).State = System.Data.Entity.EntityState.Modified; } else { sc.Entry(ProofingInfo).State = System.Data.Entity.EntityState.Added; } if (ProductInfo.Id > 0) { sc.Entry(ProductInfo).State = System.Data.Entity.EntityState.Modified; } else { sc.Entry(ProductInfo).State = System.Data.Entity.EntityState.Added; } }; SetSeachStr(); sc.SaveChanges(); } return(true); }
private IEnumerator PriceEffectTimeout() { yield return(new WaitForSeconds(PriceEffectDuration)); StockList.ForEach(stock => stock.ClearExternalEffect()); }
private void UpdateStockWeight() { StockList.ForEach(x => x.StockWeight = x.MarketValue / TotalMarketValue); }