public UnitInfo(string id, UnitClassification unitType, int health, int power, int aggression) : this() { this.Id = id; this.Health = health; this.UnitClassification = unitType; this.Power = power; this.Aggression = aggression; }
public Tank( string id, UnitClassification unitType = UnitClassification.Mechanical, int health = 20, int power = 25, int aggression = 25) : base(id, unitType, health, power, aggression) { }
protected Unit(string id, UnitClassification unitType, int health, int power, int aggression) { this.Id = id; this.UnitClassification = unitType; this.baseHealth = health; this.basePower = power; this.baseAggression = aggression; this.supplements = new List<ISupplement>(); }
public PostgradUnit(string unitCode, string unitName, List <string> prerequisites, int creditHours, UnitClassification classification, List <Trimesters> trimesterOffered, List <Campuses> campusesOffered, List <string> programmeOffered, int CWComponent) : base(unitCode, unitName, prerequisites, creditHours, classification, trimesterOffered, campusesOffered, programmeOffered, CWComponent) { }
public async Task <DataResult <ClassificationAddResponse> > ProcessClassificationCreate(ClassificationCreateDTO model) { DAL.Entities.Tables.UnitTree unitTree = await _unitOfWork.Units.GetByIdExpandedAsync(model.ParentId); if (unitTree == null) { return(new DataResult <ClassificationAddResponse>() { ResponseStatusType = ResponseStatusType.Error, Message = ResponseMessageType.ParentIdMissing }); } DAL.Entities.Tables.UnitType unitType = await _unitOfWork.UnitTypes.GetByIdAsync(model.UnitTypeId); if (unitType == null) { return(new DataResult <ClassificationAddResponse>() { ResponseStatusType = ResponseStatusType.Error, Message = ResponseMessageType.NotFound }); } List <DAL.Entities.Tables.UnitType> allowedTypes = _unitTypeCache.GetFromCache(unitTree.UnitClassification.UnitType.Name); if (allowedTypes.All(x => x.Id != model.UnitTypeId)) { return(new DataResult <ClassificationAddResponse>() { Message = ResponseMessageType.OperationNotAllowedForUnitType, ResponseStatusType = ResponseStatusType.Error }); } if (string.IsNullOrWhiteSpace(model.Name)) { return(new DataResult <ClassificationAddResponse>() { ResponseStatusType = ResponseStatusType.Error, Message = ResponseMessageType.InvalidModel }); } UnitClassification classification = _mapper.Map <UnitClassification>(model); await _unitOfWork.UnitClassifications.AddAsync(classification); await _unitOfWork.SaveAsync(); return(new DataResult <ClassificationAddResponse>() { ResponseStatusType = ResponseStatusType.Succeed, Data = new ClassificationAddResponse() { ClassificationId = classification.Id } }); }
public Unit(string id, UnitClassification unitType, int health, int power, int aggression) { this.Id = id; this.UnitClassification = unitType; this.baseHealth = health; this.basePower = power; this.baseAggression = aggression; this.supplements = new List <ISupplement>(); }
private async Task <DataResult <UnitAddResponse> > ProcessUnitCreateTransaction(UnitCreateOrUpdateDTO model) { return(await _transactionManager.ExecuteInImplicitTransactionAsync(async() => { UnitClassification classification = await _unitOfWork.UnitClassifications.GetByIdAsync(model.UnitClassificationId); if (classification == null) { return new DataResult <UnitAddResponse>() { Message = ResponseMessageType.ClassificationMissing, ResponseStatusType = ResponseStatusType.Error }; } DAL.Entities.Tables.UnitTree parentUnit = await _unitOfWork.Units.GetByIdExpandedAsync(model.ParentId); if (parentUnit == null) { return new DataResult <UnitAddResponse>() { Message = ResponseMessageType.ParentIdMissing, ResponseStatusType = ResponseStatusType.Error }; } var allowedTypes = _unitTypeCache.GetFromCache(parentUnit.UnitClassification.UnitType.Name); if (!allowedTypes.Any(x => x.Id == classification.UnitType.Id && x.Name == classification.UnitType.Name)) { return new DataResult <UnitAddResponse>() { Message = ResponseMessageType.OperationNotAllowedForUnitType, ResponseStatusType = ResponseStatusType.Error }; } DAL.Entities.Tables.UnitTree unitEntity = _mapper.Map <DAL.Entities.Tables.UnitTree>(model); await _unitOfWork.Units.AddAsync(unitEntity); await _unitOfWork.SaveAsync(); await _unitOfWork.Units.UpdateBowers(unitEntity.Id, model.ParentId); return new DataResult <UnitAddResponse>() { ResponseStatusType = ResponseStatusType.Succeed, Data = new UnitAddResponse() { UnitId = unitEntity.Id, ParentId = unitEntity.ParentId, UnitClassificationId = unitEntity.UnitClassificationId } }; })); }
protected override bool CanAttackUnit(UnitInfo unit) { bool attackUnit = false; if (this.Id != unit.Id) { UnitClassification thisUnitRequirement = InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification); if (this.UnitClassifications.Equals(typeof(thisUnitRequirement))) { attackUnit = true; } } return(attackUnit); }
public static UnitClassification RequiredClassificationToInfest(UnitClassification targetUnit) { switch (targetUnit) { case UnitClassification.Biological: return UnitClassification.Biological; case UnitClassification.Mechanical: return UnitClassification.Psionic; case UnitClassification.Psionic: return UnitClassification.Psionic; default: throw new InvalidOperationException("Unknown unit classification: " + targetUnit); } }
public static UnitClassification RequiredClassificationToInfest(UnitClassification targetUnit) { switch (targetUnit) { case UnitClassification.Biological: return(UnitClassification.Biological); case UnitClassification.Mechanical: return(UnitClassification.Psionic); case UnitClassification.Psionic: return(UnitClassification.Psionic); default: throw new InvalidOperationException("Unknown unit classification: " + targetUnit); } }
public StudyUnit(string unitCode, string unitName, List <string> prerequisites, int creditHours, UnitClassification classification, List <Trimesters> trimesterOffered, List <Campuses> campusesOffered, List <string> programmeOffered, int CWComponent) { if ((prerequisites == null) || (trimesterOffered == null) || (campusesOffered == null) || (programmeOffered == null)) { throw new ArgumentException("StudyUnit cannot be initialized with a null argument"); } this.unitCode = unitCode; this.unitName = unitName; this.prerequisites = prerequisites; this.creditHours = creditHours; this.classification = classification; this.trimesterOffered = trimesterOffered; this.campusesOffered = campusesOffered; this.programmeOffered = programmeOffered; this.CWComponent = CWComponent; }
public void Equals_TestWithSameObjectType(string unitCode, string unitName, int creditHours, UnitClassification classification, int cwcomponent, bool expectEqual) { List <string> origString, compString; List <Trimesters> origTrimesters, compTrimesters; List <Campuses> origCampuses, compCampuses; origString = new List <string>(); origTrimesters = new List <Trimesters>(); origCampuses = new List <Campuses>(); compString = new List <string>(); compTrimesters = new List <Trimesters>(); compCampuses = new List <Campuses>(); origString.Add("dummy value"); origTrimesters.Add(Trimesters.Y1T1); origCampuses.Add(Campuses.FES); StudyUnit originalUnit = new StudyUnit("UECS8888", "lucky subject", origString, 10, UnitClassification.major, origTrimesters, origCampuses, origString, 50); StudyUnit unitToCompare; if (expectEqual) // set comp** to have different values from orig*** { compString.Add("some value"); compTrimesters.Add(Trimesters.Y2T2); compCampuses.Add(Campuses.FCI); unitToCompare = new StudyUnit(unitCode, unitName, compString, creditHours, classification, compTrimesters, compCampuses, compString, cwcomponent); Assert.AreEqual(originalUnit, unitToCompare); } else // set comp** to have exactly same values as orig*** { compString.Add("dummy value"); compTrimesters.Add(Trimesters.Y1T1); compCampuses.Add(Campuses.FES); unitToCompare = new StudyUnit(unitCode, unitName, compString, creditHours, classification, compTrimesters, compCampuses, compString, cwcomponent); Assert.AreNotEqual(originalUnit, unitToCompare); } }
public List <StudyUnit> CreateSubjectList(List <string> strings) { if (strings == null) { throw new ArgumentException("CreateSubjectList cannot be run on a null string list"); } char[] delimiters = new char[] { ' ' }; string exceptionMessage = ""; string unitCode, unitName; int creditHours = 0, CWComponent = 0; UnitClassification classification = UnitClassification.major; List <string> prerequisites; List <Trimesters> trimesterOffered; List <Campuses> campusesOffered; List <string> programmeOffered; string[] temp, components; StudyUnit studyunit; List <StudyUnit> allUnits = new List <StudyUnit>(); foreach (string line in strings) { if (line.Length < 5) { continue; } prerequisites = new List <string>(); trimesterOffered = new List <Trimesters>(); campusesOffered = new List <Campuses>(); programmeOffered = new List <string>(); components = line.Split(':'); if (components.Length != 9) { throw new ArgumentException(components[0].Trim() + " : " + DefaultValues.ExceptionMessages[5]); } unitCode = components[0].Trim(); if (unitCode.Length == 0) { throw new ArgumentException(components[1].Trim() + " : " + DefaultValues.ExceptionMessages[6]); } unitName = components[1].Trim(); temp = components[2].Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < temp.Length; j++) { if (temp[j].Length > 2) { prerequisites.Add(temp[j]); } } try { creditHours = Convert.ToInt32(components[3]); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[7] + "\n"; } try { classification = (UnitClassification)Enum.Parse(typeof(UnitClassification), components[4].ToLower()); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[8] + "\n"; } temp = components[5].Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries); try { for (int j = 0; j < temp.Length; j++) { trimesterOffered.Add((Trimesters)Enum.Parse(typeof(Trimesters), temp[j].ToUpper())); } } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[9] + "\n"; } temp = components[6].Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries); try { for (int j = 0; j < temp.Length; j++) { campusesOffered.Add((Campuses)Enum.Parse(typeof(Campuses), temp[j].ToUpper())); } } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[10] + "\n"; } temp = components[7].Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < temp.Length; j++) { programmeOffered.Add(temp[j]); } try { CWComponent = Convert.ToInt32(components[8]); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[11] + "\n"; } if (exceptionMessage.Length > 1) { throw new ArgumentException(unitCode + " : " + exceptionMessage); } studyunit = new UndergradUnit(unitCode, unitName, prerequisites, creditHours, classification, trimesterOffered, campusesOffered, programmeOffered, CWComponent); allUnits.Add(studyunit); } return(allUnits); }
public Tank(string id, UnitClassification unitType) : base(id, UnitClassification.Mechanical, TankHealth, TankPower, TankkAggression) { }
public Tank(string id, UnitClassification unitType) :base(id, unitType, DefaultHealth, DefaultPower, DefaultAggression) { }
protected Infestor(string id, UnitClassification unitType, int health, int power, int aggression) : base(id, unitType, health, power, aggression) { }
public Infestor(string id, UnitClassification unitType, int health, int power, int aggression) : base(id, unitType, health, power, aggression) { }
protected InfestationUnit(string id, UnitClassification unit, int health, int power, int aggression) : base( id, unit, health, power, aggression) { }
public InfestingUnit(string id, UnitClassification classification, int aggression, int power, int health) : base(id, classification, health, power, aggression) { }
protected Parasite(string id, UnitClassification unitClassification, int health, int power, int aggression) : base(id, unitClassification, health, power, aggression) { }
public InfestingUnit(string id, UnitClassification classification, int aggression, int power , int health) : base(id, classification, health, power, aggression) { }
public InfestingUnit(string id, UnitClassification unitType, int health, int power, int aggression) : base(id, unitType, health, power, aggression) { }
protected InfestingUnit(string id, UnitClassification type, int health, int power, int aggression) : base(id, type, health, power, aggression) { }