Ejemplo n.º 1
0
        public static string LocalisedString(CultureInfo culture, DietType type)
        {
            string langKey = GetKeyFromCulture(culture);
            string result  = null;

            if (culturesInLookUp.Contains(langKey) == false)
            {
                if (LoadLanguage(culture))
                {
                    throw new ArgumentException("Language " + langKey + "not supported");
                }
            }
            Dictionary <DietType, string> lookUp = null;
            bool gotLang = stringFromDietLookUp.TryGetValue(langKey, out lookUp);

            if (gotLang == false)
            {
                //loader could load the lang, should not be reachable.
                throw new Exception("?");
            }
            bool gotString = lookUp.TryGetValue(type, out result);

            if (!gotString)
            {
                throw new ArgumentException("diet <" + type.ToString() + "> in lang:" + langKey + " not found");
            }
            return(result);
        }
Ejemplo n.º 2
0
        public int CreateDietType(VmDietType vmDietType)
        {
            var result = -1;

            try
            {
                var dietTypeRepository = UnitOfWork.GetRepository <DietTypeRepository>();

                var newDietType = new DietType
                {
                    Id      = dietTypeRepository.GetDietTypeNewId(),
                    Name    = vmDietType.Name,
                    Display = vmDietType.Display,
                };

                dietTypeRepository.CreateDietType(newDietType);

                UnitOfWork.Commit();

                result = newDietType.Id;
            }
            catch (Exception ex)
            {
                result = -1;
            }

            return(result);
        }
Ejemplo n.º 3
0
 public static Targets determineTargets(float size,DietType Diet, AttackType Attack)
 {
     if(Attack == AttackType.Scavenging){
         return Targets.Dead;
     }
     else if(size >= 35){
         return Targets.Smaller;
     }
     else if(size <= 5){
         return Targets.Larger;
     }
     else if(Attack == AttackType.Rushing){
         return Targets.Larger;
     }
     else if(Random.value<0.2){
         return Targets.Both;
     }
     else{
         float sizeWeight = (20-size)/100;
         float largeChance = 0.5f+sizeWeight;
         if(largeChance < Random.value){
             return Targets.Larger;
         }
         else{
             return Targets.Smaller;
         }
     }
 }
