protected int GetModTaW(ITalent talent) { var traitBonus = this.charakter.Traits.GetTaW(talent); var retValue = traitBonus + GetDeduction(talent); return(retValue); }
/// <summary> /// Ruft die Bonus TaW ab die übder die Traits gesetzt werden /// </summary> /// <param name="talent"></param> /// <returns></returns> public int GetModTaW(ITalent talent) { var traitValue = charakter.Traits.GetTawBonus(talent); var deductionValue = GetDeductionValue(talent); return(traitValue + deductionValue); }
private TextView GetDeductionText(ITalent talent) { var freeText = ""; var restString = ""; foreach (var deduction in talent.Deductions) { if (typeof(TalentDeductionFreeText).IsAssignableFrom(deduction.GetType())) { freeText = GetString(deduction.GetDeductionString(), freeText); } else if (typeof(TalentDeductionTalent).IsAssignableFrom(deduction.GetType())) { restString = GetString(deduction.GetDeductionString(), restString, string.Empty); } } if (!string.IsNullOrEmpty(restString)) { freeText = GetString(string.Empty, freeText, restString); } return(new TextView() { Text = restString, FreeText = freeText }); }
public static ITalent EditTalent(ITalent talent, List <ITalentDeduction> deductions = null, List <ITalentRequirement> requirements = null) { if (talent == null) { throw new ArgumentNullException(nameof(talent)); } else if (deductions == null) { throw new ArgumentNullException(nameof(deductions)); } talent.Deductions.Clear(); foreach (var deduction in deductions) { talent.Deductions.Add(deduction); } if (requirements != null) { if (typeof(AbstractTalentGeneral).IsAssignableFrom(talent.GetType())) { var abstractTalentGeneral = (AbstractTalentGeneral)talent; abstractTalentGeneral.Requirements = requirements; } else { throw new TalentException( error: ErrorCode.Error, message: Resources.ErrorTalentUnknownTalentTypeEdit ); } } return(talent); }
private TalentView CreateTalentView(ITalent item) { var newItem = new TalentView() { ID = item.ID, Name = item.Name, Probe = GetProbeString(item), BE = item.BE, TAW = GetMaxTaw(item), DeductionText = this.GetDeductionText(item), DeductionList = this.GetDeductionViewList(item), DeductionSelected = this.GetDeductionView(item) }; var talentType = item.GetType(); if (typeof(AbstractTalentGeneral).IsAssignableFrom(talentType)) { var innerItem = (AbstractTalentGeneral)item; newItem.ProbeString = innerItem.GetProbeText(); newItem.RequirementText = GetRequirementText(innerItem); } if (typeof(AbstractTalentFighting).IsAssignableFrom(talentType)) { var innerItem = (AbstractTalentFighting)item; newItem.AT = GetATMax(innerItem); newItem.PA = GetPAMax(innerItem); newItem.BL = GetBLMax(innerItem); } return(newItem); }
/// <summary> /// Ruft die manuell gesetzen TaW ab /// </summary> /// <param name="talent"></param> /// <returns></returns> public int GetTAW(ITalent talent) { if (talent == null) { throw new ArgumentNullException(nameof(talent)); } TAWDictionary.TryGetValue(talent, out int innerTAW); return(innerTAW); }
public int GetTawBonus(ITalent item) { var ret = 0; foreach (var trait in traits) { ret = ret + trait.GetTawBonus(item); } return(ret); }
protected override Guid?GetDeductionID(ITalent talent) { var sql = this.talentRepository.Get(talent); if (sql != null) { return(sql.DeductionID != null ? new Guid(sql.DeductionID) : null); } return(null); }
public TalentDeductionTalent GetDeduction(ITalent talent) { if (talent == null) { throw new TalentException(ErrorCode.InvalidValue, ""); } if (DeductionTalent.TryGetValue(talent, out TalentDeductionTalent deduction)) { return(deduction); } return(null); }
private int GetMaxTaw(ITalent talent) { if (talent == null) { return(0); } var taw = GetTAW(talent); var bonusTaw = GetModTaW(talent); return(taw + bonusTaw); }
public override int GetTAW(ITalent talent) { var sql = this.talentRepository.Get(talent); if (sql != null) { return(sql.TAW); } else { return(0); } }
public TalentDeductionTalent(ITalent talent, int value, int deductionBaseValue, string description = "") { Value = value; Talent = talent; if (value == deductionBaseValue) { IgnoreValue = true; } else { IgnoreValue = false; } Description = description; }
private DeductionView GetDeductionView(ITalent talent) { var deductionID = this.GetDeductionID(talent); if (deductionID != null) { return(new DeductionView() { ID = (Guid)deductionID }); } else { return(null); } }
private List <DeductionView> GetDeductionViewList(ITalent talent) { var deductionList = new List <DeductionView>(); foreach (var deduction in talent.Deductions) { if (typeof(TalentDeductionTalent).IsAssignableFrom(deduction.GetType())) { var innerDeduction = (TalentDeductionTalent)deduction; deductionList.Add(new DeductionView() { ID = innerDeduction.Talent.ID, Name = innerDeduction.Talent.Name }); } } return(deductionList); }
public void SetTAW(ITalent talent, int taw) { if (talent == null) { throw new ArgumentNullException(nameof(talent)); } if (TAWDictionary.TryGetValue(talent, out int innerTAW)) { TAWDictionary.Remove(talent); } TAWDictionary.Add(talent, taw); if (innerTAW != taw) { TaWChanged?.Invoke(this, talent); } }
private string GetProbeString(ITalent talent) { if (talent == null) { throw new ArgumentNullException(nameof(talent)); } var talentType = talent.GetType(); string probe; if (typeof(TalentClose).IsAssignableFrom(talentType) || typeof(TalentWeaponless).IsAssignableFrom(talentType)) { var innertalent = (AbstractTalentFighting)talent; var paValue = GetProbePAValue(innertalent); var atValue = GetProbeATValue(innertalent); var blValue = GetProbeBLValue(innertalent); probe = (atValue).ToString(Helper.CultureInfo) + "/" + (paValue).ToString(Helper.CultureInfo) + "/" + (blValue).ToString(Helper.CultureInfo); } else if (typeof(TalentRange).IsAssignableFrom(talentType)) { var innertalent = (AbstractTalentFighting)talent; var atValue = GetProbeATValue(innertalent); probe = (atValue).ToString(Helper.CultureInfo); } else if (typeof(AbstractTalentGeneral).IsAssignableFrom(talentType)) { var innerTalent = (AbstractTalentGeneral)talent; var probeValue = GetProbeValue(innerTalent); probe = (probeValue).ToString(Helper.CultureInfo); } else if (typeof(AbstractTalentLanguage).IsAssignableFrom(talentType)) { var innerTalent = (AbstractTalentLanguage)talent; probe = (GetProbeValue(innerTalent).ToString(Helper.CultureInfo)); } else { throw new Exception(); } return(probe); }
public void SetDeduction(ITalent talent, TalentDeductionTalent deduction) { if (talent == null) { throw new TalentException(ErrorCode.InvalidValue, ""); } if (deduction != null && !talent.Deductions.Contains(deduction)) { throw new TalentException(ErrorCode.InvalidValue, deduction.GetDeductionString() + " ist keine Deduction vom Talent: " + talent.Name); } if (DeductionTalent.TryGetValue(talent, out TalentDeductionTalent currentDeduction)) { SetDeductionValue(currentDeduction, false); DeductionTalent.Remove(talent); } if (deduction != null) { SetDeductionValue(deduction, true); DeductionTalent.Add(talent, deduction); } }
public static ITalent CreateTalent(string contentType, List <CharakterAttribut> probe, string be, string name, string nameExtension, Guid talentGuid = new Guid(), int orginalPos = -1) { ITalent talent = CreateTalent( contentType: contentType, guid: talentGuid, probe: probe, orginalPos: orginalPos); if (string.IsNullOrEmpty(name)) { throw new TalentException( error: ErrorCode.Error, message: Resources.ErrorNullName); } else if (talent != null) { talent.BE = be; talent.Name = name; talent.NameExtension = nameExtension; } return(talent); }
abstract protected int GetDeduction(ITalent talent);
public static List <ITalent> ExcelImport(string importFile, out List <LanguageFamily> familieList) { familieList = new List <LanguageFamily>(); var ret = new List <ITalent>(); var excelTalentDic = new Dictionary <string, List <ExcelTalent> >(); var talentsWithDeduction = new Dictionary <ITalent, ExcelTalent>(); var talentWithRequirements = new Dictionary <ITalent, ExcelTalent>(); #region Import der Exel Datei SpreadsheetDocument document = SpreadsheetDocument.Open(importFile, false); WorkbookPart wbPart = document.WorkbookPart; List <Sheet> sheets = wbPart.Workbook.Descendants <Sheet>().ToList(); foreach (var sheet in sheets) { var orginalPosition = 0; var contentType = sheet.Name; var currentTitle = string.Empty; var excelTalents = new List <ExcelTalent>(); WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(sheet.Id)); var rowList = wsPart.Worksheet.GetFirstChild <SheetData>().Elements <Row>().ToList(); var titleRowHeaders = new List <string>(); var titleRow = rowList[0]; rowList.RemoveAt(0); //Titel Leiste Entfernen foreach (var cell in titleRow.Descendants <Cell>().ToList()) { var cellValue = ExcelImportGetCellValue(wbPart, cell); titleRowHeaders.Add(cellValue); } foreach (var row in rowList) { var excelTalent = new ExcelTalent(); var celllist = row.Descendants <Cell>().ToList(); var counter = 0; excelTalent.OrginalPosition = orginalPosition++; foreach (var cell in celllist) { var cellValue = ExcelImportGetCellValue(wbPart, cell); excelTalent.AddValue(titleRowHeaders[counter], cellValue); counter++; } var excelRowType = excelTalent.ExcelRowType(); if (excelRowType == ExcleRowType.Title) { var title = excelTalent.Talent.Replace(EXCELTITLE, ""); currentTitle = title; } else if (excelRowType == ExcleRowType.ValidTalent) { excelTalent.Title = currentTitle; excelTalents.Add(excelTalent); } } excelTalentDic.Add(contentType, excelTalents); } #endregion #region Talente Erstellen foreach (var talentGroup in excelTalentDic) { LanguageFamily currentLanguageFamily = null; var talentList = talentGroup.Value; var pos = 0; foreach (var excelTalent in talentList) { var name = string.Empty; var nameExtension = string.Empty; if (excelTalent.Talent.Contains("(")) { var items = excelTalent.Talent.Split('('); name = items[0]; nameExtension = items[1].Split(')').First(); } else { name = excelTalent.Talent; } ITalent newTalent = null; if (!string.IsNullOrEmpty(name)) { newTalent = SearchTalent(name, ret, GetTypeFromString(talentGroup.Key)); if (newTalent == null) { newTalent = CreateTalent( contentType: talentGroup.Key, probe: excelTalent.GetConvertAttribute(), be: excelTalent.BE, name: name, nameExtension: nameExtension, orginalPos: excelTalent.OrginalPosition); } } #region Sprache if (talentGroup.Key == nameof(TalentSpeaking)) { TalentSpeaking talentLanguage = null; TalentWriting talentWriting = null; if (newTalent != null) { talentLanguage = (TalentSpeaking)newTalent; } if (!string.IsNullOrEmpty(excelTalent.Schrift)) { talentWriting = (TalentWriting)SearchTalent(excelTalent.Schrift, ret, typeof(TalentWriting)); if (talentWriting == null) { talentWriting = (TalentWriting)CreateTalent( contentType: nameof(TalentWriting), probe: excelTalent.GetConvertAttribute(), be: excelTalent.Komplex2, name: excelTalent.Schrift, nameExtension: nameExtension); } } if (currentLanguageFamily == null || currentLanguageFamily.Name != excelTalent.Title) { currentLanguageFamily = new LanguageFamily(excelTalent.Title); familieList.Add(currentLanguageFamily); pos = 0; } if (talentLanguage != null) { currentLanguageFamily.Languages.Add(pos, talentLanguage); } if (talentWriting != null) { currentLanguageFamily.Writings.Add(pos, talentWriting); } if (talentWriting != null && !ret.Contains(talentWriting)) { ret.Add(talentWriting); } } #endregion if (excelTalent.IsValidVerwanteFertigkeit()) { talentsWithDeduction.Add(newTalent, excelTalent); } if (excelTalent.IsValidAnforderung()) { talentWithRequirements.Add(newTalent, excelTalent); } if (newTalent != null && !ret.Contains(newTalent)) { ret.Add(newTalent); } pos++; } } ret = new List <ITalent>(ret.OrderBy(x => x.Name)); foreach (var talentwithDeduction in talentsWithDeduction) { var deductionTalentStrings = talentwithDeduction.Value.GetSplitDeduction(); foreach (var deductionString in deductionTalentStrings) { var value = deductionString; var valueint = -1; var mainReqg = new Regex("[(][+][0-9]?[0-9][)]"); var innerReqg = new Regex("[0-9]?[0-9]"); var stringTalentReqg = new Regex("[(][A-Za-zäüß]{1,}[ ]?[A-Za-zäüß]{1,}[)]"); if (mainReqg.IsMatch(deductionString)) { value = mainReqg.Split(deductionString)[0].Trim(); if (!int.TryParse(innerReqg.Match(deductionString).ToString(), out valueint)) { valueint = -1; } } if (valueint == -1) { valueint = talentwithDeduction.Key.BaseDeduction; } ITalentDeduction deduction = null; var deductionTalent = ret.Where(x => x.Name.StartsWith(value, StringComparison.CurrentCulture)); if (deductionTalent.Any()) { deduction = new TalentDeductionTalent(deductionTalent.First(), valueint, talentwithDeduction.Key.BaseDeduction); } else { var stringTalent = stringTalentReqg.Split(deductionString)[0].Trim(); var innerTalent = ret.Where(x => x.Name == stringTalent).FirstOrDefault(); if (innerTalent != null) { value = mainReqg.Split(deductionString)[0].Trim(); if (stringTalentReqg.IsMatch(value)) { var description = stringTalentReqg.Match(value).Value; description = description.Replace("(", "").Replace(")", ""); deduction = new TalentDeductionTalent(innerTalent, valueint, talentwithDeduction.Key.BaseDeduction, description); } else { deduction = new TalentDeductionFreeText(deductionString); } } else { deduction = new TalentDeductionFreeText(deductionString); } } talentwithDeduction.Key.Deductions.Add(deduction); } } foreach (var talentWithRequirement in talentWithRequirements) { var splitRequirement = talentWithRequirement.Value.GetSplitRequirement(); foreach (var requirementString in splitRequirement) { ITalentRequirement requirement; var talent = (AbstractTalentGeneral)talentWithRequirement.Key; var value = requirementString; var valueStart = -1; var valueEnd = -1; var reqTalent = ret.Where(x => x.Name.StartsWith(value, StringComparison.CurrentCulture)); var startReqg = new Regex("[0-9]?[0-9][+][:]"); var endReqg = new Regex("[ ][0-9]?[0-9]"); if (endReqg.IsMatch(value)) { if (startReqg.IsMatch(value)) { var innerStartReq = new Regex("[0-9]?[0-9]"); var startvalue = startReqg.Match(value).ToString(); var truestartValue = innerStartReq.Match(startvalue).ToString(); valueStart = Int32.Parse(truestartValue, Helper.CultureInfo); value = startReqg.Split(value)[1]; } var startSplit = startReqg.Split(value); valueEnd = Int32.Parse(endReqg.Match(value).ToString(), Helper.CultureInfo); value = endReqg.Split(value)[0].Trim(); } requirement = new TalentRequirementFreeText(requirementString); if (reqTalent.Any() && valueEnd != -1 && valueStart != -1) { requirement = new TalentRequirementTalent(reqTalent.First(), valueEnd, valueStart); } else if (reqTalent.Any() && valueEnd != -1) { var trueReqTalent = reqTalent.First(); requirement = new TalentRequirementTalent(reqTalent.First(), valueEnd); } else { requirement = new TalentRequirementFreeText(requirementString); } talent.Requirements.Add(requirement); } } #endregion return(ret); }
private int GetDeductionValue(ITalent talent) { deductionDictionary.TryGetValue(talent, out int value); return(value); }
private static ITalent CreateTalent(string contentType, Guid guid = new Guid(), List <CharakterAttribut> probe = null, int orginalPos = -1) { ITalent talent = null; contentType = contentType.Trim(); if (guid == new Guid() || guid == null) { guid = guid.GenerateNextGuid(talentGuids); talentGuids.Add(guid); } if (contentType == nameof(TalentWeaponless)) { talent = new TalentWeaponless(guid); } else if (contentType == nameof(TalentClose)) { talent = new TalentClose(guid); } else if (contentType == nameof(TalentRange)) { talent = new TalentRange(guid); } else if (contentType == nameof(TalentCrafting)) { talent = new TalentCrafting(guid, probe); } else if (contentType == nameof(TalentKnowldage)) { talent = new TalentKnowldage(guid, probe); } else if (contentType == nameof(TalentNature)) { talent = new TalentNature(guid, probe); } else if (contentType == nameof(TalentPhysical)) { talent = new TalentPhysical(guid, probe); } else if (contentType == nameof(TalentSocial)) { talent = new TalentSocial(guid, probe); } else if (contentType == nameof(TalentSpeaking) || contentType == "TalentLanguage") { //TalentLanguage ist ein Relikt das aber vorhanden sein muss damit man alte Save dateien Laden kann talent = new TalentSpeaking(guid); } else if (contentType == nameof(TalentWriting)) { talent = new TalentWriting(guid); } else { throw new TalentException( error: ErrorCode.Error, message: Resources.ErrorUnknownTalentType); } talent.OrginalPosition = orginalPos; return(talent); }
public static JSONTalent CreateJSON(ITalent talent) { if (talent == null) { throw new ArgumentNullException(nameof(talent)); } JSONTalent jsonTalent; #region TalentType var talenttype = talent.GetType().ToString(); var lastIndex = talenttype.LastIndexOf(".", StringComparison.CurrentCulture); talenttype = talenttype.Substring(lastIndex + 1); #endregion if (!string.IsNullOrEmpty(talent.Name)) { jsonTalent = new JSONTalent { ID = talent.ID, BE = talent.BE, Name = talent.Name, NameExtension = talent.NameExtension, ContentType = talenttype, SaveTime = DateTime.Now, OrginalPos = talent.OrginalPosition, }; foreach (var item in talent.Deductions) { if (typeof(TalentDeductionTalent).IsAssignableFrom(item.GetType())) { var deduction = (TalentDeductionTalent)item; var existingItem = jsonTalent.DeductionTalentList.Where(x => x.ID == deduction.Talent.ID).FirstOrDefault(); if (existingItem != null) { jsonTalent.DeductionTalentList.Remove(existingItem); } jsonTalent.DeductionTalentList.Add(new JSONTalentDeduction { ID = deduction.Talent.ID, Value = deduction.Value, Description = deduction.Description }); } else if (typeof(TalentDeductionFreeText).IsAssignableFrom(item.GetType())) { var deduction = (TalentDeductionFreeText)item; jsonTalent.DeductionStrings.Add(deduction.Text); } } if (typeof(AbstractTalentGeneral).IsAssignableFrom(talent.GetType())) { var abstractTalentGeneral = (AbstractTalentGeneral)talent; jsonTalent.Probe = abstractTalentGeneral.Attributs; foreach (var requirement in abstractTalentGeneral.Requirements) { if (requirement.GetType() == typeof(TalentRequirementTalent)) { var req = (TalentRequirementTalent)requirement; if (jsonTalent.RequirementNeed == null) { jsonTalent.RequirementNeed = new Dictionary <Guid, int>(); jsonTalent.RequirementOff = new Dictionary <Guid, int>(); } if (jsonTalent.RequirementOff.ContainsKey(req.Talent.ID)) { throw new Exception(Resources.ErrorTalentDobbleRequirement); } else { jsonTalent.RequirementNeed.Add(req.Talent.ID, req.ReqNeed); jsonTalent.RequirementOff.Add(req.Talent.ID, req.ReqOff); } } else if (requirement.GetType() == typeof(TalentRequirementAttribut)) { var req = (TalentRequirementAttribut)requirement; if (jsonTalent.RequirementAttributs == null) { jsonTalent.RequirementAttributs = new Dictionary <CharakterAttribut, int>(); } jsonTalent.RequirementAttributs.Add(req.Attribut, req.AttributValue); } else if (requirement.GetType() == typeof(TalentRequirementFreeText)) { var req = (TalentRequirementFreeText)requirement; if (jsonTalent.RequirementStrings == null) { jsonTalent.RequirementStrings = new List <string>(); } jsonTalent.RequirementStrings.Add(req.FreeText); } else { throw new Exception(Resources.ErrorTalentUnknwonRequirement); } } } } else { throw new Exception(Resources.ErrorTalentMissingVariables); } return(jsonTalent); }
internal int GetDeduction(ITalent talent) { var list = dbSet.Where(x => x.DeductionID == talent.ID.ToString() && x.CharakterID == charakterID).ToList(); return(list.Count); }
internal T_Talente Get(ITalent talent) { return(dbSet.Where(x => x.TalentID == talent.ID.ToString() && x.CharakterID == charakterID).FirstOrDefault()); }
protected override int GetDeduction(ITalent talent) { return(this.talentRepository.GetDeduction(talent)); }
abstract public int GetTAW(ITalent talent);
static Talent() { LogicServer.Instance.UpdateManager.InitStaticImpl(typeof(Talent), typeof(TalentDefaultImpl), o => { mImpl = (ITalent)o; }); }
public TalentRequirementTalent(ITalent talent, int reqNeed, int reqoff = 0) { Talent = talent; ReqNeed = reqNeed; ReqOff = reqoff; }
abstract protected Guid?GetDeductionID(ITalent talent);