public ProductGiftViewModel(EquipmentItem item)
 {
     ProductID    = item.ProductID;
     ProductImage = Images.GetProductImage(EquipmentItemExtension.GetProductType(item)).VM;
     ProductName  = item.GetProductType().ToHumanReadable().FirstUpper();
     Amount       = item.Amount;
     Quality      = item.Quality;
 }
Exemple #2
0
        public MethodResult <bool> CanUseEquipmentItem(EquipmentItem item, Entity entity)
        {
            if (entity.GetEntityType() != EntityTypeEnum.Citizen)
            {
                return(new MethodResult <bool>("You are not a citizen. You cannot use items!"));
            }

            if (item.GetProductType() == ProductTypeEnum.MovingTicket)
            {
                return(true);
            }

            if (item.GetProductType() == ProductTypeEnum.Tea)
            {
                if (entity.Citizen.DrankTeas < 10)
                {
                    return(true);
                }
                return(new MethodResult <bool>("You cannot drink more than 10 teas per day!"));
            }

            return(new MethodResult <bool>("You cannot use this item!"));
        }
Exemple #3
0
        public MethodResult <string> UseEquipmentItem(EquipmentItem item, Entity entity)
        {
            switch (item.GetProductType())
            {
            case ProductTypeEnum.Tea:
            {
                var hpHealed = productService.GetTeaHealedAmount(item.Quality);
                var prevHp   = entity.Citizen.HitPoints;

                entity.Citizen.HitPoints = Math.Min(100, prevHp + hpHealed);
                entity.Citizen.DrankTeas++;

                equipmentRepository.RemoveEquipmentItem(item.EquipmentID, item.ProductID, item.Quality);
                equipmentRepository.SaveChanges();

                hpHealed = entity.Citizen.HitPoints - prevHp;
                return($"You drank tea and healed {hpHealed} hitpoint{PluralHelper.S(hpHealed)}.");
            }

            default:
                throw new Exception("No action defined for " + EquipmentItemExtension.GetProductType(item).ToString());
            }
        }