Ejemplo n.º 4
0
 public Animal(int numberOfLegs, bool isMammal, bool hasFur, DietType dietType)
 {
     NumberOfLegs = numberOfLegs;
     IsMammal     = isMammal;
     HasFur       = hasFur;
     DietType     = dietType;
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(DietType diet)
        {
            _db.Update(diet);
            var dietList = await _db.GetAllDiets();

            return(View("Index", dietList));
        }
        public async Task <DietType> Add(DietType diet)
        {
            _context.DietTypes.Add(diet);
            await _context.SaveChangesAsync();

            return(diet);
        }
Ejemplo n.º 7
0
 // CONSTRUCTORS
 public Food(string name, byte graphic, double volume, int effect, DietType foodType, Color?color, ItemType type = ItemType.Food, bool hollow = false, DamageType damageType = DamageType.Blunt)
     : base(graphic, type, volume, hollow, damageType, name)
 {
     this.foodType = foodType;
     ForeColor     = (Color)color;
     this.effect   = effect;
     Rarity        = DetermineRarity();
 }
        public DietType Update(DietType diet)
        {
            var dietUpdate = _context.DietTypes.Attach(diet);

            dietUpdate.State = EntityState.Modified;
            _context.SaveChanges();
            return(diet);
        }
Ejemplo n.º 9
0
        public async Task <ActionResult <DietType> > PostDietType(DietType dietType)
        {
            // Indicate to the database context we want to add this new record
            _context.Diets.Add(dietType);
            await _context.SaveChangesAsync();

            // Return a response that indicates the object was created (status code `201`) and some additional
            // headers with details of the newly created object.
            return(CreatedAtAction("GetDietType", new { id = dietType.Id }, dietType));
        }
Ejemplo n.º 10
0
 public Food(DietType foodType, string name, byte graphic, double volume, Color?foreColor = null, ItemType type = ItemType.Food, bool hollow = false, DamageType damageType = DamageType.Blunt)
     : base(graphic, type, volume, hollow, damageType)
 {
     ForeColor = Physics.MaterialColors[foodType == DietType.Herbivore ? Material.Plant : Material.Meat];
     if (foreColor != null)
     {
         ForeColor = (Color)foreColor;
     }
     foodName = name;
     Identify();
 }
Ejemplo n.º 11
0
        public async Task <IActionResult> Update(string id, DietType updatedDietType)
        {
            var queriedDietType = await _dietTypeService.GetByIdAsync(id);

            if (queriedDietType == null)
            {
                return(NotFound());
            }
            await _dietTypeService.UpdateAsync(id, updatedDietType);

            return(NoContent());
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create(DietType diet)
        {
            if (!ModelState.IsValid)
            {
                return(View(diet));
            }
            await _db.Add(diet);

            var dietList = await _db.GetAllDiets();

            return(View("Index", dietList));
        }
Ejemplo n.º 13
0
        public override string ToString()
        {
            string theirGenderPronoun,                  //The gender pronoun to use
                   animalInfo = "";                     //String of info to return

            //Finds out the animal's gender pronoun
            theirGenderPronoun = Gender.ToLower() == "male" ? "He" : "She";

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is our {0} year old {1}.  ", Age, Type.ToLower());

            animalInfo += string.Format("{0} lives here at {1}.  ", theirGenderPronoun, ZooLocation);

            animalInfo += string.Format("{0} is a {1}.  ", theirGenderPronoun, DietType.ToLower());

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }
Ejemplo n.º 14
0
    //TODO: Place for model data.
    void Start()
    {
        Material Red = (Material)Resources.Load("Temp/Materials/Redfish_MT");
        Material Blue = (Material)Resources.Load("Temp/Materials/Purpfish_MT");
        Material Green = (Material)Resources.Load("Temp/Materials/Goldfish_MT");
        //TODO: Load Model Data
        //TODO: Calculate complexity

        species = GenUtil.species(Random.Range(1,40),complexity:75, targets: Targets.Smaller);
        //Debug.Log (species);

        //Unpack species string
        string[] temp = species.Split(new char[] {' '});
        speciesName = temp[0];
        Diet = (DietType)System.Enum.Parse(typeof(DietType),temp[1]);
        dimensions.x = float.Parse(temp[2]);
        dimensions.y = float.Parse(temp[3]);
        dimensions.z = float.Parse(temp[4]);
        AttType = (AttackType)System.Enum.Parse(typeof(AttackType),temp[5]);
        DefType = (DefenceType)System.Enum.Parse(typeof(DefenceType),temp[6]);
        MovType = (MovementType)System.Enum.Parse(typeof(MovementType),temp[7]);
        targets = (Targets)System.Enum.Parse(typeof(Targets),temp[8]);
        speed = float.Parse(temp[9]);
        if(temp.Length > 10){
            for(int i = 10;i<temp.Length;i++){
                gameObject.AddComponent(temp[i]);
            }
        }
        size = (dimensions.x+dimensions.y+dimensions.z)/3;

        //Switch Color based on Diet
        switch(Diet){
        case DietType.Omnivore:
            renderer.material = Blue;
            break;
        case DietType.Herbivore:
            renderer.material = Green;
            break;
        case DietType.Carnivore:
            renderer.material = Red;
            break;
        }
    }
Ejemplo n.º 15
0
        public bool UpdateDietType(VmDietType vmDietType)
        {
            try
            {
                var DietTypeRepository = UnitOfWork.GetRepository <DietTypeRepository>();

                var updateableDietType = new DietType
                {
                    Id      = vmDietType.Id,
                    Name    = vmDietType.Name,
                    Display = vmDietType.Display,
                };

                DietTypeRepository.UpdateDietType(updateableDietType);

                return(UnitOfWork.Commit());
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 16
0
        /**
         * Prints out all the info on a reptile in a formatted matter.
         * @return The info about a reptile
         */
        public override string ToString()
        {
            string theirGenderPronoun,                  //The gender pronoun to use
                   theirDietType = DietType.ToLower(),  //The reptile's diet type
                   animalInfo    = "";                  //The string to return with the reptile's info

            //Finds out the reptile's gender pronoun
            if (Gender.ToLower() == "male") //Is a male
            {
                theirGenderPronoun = "He";
            }
            else //Is a female
            {
                theirGenderPronoun = "She";
            }

            if (DietType == "omnivore")
            {
                theirDietType = "an " + theirDietType;
            }
            else
            {
                theirDietType = "a " + theirDietType;
            }

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is our {0} year old {1}.  ",
                                        Age, Type.ToLower());

            animalInfo += string.Format("{0} lives {1} at {2}.  ",
                                        theirGenderPronoun, (LivesIndoors ? "indoors" : "outdoors"), ZooLocation);

            animalInfo += string.Format("{0} is {1}shelled and is {2}.  ",
                                        theirGenderPronoun, (HasAShell ? "" : "not "), theirDietType);

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> PutDietType(int id, DietType dietType)
        {
            // If the ID in the URL does not match the ID in the supplied request body, return a bad request
            if (id != dietType.Id)
            {
                return(BadRequest());
            }

            // Tell the database to consider everything in dietType to be _updated_ values. When
            // the save happens the database will _replace_ the values in the database with the ones from dietType
            _context.Entry(dietType).State = EntityState.Modified;

            try
            {
                // Try to save these changes.
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                // Ooops, looks like there was an error, so check to see if the record we were
                // updating no longer exists.
                if (!DietTypeExists(id))
                {
                    // If the record we tried to update was already deleted by someone else,
                    // return a `404` not found
                    return(NotFound());
                }
                else
                {
                    // Otherwise throw the error back, which will cause the request to fail
                    // and generate an error to the client.
                    throw;
                }
            }

            // Return a copy of the updated data
            return(Ok(dietType));
        }
Ejemplo n.º 18
0
 public static AttackType determineAttack(DietType Diet)
 {
     AttackType result = AttackType.Scavenging;
     float chance = Random.value;
     if(Diet == DietType.Herbivore){
         result = AttackType.Scavenging;
     }
     else{
         if(chance >= .9){
             result = AttackType.Scavenging;
         }
         else if(chance >= .45){
             result = AttackType.Stalking;
         }
         else if (chance >= .225){
             result = AttackType.Waiting;
         }
         else{
             result = AttackType.Rushing;
         }
     }
     return result;
 }
Ejemplo n.º 19
0
 public static DefenceType determineDefence(DietType Diet)
 {
     DefenceType result = DefenceType.Fleeing;
     float chance = Random.value;
     if((Diet == DietType.Carnivore || Diet == DietType.Omnivore) && chance >= .5){
         result = DefenceType.Fighting;
     }
     else{
         if(chance >= .75){
             result = DefenceType.Fleeing;
         }
         else if(chance >= .5){
             result = DefenceType.Hardening;
         }
         else if(chance >= .25){
             result = DefenceType.Fighting;
         }
         else{
             result = DefenceType.Hiding;
         }
     }
     return result;
 }
Ejemplo n.º 20
0
 public async Task UpdateAsync(string id, DietType DietType)
 {
     await _dietType.ReplaceOneAsync(s => s.Id == id, DietType);
 }
Ejemplo n.º 21
0
 public Diet(DietType type)
 {
     this.Type = type;
 }
Ejemplo n.º 22
0
 public Dragon(int numberOfLegs, bool hasFur, DietType dietType)
     : base(numberOfLegs, false, hasFur, dietType)
 {
 }
Ejemplo n.º 23
0
        private void FillBalanceFoodCalorieByQty(IEnumerable <FoodItemModel> foodList, DietType type, double balanceCalorie)
        {
            var foods       = foodList.Where(f => f.Type == type).ToList();
            var foodCount   = foods.Count;
            var calPortaion = balanceCalorie / foodCount;

            foreach (var item in foods)
            {
                var foodCalorie       = GetFoodCalorieAmount(item);
                var extraFoodQuantity = 100 * calPortaion / foodCalorie;
                item.FoodQuantity += extraFoodQuantity;
            }
        }
Ejemplo n.º 24
0
        // CONSTRUCTORS //

        public Animal(Block[] map, Point position, Point worldIndex, int currentFloor, Color?color, int sightDist, int persistence, Dictionary <DesireType, int> baseDesires, Class uclass, string name, string gender, DietType diet, string faction, byte graphic,
                      bool solid = true, bool opaque = true) : base(map, position, worldIndex, currentFloor, sightDist, graphic, name, gender, diet, faction, solid, opaque)
        {
            if (color != null)
            {
                this.ForeColor = (Color)color;
            }
            this.Class = uclass;

            this.baseDesires = baseDesires;
            currentDesires   = baseDesires;

            DetermineStats();
            DetermineEquipment();
        }
Ejemplo n.º 25
0
        // CONSTRUCTORS

        public Player(Block[] map, Point position, Point worldIndex, int currentFloor, int sightDist, string name, string gender, DietType diet, string faction, Class uclass, byte graphic = 1,
                      bool solid = true, bool opaque = true) : base(map, position, worldIndex, currentFloor, sightDist, graphic, name, gender, diet, faction, solid, opaque)
        {
            ForeColor = Color.AntiqueWhite;

            BlueprintPouch bpPouch    = new BlueprintPouch(false);
            RecipePouch    craftPouch = new RecipePouch(false);

            Inventory.Add(bpPouch);
            Inventory.Add(craftPouch);
            Inventory.Add(new Axe(true)
            {
                WeaponName = "pickaxe", Material = Material.Copper
            });
            Inventory.Add(new Torch(false));
            foreach (Item i in Inventory)
            {
                i.DetermineDurability();
            }

            Gold  = 550;
            Class = uclass;
            DetermineStats();
            DetermineEquipment();
        }
Ejemplo n.º 26
0
        /**
         * Prints out all the info of the mammal in a formatted matter.
         * @return The info of the mammal
         */
        public override string ToString()
        {
            string theirGenderPronoun,
                   animalInfo = "";

            //Finds out the mammal's gender pronoun
            if (Gender.ToLower() == "male") //Is a male
            {
                theirGenderPronoun = "He";
            }
            else //Is a female
            {
                theirGenderPronoun = "She";
            }

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is one of our {0}s.  ",
                                        Type.ToLower());

            animalInfo += string.Format("{0}\'s {1} years old and weighs {2:N1} pounds.  ",
                                        theirGenderPronoun, Age, Weight);

            animalInfo += string.Format("{0} lives here at {1}, where {2} eats {3} {4} meals per day.  ",
                                        theirGenderPronoun, ZooLocation, theirGenderPronoun.ToLower(), DailyMealCount, DietType.ToLower());

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }
Ejemplo n.º 27
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 53, Configuration.FieldSeparator),
                       Id,
                       SetIdPv1.HasValue ? SetIdPv1.Value.ToString(culture) : null,
                       PatientClass,
                       AssignedPatientLocation?.ToDelimitedString(),
                       AdmissionType,
                       PreadmitNumber?.ToDelimitedString(),
                       PriorPatientLocation?.ToDelimitedString(),
                       AttendingDoctor != null ? string.Join(Configuration.FieldRepeatSeparator, AttendingDoctor.Select(x => x.ToDelimitedString())) : null,
                       ReferringDoctor != null ? string.Join(Configuration.FieldRepeatSeparator, ReferringDoctor.Select(x => x.ToDelimitedString())) : null,
                       ConsultingDoctor != null ? string.Join(Configuration.FieldRepeatSeparator, ConsultingDoctor.Select(x => x.ToDelimitedString())) : null,
                       HospitalService,
                       TemporaryLocation?.ToDelimitedString(),
                       PreadmitTestIndicator,
                       ReadmissionIndicator,
                       AdmitSource,
                       AmbulatoryStatus != null ? string.Join(Configuration.FieldRepeatSeparator, AmbulatoryStatus) : null,
                       VipIndicator,
                       AdmittingDoctor != null ? string.Join(Configuration.FieldRepeatSeparator, AdmittingDoctor.Select(x => x.ToDelimitedString())) : null,
                       PatientType,
                       VisitNumber?.ToDelimitedString(),
                       FinancialClass != null ? string.Join(Configuration.FieldRepeatSeparator, FinancialClass.Select(x => x.ToDelimitedString())) : null,
                       ChargePriceIndicator,
                       CourtesyCode,
                       CreditRating,
                       ContractCode != null ? string.Join(Configuration.FieldRepeatSeparator, ContractCode) : null,
                       ContractEffectiveDate != null ? string.Join(Configuration.FieldRepeatSeparator, ContractEffectiveDate.Select(x => x.ToString(Consts.DateFormatPrecisionDay, culture))) : null,
                       ContractAmount != null ? string.Join(Configuration.FieldRepeatSeparator, ContractAmount.Select(x => x.ToString(Consts.NumericFormat, culture))) : null,
                       ContractPeriod != null ? string.Join(Configuration.FieldRepeatSeparator, ContractPeriod.Select(x => x.ToString(Consts.NumericFormat, culture))) : null,
                       InterestCode,
                       TransferToBadDebtCode,
                       TransferToBadDebtDate.HasValue ? TransferToBadDebtDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       BadDebtAgencyCode,
                       BadDebtTransferAmount.HasValue ? BadDebtTransferAmount.Value.ToString(Consts.NumericFormat, culture) : null,
                       BadDebtRecoveryAmount.HasValue ? BadDebtRecoveryAmount.Value.ToString(Consts.NumericFormat, culture) : null,
                       DeleteAccountIndicator,
                       DeleteAccountDate.HasValue ? DeleteAccountDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       DischargeDisposition,
                       DischargedToLocation?.ToDelimitedString(),
                       DietType?.ToDelimitedString(),
                       ServicingFacility,
                       BedStatus,
                       AccountStatus,
                       PendingLocation?.ToDelimitedString(),
                       PriorTemporaryLocation?.ToDelimitedString(),
                       AdmitDateTime.HasValue ? AdmitDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       DischargeDateTime.HasValue ? DischargeDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       CurrentPatientBalance.HasValue ? CurrentPatientBalance.Value.ToString(Consts.NumericFormat, culture) : null,
                       TotalCharges.HasValue ? TotalCharges.Value.ToString(Consts.NumericFormat, culture) : null,
                       TotalAdjustments.HasValue ? TotalAdjustments.Value.ToString(Consts.NumericFormat, culture) : null,
                       TotalPayments.HasValue ? TotalPayments.Value.ToString(Consts.NumericFormat, culture) : null,
                       AlternateVisitId?.ToDelimitedString(),
                       VisitIndicator,
                       OtherHealthcareProvider?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Ejemplo n.º 28
0
 public DietTypeAttribute(DietType dietType)
 {
     this.Something = dietType;
 }
Ejemplo n.º 29
0
        // CONSTRUCTORS //

        public Monster(Block[] map, Point position, Point worldIndex, int currentFloor, Color?color, int sightDist, int persistence, Dictionary <DesireType, int> baseDesires, Class uclass, string name, string gender, DietType diet, string faction, byte graphic,
                       bool solid = true, bool opaque = true) : base(map, position, worldIndex, currentFloor, sightDist, graphic, name, gender, diet, faction, solid, opaque)
        {
            this.persistence          = persistence;
            patrolling                = true;
            curPatrolDestIndex        = Program.RNG.Next(1, 5);
            turnsSinceAttentionCaught = 0;
            if (color != null)
            {
                this.ForeColor = (Color)color;
            }
            this.Class = uclass;

            this.baseDesires = baseDesires;
            currentDesires   = baseDesires;

            DetermineStats();
            DetermineEquipment();
        }
Ejemplo n.º 30
0
        public bool UpdatePerson(VmPerson vmPerson)
        {
            try
            {
                var personRepository   = UnitOfWork.GetRepository <PersonRepository>();
                var dietTypeRepository = UnitOfWork.GetRepository <DietTypeRepository>();

                var person = new Person
                {
                    Id                     = vmPerson.Id,
                    SizeId                 = vmPerson.SizeId,
                    Sex                    = vmPerson.Sex,
                    UniversityId           = vmPerson.UniversityId,
                    JacketSizeId           = vmPerson.JacketSizeId,
                    UserId                 = vmPerson.UserId,
                    ResumeUrl              = vmPerson.ResumeUrl,
                    FirstName              = vmPerson.FirstName,
                    LastName               = vmPerson.LastName,
                    StreetLine1            = vmPerson.StreetLine1,
                    StreetLine2            = vmPerson.StreetLine2,
                    City                   = vmPerson.City,
                    State                  = vmPerson.State,
                    ZipCode                = vmPerson.ZipCode,
                    EmgyPersonFirstName    = vmPerson.EmgyPersonFirstName,
                    EmgyPersonLastName     = vmPerson.EmgyPersonLastName,
                    EmgyPersonPhoneNumber  = vmPerson.EmgyPersonPhoneNumber,
                    EmgyPersonRelationship = vmPerson.EmgyPersonRelationship,
                    ShortBio               = vmPerson.ShortBio,

                    WelcomeDinner             = vmPerson.WelcomeDinner,
                    LunchOnMonday             = vmPerson.LunchOnMonday,
                    LunchOnTuesday            = vmPerson.LunchOnTuesday,
                    ReceptionNetworkOnTuesday = vmPerson.ReceptionNetworkOnTuesday,
                    AwardBanquet   = vmPerson.AwardBanquet,
                    NoneOfTheAbove = vmPerson.NoneOfTheAbove,
                    SecondaryEmail = vmPerson.SecondaryEmail,
                    Agreement      = vmPerson.Agreement,
                };

                if (vmPerson.DietTypeId == 5)
                {
                    var dietType = new DietType
                    {
                        Id      = dietTypeRepository.GetDietTypeNewId(),
                        Name    = vmPerson.DietType,
                        Display = true,
                    };

                    person.DietTypeId = dietType.Id;

                    dietTypeRepository.CreateDietType(dietType);
                }
                else
                {
                    person.DietTypeId = vmPerson.DietTypeId;
                }

                person.Allergies = vmPerson.Allergies;

                personRepository.UpdatePerson(person);

                //Do not delete its for next year
                //if (vmPerson.RoleId == "4d7951d8-8eda-4452-8ff1-dfc9076d8bbe")
                //{
                //    var userTaskRepository = UnitOfWork.GetRepository<UserTaskRepository>()

                //    userTaskRepository.DeleteUserTasks(vmPerson.UserId);
                //    userTaskRepository.CreateTasksUser(vmPerson.UserId, vmPerson.TaskIds);
                //}

                var teamMemberRepository = UnitOfWork.GetRepository <TeamMemberRepository>();

                var updateableTeamMember = new TeamMember
                {
                    MemberUserId       = vmPerson.UserId,
                    RegistrationStatus = true,
                };

                teamMemberRepository.UpdateTeamMemberRegistrationStatusByUserId(updateableTeamMember);


                UnitOfWork.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 31
0
        public async Task <IActionResult> Create(DietType dietType)
        {
            await _dietTypeService.CreateAsync(dietType);

            return(Ok(dietType));
        }
Ejemplo n.º 32
0
        public DietType GetDietType(int id)
        {
            DietType diet = _context.DietTypes.Where(m => m.Id == id).FirstOrDefault();

            return(diet);
        }
Ejemplo n.º 33
0
        public async Task <DietType> CreateAsync(DietType DietType)
        {
            await _dietType.InsertOneAsync(DietType);

            return(DietType);
        }