/// <summary>
    /// Resets all data
    /// </summary>
    public void Reset()
    {
        LastWidth.Clear();
        LastThickness.Clear();
        LastRunConfigurationGroups.Clear();
        SalesList.Clear();
        PredictionList.Clear();
        LastRunMachine.Clear();
        PriorityList.Clear();
        foreach (var line in StaticFactoryValuesManager.CoatingLines)
        {
            ScheduledItem[line] = false;
        }
        CurrentWaste = StaticFactoryValuesManager.CurrentWaste;

        if (CurrentInventory == null)
        {
            CurrentInventory = new List <InventoryItem>();
        }
        CurrentInventory.Clear();

        if (PrereqMakeOrders == null)
        {
            PrereqMakeOrders = new List <PrereqMakeOrder>();
        }
        PrereqMakeOrders.Clear();
    }
    private List <MakeOrder> GetPredictions()
    {
        var predictions = new List <MakeOrder>();

        foreach (var master in StaticInventoryTracker.ProductMasterList) //.Where(p => p.MadeIn.Equals("Coating")))
        {
            double pieces = master.PiecesPerUnit * master.TargetSupply;

            StaticFunctions.OutputDebugLine("Creating new prediction for " + master);
            MakeOrder newOrder = new MakeOrder(master.MasterID, pieces)
            {
                DueDay = CurrentDay
            };
            // assume the current day is the due date unless we have inventory data (Could have no inventory)
            // forecast out when the order should be due
            var inv = CurrentInventory.FirstOrDefault(i => i.MasterID == master.MasterID);
            if (inv != null)
            {
                double currentInv  = inv.Units;
                double usedPerDay  = GetAvgUnitsPerDay(master) * 30;
                int    daysTillOut = (int)Math.Floor(currentInv / usedPerDay);
                newOrder.DueDay = CurrentDay.AddDays(daysTillOut);
                StaticFunctions.OutputDebugLine("Found inventory of " + currentInv + " for prediction " + master +
                                                " predicted to run out in " + daysTillOut + " days");
            }
            predictions.Add(newOrder);
        }

        return(predictions);
    }
    public void RemoveFilledSales()
    {
        List <MakeOrder> filledSales = new List <MakeOrder>();

        // Sales list already sorted by due date. No issue with filling in order.
        foreach (var saleOrder in SalesList)
        {
            var invItem = CurrentInventory.FirstOrDefault(i => saleOrder.MasterID == i.MasterID);
            if (invItem != null)
            {
                // If enough in inventory, fill order and remove from inventory
                if (invItem.TotalPieces >= saleOrder.PiecesToMake)
                {
                    invItem.Units -= (saleOrder.PiecesToMake / invItem.PiecesPerUnit);
                    filledSales.Add(saleOrder);
                }
                else
                {
                    // not enough inventory. Remove what we can from inventory and reduce the sale order needed.
                    saleOrder.PiecesToMake -= invItem.TotalPieces;
                    invItem.Units           = 0;
                }
            }
        }

        foreach (var filledSale in filledSales)
        {
            SalesList.Remove(filledSale);
        }
    }
        public ActionResult DeleteConfirmed(int id)
        {
            CurrentInventory currentInventory = db.CurrentInventories.Find(id);

            db.CurrentInventories.Remove(currentInventory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void SetInventory()
 {
     foreach (var allInventoryItem in StaticInventoryTracker.AllInventoryItems)
     {
         CurrentInventory.Add(new InventoryItem(allInventoryItem.ProductCode, allInventoryItem.Units,
                                                allInventoryItem.PiecesPerUnit, allInventoryItem.Grade, allInventoryItem.MasterID,
                                                allInventoryItem.InventoryItemID));
     }
 }
 public ActionResult Edit([Bind(Include = "Id,IngredientId,AvailableQuantity")] CurrentInventory currentInventory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currentInventory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IngredientId = new SelectList(db.Ingredients, "Id", "Ingredient", currentInventory.IngredientId);
     return(View(currentInventory));
 }
        // GET: CurrentInventories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CurrentInventory currentInventory = db.CurrentInventories.Find(id);

            if (currentInventory == null)
            {
                return(HttpNotFound());
            }
            return(View(currentInventory));
        }
        // GET: CurrentInventories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CurrentInventory currentInventory = db.CurrentInventories.Find(id);

            if (currentInventory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IngredientId = new SelectList(db.Ingredients, "Id", "Ingredient", currentInventory.IngredientId);
            return(View(currentInventory));
        }
Ejemplo n.º 9
0
    public void SetHUD(HUD hud, InventoryManager _inventoryManager)
    {
        isCurrentPlayer = true;

        _hud = hud;

        Connect(nameof(Agent.WeaponChangeSignal), _hud, nameof(HUD.UpdateWeapon));
        Connect(nameof(Agent.HealthChangedSignal), _hud, nameof(HUD.UpdateHealth));
        Connect(nameof(Agent.DefeatedAgentChangedSignal), _hud, nameof(HUD.UpdateDefeatedAgent));

        setHealth(MaxHealth);
        setEnergy(MaxEnergy);

        for (int index = 0; index <= (int)Weapon.WeaponOrder.Left; index++)
        {
            Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder)index;
            Weapon             weapon      = GetWeapons(weaponOrder)[GetCurrentWeaponIndex(weaponOrder)];
            if (weapon != null)
            {
                ConnectWeapon(weapon, weaponOrder);

                EmitSignal(nameof(WeaponChangeSignal), CurrentInventory.GetItems()[CurrentInventory.GetEquipItemIndex(weaponOrder, GetCurrentWeaponIndex(weaponOrder))], weaponOrder);
                // Emit signal to update info
                weapon.EmitSignal(nameof(Weapon.AmmoChangeSignal), weapon.GetAmmo(), weapon.GetMaxAmmo(), weaponOrder);
            }
            else
            {
                EmitSignal(nameof(WeaponChangeSignal), null, weaponOrder);
            }
        }

        // Set up the player indicator screen
        ScreenIndicator screenIndicator = (ScreenIndicator)((PackedScene)GD.Load("res://ui/ScreenIndicator.tscn")).Instance();

        AddChild(screenIndicator);
        screenIndicator.Initialize(this);

        // Setup Inventory UI
        _inventoryUI = (InventoryUI)_hud.GetNode("controlGame/InventoryUI");
        _inventoryUI.Initialize(_inventoryManager, CurrentInventory);

        if (!_teamMapAI.IsConnected(nameof(TeamMapAI.TeamUnitUsageAmountChangeSignal), _hud, nameof(HUD.UpdateTeamUnitUsageAmount)))
        {
            _teamMapAI.Connect(nameof(TeamMapAI.TeamUnitUsageAmountChangeSignal), _hud, nameof(HUD.UpdateTeamUnitUsageAmount));
            // Notify the HUD to change
            _teamMapAI.ChargeAmount(0);
        }
    }
