Exemplo n.º 1
0
        public string CargoItemToHTMLString(CargoItem item)
        {
            if (item == null)
            {
                return(null);
            }
            string resultHTML = string.Empty;

            if (item.success == true)
            {
                resultHTML += "<div class='bot-cargo-container'>";
                resultHTML += $"<div class='bot-cargo-item'><div>Status of your request:</div><div>{item.data[0].Status}</div></div>";
                if (!string.IsNullOrEmpty(item.data[0].ScheduledDeliveryDate))
                {
                    resultHTML += $"<div class='bot-cargo-item'><div>Expected delivery date:</div><div>{item.data[0].ScheduledDeliveryDate}</div></div>";
                }
                if (!string.IsNullOrEmpty(item.data[0].WarehouseRecipient))
                {
                    resultHTML += $"<div class='bot-cargo-item'><div>Place of arrival:</div><div>{item.data[0].WarehouseRecipient}</div></div>";
                }
                resultHTML += "</div>";
            }
            else
            {
                resultHTML += "Can`t find your cargo. Please, check it's id";
            }

            return(resultHTML);
        }
        private List <CargoItem> MapMsd1CargoSummaryToCargoItem(string id)
        {
            List <CargoItem> cargoItems = new List <CargoItem>();

            try
            {
                IQueryable <Msd1CargoSummary> cargoSummary = _context.Msd1CargoSummary.Where(x => x.Msd1Id == id)
                                                             .AsQueryable();

                foreach (Msd1CargoSummary msd1CargoSummary in cargoSummary)
                {
                    CargoItem cargoItem = new CargoItem()
                    {
                        Id                = Guid.NewGuid(),
                        Description       = msd1CargoSummary.Description,
                        Category          = _helperService.GetCategoryDescriptionByCode(msd1CargoSummary.CategoryCode),
                        GrossWeight       = (double?)msd1CargoSummary.GrossWeight,
                        TotalUnits        = msd1CargoSummary.TotalUnits,
                        UnitsWithCargo    = msd1CargoSummary.UnitsWithCargo,
                        UnitsWithoutCargo = msd1CargoSummary.UnitsWithoutCargo,
                    };

                    cargoItems.Add(cargoItem);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
            }

            return(cargoItems);
        }
Exemplo n.º 3
0
        public void CheckIn(PassengerBaggage baggage)
        {
            ValidateCanLoadBaggage(baggage);

            foreach (var bag in baggage.Bags)
            {
                var cargoItem = new CargoItem(bag);
                cargo.Add(cargoItem);
            }
        }
Exemplo n.º 4
0
 public void AddCargo(GameData.Items.Equipment equip, string hardpoint, int count)
 {
     if (equip.Good?.Ini.Combinable ?? false)
     {
         if (!string.IsNullOrEmpty(hardpoint))
         {
             throw new InvalidOperationException("Tried to mount combinable item");
         }
         var slot = Items.FirstOrDefault(x => equip.Good.Equipment == x.Equipment);
         if (slot == null)
         {
             CargoItem dbItem = null;
             if (dbChar != null)
             {
                 dbItem = new CargoItem()
                 {
                     ItemCount = count, ItemName = equip.Nickname
                 };
                 dbChar.Character.Items.Add(dbItem);
                 dbChar.ApplyChanges();
             }
             Items.Add(new NetCargo()
             {
                 Equipment = equip, Count = count, DbItem = dbItem
             });
         }
         else
         {
             if (dbChar != null)
             {
                 slot.DbItem.ItemCount += count;
                 dbChar.ApplyChanges();
             }
             slot.Count += count;
         }
     }
     else
     {
         CargoItem dbItem = null;
         if (dbChar != null)
         {
             dbItem = new CargoItem()
             {
                 ItemCount = count, Hardpoint = hardpoint, ItemName = equip.Nickname
             };
             dbChar.Character.Items.Add(dbItem);
             dbChar.ApplyChanges();
         }
         Items.Add(new NetCargo()
         {
             Equipment = equip, Hardpoint = hardpoint, Count = count, DbItem = dbItem
         });
     }
 }
 public bool removeItem(CargoItem item)
 {
     for (int i = 0; i < itemSlots.Length; i++)
     {
         if (itemSlots[i].CargoItem == item)
         {
             itemSlots[i].CargoItem = null;
             return(true);
         }
     }
     return(false);
 }
    public bool addItem(CargoItem item)
    {
        for (int i = 0; i < itemSlots.Length; i++)
        {
            if (itemSlots[i].CargoItem == null)
            {
                itemSlots[i].CargoItem = item;
                if (itemSlots[i].CargoItem is TurretDescription)
                {
                    (itemSlots[i].CargoItem as TurretDescription).slotName = SlotName.Cargo;
                }

                return(true);
            }
        }
        return(false);
    }
 public void AddToCargo(CargoItem cargoItem)
 {
     base.AddObject("Cargo", cargoItem);
 }
 public static CargoItem CreateCargoItem(short cod_Cargo, string descripcion_Cargo)
 {
     CargoItem cargoItem = new CargoItem();
     cargoItem.Cod_Cargo = cod_Cargo;
     cargoItem.Descripcion_Cargo = descripcion_Cargo;
     return cargoItem;
 }
Exemplo n.º 9
0
        public ModelStateDictionary ManualModelValidation(MSD1_1 localMSD1, string cargoDescription, CargoItem cargoItem)
        {
            var currentCargoGroup = _portFreightContext.CargoGroup.FirstOrDefault(x => x.Description == cargoDescription);

            var cargoCategory        = _portFreightContext.CargoCategory.Where(x => x.GroupCode == currentCargoGroup.GroupCode);
            var currentCargoCategory = cargoCategory.FirstOrDefault(x => x.Description == cargoItem.Category);

            TextInputDisplayDriver = BuildTextInputDisplayDriver(currentCargoCategory, currentCargoGroup.IsUnitised);

            var grossWeightVisible          = TextInputDisplayDriver.Contains(WeightConfigure);
            var numUnitsVisible             = TextInputDisplayDriver.Contains(NoCargoConfigure);
            var numUnitsWithCargoVisible    = TextInputDisplayDriver.Contains(CargoConfigure) && !numUnitsVisible;
            var numUnitsWithoutCargoVisible = numUnitsWithCargoVisible;

            if (numUnitsVisible && (!cargoItem.TotalUnits.HasValue || cargoItem.TotalUnits == 0))
            {
                _modelState.AddModelError("CargoItem.TotalUnits", "Enter number of units");
            }

            if (numUnitsWithCargoVisible && (!cargoItem.UnitsWithCargo.HasValue))
            {
                _modelState.AddModelError("CargoItem.UnitsWithCargo", "Enter number of units carrying cargo");
            }

            if (numUnitsWithoutCargoVisible && (!cargoItem.UnitsWithoutCargo.HasValue))
            {
                _modelState.AddModelError("CargoItem.UnitsWithoutCargo", "Enter number of units without cargo");
            }

            if (grossWeightVisible)
            {
                if (!cargoItem.GrossWeight.HasValue)
                {
                    _modelState.AddModelError("CargoItem.GrossWeight", "Enter the weight. Type 0 if no weight available");
                }
                else
                {
                    if (!numUnitsVisible && !numUnitsWithCargoVisible && !numUnitsWithoutCargoVisible && cargoItem.GrossWeight == 0)
                    {
                        _modelState.AddModelError("CargoItem.GrossWeight", "Enter weight greater than 0.");
                    }
                    else if (numUnitsVisible && !numUnitsWithCargoVisible && !numUnitsWithoutCargoVisible && cargoItem.GrossWeight == 0)
                    {
                        _modelState.AddModelError("CargoItem.GrossWeight", "Enter weight greater than 0.");
                    }
                    else
                    {
                        var totalGrossWeight = localMSD1.CargoSummary.Sum(x => x.GrossWeight) + cargoItem.GrossWeight;
                        if (string.IsNullOrEmpty(cargoItem.Description) && ((cargoItem.GrossWeight > (localMSD1.DeadWeight + 1) * localMSD1.NumVoyages) ||
                                                                            (totalGrossWeight > (localMSD1.DeadWeight + 1) * localMSD1.NumVoyages)))
                        {
                            _modelState.AddModelError("CargoItem.GrossWeight",
                                                      totalGrossWeight + " exceeds the deadweight of this ship. Correct the tonnage or contact the helpdesk.");
                        }
                    }
                }
            }

            if (numUnitsWithCargoVisible &&
                numUnitsWithoutCargoVisible &&
                cargoItem.UnitsWithCargo == 0 &&
                cargoItem.UnitsWithoutCargo == 0)
            {
                _modelState.AddModelError("CargoItem.UnitsWithCargo", "Number of units with and without cargo cannot both be 0. Correct the number of units or contact the helpdesk.");
                _modelState.AddModelError("CargoItem.UnitsWithoutCargo", "Number of units with and without cargo cannot both be 0. Correct the number of units or contact the helpdesk.");
            }

            if (numUnitsWithCargoVisible && cargoItem.UnitsWithCargo > 0 && cargoItem.GrossWeight == 0)
            {
                _modelState.AddModelError("CargoItem.GrossWeight",
                                          "You reported " + cargoItem.UnitsWithCargo + " loaded units with cargo but no weight. Enter the total weight of this cargo.");
            }

            if (numUnitsWithCargoVisible && cargoItem.UnitsWithCargo == 0 && cargoItem.GrossWeight > 0)
            {
                _modelState.AddModelError("CargoItem.UnitsWithCargo",
                                          "You reported cargo weighing " + cargoItem.GrossWeight + " tonnes but 0 units with cargo. Enter the number of units that were carrying this cargo.");
            }
            return(_modelState);
        }
Exemplo n.º 10
0
    private void drop(CargoItemSlot dropCargoItemSlot)
    {
        if (draggedSlot != null)
        {
            TurretDescription dragItem = draggedSlot.CargoItem as TurretDescription;       //item dragged by the player
            TurretDescription dropItem = dropCargoItemSlot.CargoItem as TurretDescription; //item present or not in the cargoItemSlot

            int slotIdDraggedItem = -1;

            //We want to know the slotId of the dragged item, and if its a cargo or an arsenal slot
            if (dragItem.slotName == SlotName.Arsenal) //Turret Slot
            {
                //Get slotId of the turret to unequip from arsenal
                slotIdDraggedItem = dragItem.arsenalId;
            }
            else if (dragItem.slotName == SlotName.Cargo) //Cargo Slot
            {
                //Get slotId of the turret to unequip from cargo
                slotIdDraggedItem = dragItem.cargoId;
            }
            //Debug.Log(slotIdDraggedItem);


            //Case 1 : drop item in empty arsenal slot (OK)
            if (dropCargoItemSlot is TurretSlot && dragItem != null && dropItem == null)
            {
                if (dragItem is TurretDescription)           //if dragged is a turret
                {
                    if ((draggedSlot as TurretSlot) != null) //if dragged item come from arsenal (OK)
                    {
                        //Switch turrets
                        dragItem.unequipTurret(this, draggedSlot.slotId);
                        dragItem.equipTurret(this, dropCargoItemSlot.slotId); //equip dragTurret in arsenal slot

                        //Switch hidders
                        (draggedSlot as TurretSlot).hidderEmpty.SetActive(true);
                        (dropCargoItemSlot as TurretSlot).hidderEmpty.SetActive(false);

                        //Switch visual
                        dropCargoItemSlot.CargoItem = draggedSlot.CargoItem;
                        draggedSlot.CargoItem       = null;

                        //Update id
                        (dropCargoItemSlot as TurretSlot).cargoId = (draggedSlot as TurretSlot).cargoId;
                        (draggedSlot as TurretSlot).cargoId       = -1;

                        //Update price
                        (dropCargoItemSlot as TurretSlot).updateUpgradePrice(dragItem.actualUpgradePriceScraps, dragItem.actualUpgradePriceEnergyCore);
                        (draggedSlot as TurretSlot).updateUpgradePrice(dropItem.actualUpgradePriceScraps, dropItem.actualUpgradePriceEnergyCore);
                    }
                    else //if dragged item come from cargo
                    {
                        dragItem.equipTurret(this, dropCargoItemSlot.slotId);

                        //Switch hidders
                        (dropCargoItemSlot as TurretSlot).hidderEmpty.SetActive(false);
                        draggedSlot.isUsed = true;
                        draggedSlot.manageHidders();

                        //Switch visual
                        dropCargoItemSlot.CargoItem = draggedSlot.CargoItem;

                        //Update id
                        (dropCargoItemSlot as TurretSlot).cargoId = draggedSlot.slotId;

                        //Update price
                        (dropCargoItemSlot as TurretSlot).updateUpgradePrice(dragItem.actualUpgradePriceScraps, dragItem.actualUpgradePriceEnergyCore);
                    }
                }
            }

            //Case 2 : drop item in occupied arsenal slot (OK)
            if (dropCargoItemSlot is TurretSlot && dragItem != null && dropItem != null && draggedSlot != dropCargoItemSlot)
            {
                if (dragItem is TurretDescription)           //if dragged is a turret
                {
                    if ((draggedSlot as TurretSlot) != null) //if dragged item come from arsenal (OK)
                    {
                        dragItem.unequipTurret(this, draggedSlot.slotId);
                        dropItem.unequipTurret(this, dropCargoItemSlot.slotId);

                        dragItem.equipTurret(this, dropCargoItemSlot.slotId);
                        dropItem.equipTurret(this, draggedSlot.slotId);

                        //Switch items
                        CargoItem draggedItem = draggedSlot.CargoItem;
                        draggedSlot.CargoItem       = dropCargoItemSlot.CargoItem;
                        dropCargoItemSlot.CargoItem = draggedItem;

                        //Update price
                        (dropCargoItemSlot as TurretSlot).updateUpgradePrice(dragItem.actualUpgradePriceScraps, dragItem.actualUpgradePriceEnergyCore);
                        (draggedSlot as TurretSlot).updateUpgradePrice(dropItem.actualUpgradePriceScraps, dropItem.actualUpgradePriceEnergyCore);
                    }
                    else if (!draggedSlot.isUsed)                               //if dragged item come from cargo and its not an already used turret (OK)
                    {
                        dropItem.unequipTurret(this, dropCargoItemSlot.slotId); //unequip turret in arsenal slot
                        dragItem.equipTurret(this, dropCargoItemSlot.slotId);   //equip dragTurret in arsenal slot

                        //Send dropItem item back to its cargo slot
                        cargo.itemSlots[(dropCargoItemSlot as TurretSlot).cargoId].isUsed = false;
                        cargo.itemSlots[draggedSlot.slotId].isUsed = true;
                        cargo.itemSlots[(dropCargoItemSlot as TurretSlot).cargoId].manageHidders();
                        cargo.itemSlots[draggedSlot.slotId].manageHidders();

                        //Change item in arsenal slot
                        dropCargoItemSlot.CargoItem = draggedSlot.CargoItem;

                        //Set slot id in arsenal slot according to the new turret
                        (dropCargoItemSlot as TurretSlot).cargoId = draggedSlot.slotId;

                        //Update price
                        (dropCargoItemSlot as TurretSlot).updateUpgradePrice(dragItem.actualUpgradePriceScraps, dragItem.actualUpgradePriceEnergyCore);

                        dropItem.cargoId = dropCargoItemSlot.slotId;
                    }
                }
            }

            /*//Case 3 : drop item in empty cargo slot (OK)
             * if (!(dropCargoItemSlot is TurretSlot) && dragItem != null && dropItem == null)
             * {
             *  Debug.Log("Case 3");
             *  if (dragItem is TurretDescritpion) //if dragged is a turret
             *  {
             *      if ((dragItem as TurretDescritpion).slotName == SlotName.Arsenal) //if dragged item come from arsenal (OK)
             *      {
             *          dragItem.unequipTurret(this, slotIdDraggedItem);
             *          dragItem.cargoId = dropCargoItemSlot.slotId; ;
             *      }
             *      else if ((dragItem as TurretDescritpion).slotName == SlotName.Cargo) //if dragged item come from cargo (OK)
             *      {
             *          dragItem.cargoId = dropCargoItemSlot.slotId;
             *      }
             *  }
             * }*/

            /*//Case 4 : drop item in occupied cargo slot (OK)
             * if (!(dropCargoItemSlot is TurretSlot) && dragItem != null && dropItem != null)
             * {
             *  Debug.Log("Case 4");
             *  if (dragItem is TurretDescritpion) //if dragged is a turret
             *  {
             *      if ((dragItem as TurretDescritpion).slotName == SlotName.Arsenal) //if dragged item come from arsenal (OK)
             *      {
             *          dragItem.unequipTurret(this, slotIdDraggedItem); //unequip drag Turret from arsenal slot
             *          dropItem.equipTurret(this, slotIdDraggedItem); //equip drop Turret from cargo in arsenal slot
             *
             *          dragItem.cargoId = dropCargoItemSlot.slotId;
             *      }
             *      else if ((dragItem as TurretDescritpion).slotName == SlotName.Cargo) //if dragged item come from cargo (OK)
             *      {
             *          dragItem.cargoId = dropCargoItemSlot.slotId;
             *          dropItem.cargoId = slotIdDraggedItem;
             *      }
             *  }
             * }*/

            //Case 4 : drop item in occupied cargo slot (Ok)
            if (!(dropCargoItemSlot is TurretSlot) && dragItem != null && dropItem != null)
            {
                if (dragItem is TurretDescription && (draggedSlot as TurretSlot) != null)                            //if dragged is a turret
                {
                    if ((draggedSlot as TurretSlot).cargoId == dropCargoItemSlot.slotId && dropCargoItemSlot.isUsed) //if cargo slot is the origin slot of the dragged item, then the turret become empty
                    {
                        dragItem.unequipTurret(this, draggedSlot.slotId);                                            //unequip drag Turret from arsenal slot

                        //Switch hidder
                        cargo.itemSlots[(draggedSlot as TurretSlot).cargoId].isUsed = false;
                        cargo.itemSlots[(draggedSlot as TurretSlot).cargoId].manageHidders();
                        (draggedSlot as TurretSlot).hidderEmpty.SetActive(true);

                        //Set slot id in arsenal slot to empty
                        (draggedSlot as TurretSlot).cargoId = -1;

                        //Empty arsenal slot
                        draggedSlot.CargoItem = null;

                        //Update price
                        (draggedSlot as TurretSlot).updateUpgradePrice(-1, -1);
                    }
                    else if (!dropCargoItemSlot.isUsed)
                    {
                        dragItem.unequipTurret(this, draggedSlot.slotId); //unequip drag Turret from arsenal slot
                        dropItem.equipTurret(this, draggedSlot.slotId);   //equip drop Turret from cargo in arsenal slot

                        //Switch hidder
                        cargo.itemSlots[(draggedSlot as TurretSlot).cargoId].isUsed = false;
                        cargo.itemSlots[(draggedSlot as TurretSlot).cargoId].manageHidders();
                        dropCargoItemSlot.isUsed = true;
                        dropCargoItemSlot.manageHidders();

                        //Change item in arsenal slot
                        draggedSlot.CargoItem = dropCargoItemSlot.CargoItem;

                        //Set slot id in arsenal slot according to the new turret
                        (draggedSlot as TurretSlot).cargoId = dropCargoItemSlot.slotId;

                        //Update price
                        (draggedSlot as TurretSlot).updateUpgradePrice(dropItem.actualUpgradePriceScraps, dropItem.actualUpgradePriceEnergyCore);
                    }

                    dragItem.cargoId = dropCargoItemSlot.slotId;
                }
            }

            /*
             * if (dragItem is TurretDescritpion)
             * {
             *  Debug.Log("DragItem");
             *  if (dragItem != null) dragItem.unequipTurret(this);
             *  if (dropItem != null) dragItem.equipTurret(this, dropCargoItemSlot.slotId);
             * }
             * if (dropItem is TurretDescritpion)
             * {
             *  Debug.Log("DropItem");
             *  if (dragItem != null) dragItem.equipTurret(this, dropCargoItemSlot.slotId);
             *  if (dropItem != null) dragItem.unequipTurret(this);
             * }*/

            //Reverse items positions

            /*CargoItem draggedItem = draggedSlot.CargoItem;
             * draggedSlot.CargoItem = dropCargoItemSlot.CargoItem;
             * dropCargoItemSlot.CargoItem = draggedItem;*/
        }
    }