Ejemplo n.º 10
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            // Check if file has been uploaded
            if (Upload.HasFile)
            {
                // Create a list of products
                List <Product> products = new List <Product>();

                // Go through each line of CSV file
                using (TextFieldParser parser = new TextFieldParser(Upload.PostedFile.InputStream))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    while (!parser.EndOfData)
                    {
                        // Read one row
                        string[] fields = parser.ReadFields();

                        // Create product object and fill in data from CSV row
                        Product product = new Product();
                        product.CreateFromCSVLine(fields);

                        // Add product to the list
                        products.Add(product);
                    }
                }

                // Use the list of products to
                CurrentInventory.DataSource = products;
                CurrentInventory.DataBind();

                Cache["CurrentInv"] = products;

                // Apply the end of day rules to all the products
                foreach (Product product in products)
                {
                    product.EndDay();
                }

                // Display updated inventory
                EndDayInventory.DataSource = products;
                EndDayInventory.DataBind();

                Cache["EndDayInv"] = products;

                Inventories.Visible = true;
            }
        }
        public void UpdateActiveInventory()
        {
            ITransaction finder = new ListCurrentInventoryTransaction(sqliteStore);

            finder.Execute();
            CurrentInventory.Clear();
            CurrentInventoryBatchNumberToIdMappings.Clear();
            BubbleSortEntitiesByBatchDisplayName(finder);

            for (int i = 0; i < finder.Results.Count; i++)
            {
                Entity <InventoryBatch> entity = finder.Results[i] as Entity <InventoryBatch>;
                CurrentInventory.Add(entity.NativeModel);
                CurrentInventoryBatchNumberToIdMappings.Add(entity.NativeModel.BatchNumber, entity.SystemId);
            }
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Update schedule generation data with the last scheduled item on the line
    /// </summary>
    /// <param name="item"></param>
    /// <param name="lineIndex"></param>
    public void MarkItemScheduled(ProductMasterItem item, int lineIndex, double unitsMade)
    {
        int pcsMade = (int)(unitsMade * item.PiecesPerUnit);
        var line    = StaticFactoryValuesManager.CoatingLines[lineIndex];

        LastWidth[line]     = item.Width;
        LastThickness[line] = item.Thickness;

        // remove prediction
        var prediction = PredictionList.FirstOrDefault(p => p.MasterID == item.MasterID);

        if (prediction != null)
        {
            PredictionList.Remove(prediction);
        }

        // remove sale
        var sale        = SalesList.FirstOrDefault(s => s.MasterID == item.MasterID);
        int pcsToRemove = pcsMade;

        while (sale != null)
        {
            if (sale.PiecesToMake > pcsToRemove)
            {
                sale.PiecesToMake -= pcsToRemove;
            }
            else
            {
                // made more or equal to the amount for this sale
                pcsToRemove -= sale.PiecesToMake;
                SalesList.Remove(sale);
                sale = SalesList.FirstOrDefault(s => s.MasterID == item.MasterID);
            }
        }

        // update inventory
        var invItem = CurrentInventory.FirstOrDefault(i => i.MasterID == item.MasterID);

        if (invItem != null)
        {
            invItem.Units += unitsMade;
        }
        CurrentWaste += item.Waste * unitsMade;
    }
Ejemplo n.º 13
0
    private void AddPressProduction(DateTime start, DateTime end)
    {
        // current day already moved
        var production = PressManager.Instance.GetProduction(start, end);

        foreach (var tuple in production)
        {
            // add inventory
            var inv = CurrentInventory.FirstOrDefault(i => i.MasterID == tuple.Item1.MasterID);
            if (inv != null)
            {
                inv.Units += tuple.Item2;
            }
            else
            {
                InventoryItem newInv = new InventoryItem(tuple.Item1, tuple.Item2, "DEALER");
                CurrentInventory.Add(newInv);
            }
        }
    }
Ejemplo n.º 14
0
        protected void EndDayButton_Click(object sender, EventArgs e)
        {
            // Get end of day inventory
            List <Product> products = (List <Product>)Cache["EndDayInv"];

            // Display as current inventory
            CurrentInventory.DataSource = products;
            CurrentInventory.DataBind();

            Cache["CurrentInv"] = products;

            // Apply the end of day rules to all the products
            foreach (Product product in products)
            {
                product.EndDay();
            }

            // Display updated inventory
            EndDayInventory.DataSource = products;
            EndDayInventory.DataBind();

            Cache["EndDayInv"] = products;
        }
Ejemplo n.º 15
0
        public void FillInventory()
        {
            // read txt file
            // set object properties from read-in data
            try
            {
                string currentDirectory  = Environment.CurrentDirectory;
                string inventoryFile     = "Inventory.txt";
                string fullInventoryPath = Path.Combine(currentDirectory, @"..\..\..\..\..\Example Files", inventoryFile);

                using (StreamReader sr = new StreamReader(fullInventoryPath))
                {
                    while (!sr.EndOfStream)
                    {
                        string             line      = sr.ReadLine();
                        string[]           lineArray = line.Split("|");
                        VendingMachineItem vmi       = new VendingMachineItem
                        {
                            Category     = lineArray[3],
                            Price        = Decimal.Parse(lineArray[2]),
                            SlotLocation = lineArray[0],
                            Name         = lineArray[1]
                        };
                        CurrentInventory.Add(vmi);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("File IO error.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Application error.");
            }
        }
Ejemplo n.º 16
0
        public static void StartBattle(CMonster opponent, double expCoe = 1.15)
        {
            if (CurrentPlayer.Pets.Length < 1 || CurrentPlayer.IsAllPetDead)
            {
                ConsoleUtil.WriteColor("전투가능한 펫이 없슴니다.");
                ConsoleUtil.Pause();
                return;
            }

            var random   = new Random();
            var firstAtk = random.Next(0, 2) == 0;

            Console.Clear();
            ConsoleUtil.WriteColor("전투가 시작되었습니다.");
            ConsoleUtil.WriteColor(opponent.ToString());
            ConsoleUtil.Pause();

            var pet = SelectPet();

            if (pet == -1)
            {
                return;
            }

            CurrentPlayer.Pets[pet].Info.Reset();
            opponent.Info.Reset();

            do
            {
                if (CurrentPlayer.Pets[pet].IsDead)
                {
                    int switched;
                    do
                    {
                        switched = SelectPet();
                    }while (CurrentPlayer.Pets[switched].IsDead);

                    pet = switched;
                }

                Console.Clear();

                ShowRound(pet, opponent);

                int action = -1;
                while (true)
                {
                    action = SelectAction();

                    if (
                        (action == 1 && CurrentInventory.Items.Count < 1) ||
                        (action == 2 && CurrentPlayer.GetPetsCount() < 2)
                        )
                    {
                        ConsoleUtil.WriteColor("불가능한 선택입니다.");
                        ConsoleUtil.Pause();
                    }
                    else
                    {
                        break;
                    }
                }

#nullable enable
                SSkill?skill = null;

                switch (action)
                {
                case 0: // Attack
                    skill = SelectSkill(pet);
                    break;

                case 1: // Use Item
                    var result = false;
                    do
                    {
                        var item   = SelectItem();
                        var usable = CurrentInventory.Items[item].Item as IUsableItem;
                        result = usable !.OnUse(CurrentPlayer.Pets[pet], opponent);
                        CurrentInventory.MinusItem(CurrentInventory.Items[item].Item, 1);

                        if (!result)
                        {
                            ConsoleUtil.WriteColor("아이템 사용에 실패했습니다.");
                            ConsoleUtil.Pause();
                        }
                        else
                        {
                            ConsoleUtil.WriteColor("아이템을 사용했습니다.");
                            ConsoleUtil.Pause();
                        }
                    }while (!result);

                    break;

                case 2: // Swap Pet
                    int switched;
                    do
                    {
                        switched = SelectPet();
                    }while (pet == switched);

                    pet = switched;

                    ConsoleUtil.WriteColor($"펫을 {CurrentPlayer.Pets[switched].Name}으로 교체했습니다.");
                    ConsoleUtil.Pause(true);
                    break;
                }

                if (firstAtk)
                {
                    if (action == 0)
                    {
                        PetAttack(pet, opponent, skill !);
                    }

                    if (opponent.IsDead)
                    {
                        break;
                    }
                    MonsterAttack(pet, opponent);
                }
                else
                {
                    MonsterAttack(pet, opponent);
                    if (CurrentPlayer.Pets[pet].IsDead)
                    {
                        return;
                    }
                    if (action == 0)
                    {
                        PetAttack(pet, opponent, skill !);
                    }
                }
            }while (!CurrentPlayer.IsAllPetDead && !opponent.IsDead);