private void AddProtectionDescription(List <StyledLine> descriptionResult, IArmorItem equipedArmor) { var equiped = Equals(equipedArmor); foreach (Element element in Enum.GetValues(typeof(Element))) { var value = GetProtection(element); var equipedValue = equipedArmor?.GetProtection(element) ?? 0; if (value != 0 || equipedValue != 0) { var protectionLine = new StyledLine { new StyledString($"{TextHelper.GetElementName(element)}", TextHelper.GetElementColor(element)), " Protection: " }; if (equiped) { protectionLine.Add(TextHelper.GetValueString(value, "%")); } else { protectionLine.Add(TextHelper.GetCompareValueString(value, equipedValue, "%")); } descriptionResult.Add(protectionLine); } } }
public static void AddBonusesDescription(IEquipableItem item, IEquipableItem equiped, List <StyledLine> descriptionResult) { var equalItems = item.Equals(equiped); foreach (var bonusType in Enum.GetValues(typeof(EquipableBonusType)).Cast <EquipableBonusType>()) { var equipedValue = equiped?.GetBonus(bonusType) ?? 0; var value = item.GetBonus(bonusType); if (value == 0 && equipedValue == 0) { continue; } var bonusName = GetEquipableBonusTypeName(bonusType); var bonusDescription = new StyledLine { bonusName, " Bonus: " }; if (equalItems || equiped == null) { bonusDescription.Add(GetValueString(value)); } else { bonusDescription.Add(GetCompareValueString(value, equipedValue)); } descriptionResult.Add(bonusDescription); } foreach (var stat in Enum.GetValues(typeof(PlayerStats)).Cast <PlayerStats>()) { var equipedValue = equiped?.GetStatBonus(stat) ?? 0; var value = item.GetStatBonus(stat); if (value == 0 && equipedValue == 0) { continue; } var bonusName = GetStatName(stat); var bonusDescription = new StyledLine { bonusName, " Bonus: " }; if (equalItems || equiped == null) { bonusDescription.Add(GetValueString(value)); } else { bonusDescription.Add(GetCompareValueString(value, equipedValue)); } descriptionResult.Add(bonusDescription); } }
private void PrintPlayerStats(int dX, int dY, CellSurface surface) { surface.Print(dX, dY, "Stats:"); var stats = Enum.GetValues(typeof(PlayerStats)).Cast <PlayerStats>().ToArray(); var maxLength = stats.Select(TextHelper.GetStatName).Select(name => name.Length).Max(); for (var index = 0; index < stats.Length; index++) { var stat = stats[index]; var pureValue = Player.GetPureStat(stat); var bonusValue = Player.Equipment.GetStatsBonus(stat); var name = TextHelper.GetStatName(stat); var y = dY + 2 + index; surface.Print(dX, y, name); var bonusText = new StyledLine { pureValue.ToString() }; if (bonusValue != 0) { var bonusSymbol = bonusValue > 0 ? "+" : "-"; var bonusColor = bonusValue > 0 ? TextHelper.PositiveValueColor : TextHelper.NegativeValueColor; bonusText.Add(" ("); bonusText.Add($"{bonusSymbol}{bonusValue}", bonusColor); bonusText.Add(")"); } surface.PrintStyledText(dX + maxLength + 1, y, bonusText.ToColoredString(DefaultBackground)); } var xPos = dX + maxLength + 10; surface.PrintStyledText(xPos, dY + 2, new StyledLine { "Max Health ", new StyledString(Player.MaxHealth.ToString(), TextHelper.HealthColor) }.ToColoredString(DefaultBackground)); surface.PrintStyledText(xPos, dY + 3, new StyledLine { "Max Mana ", new StyledString(Player.MaxMana.ToString(), TextHelper.ManaColor) }.ToColoredString(DefaultBackground)); surface.PrintStyledText(xPos, dY + 4, new StyledLine { "Mana Regeneration ", new StyledString(Player.ManaRegeneration.ToString(), TextHelper.ManaRegenerationColor) }.ToColoredString(DefaultBackground)); surface.PrintStyledText(xPos, dY + 5, new StyledLine { "Dodge Chance ", $"{Player.DodgeChance}%" }.ToColoredString(DefaultBackground)); surface.PrintStyledText(dX, dY + 4 + stats.Length, new StyledLine { $"Level: {Player.Level}" }.ToColoredString(DefaultBackground)); surface.PrintStyledText(dX, dY + 5 + stats.Length, new StyledLine { "XP: ", new StyledString($"{Player.Experience} / {Player.GetXpToLevelUp()}", TextHelper.XpColor) }.ToColoredString(DefaultBackground)); }
private StyledLine[] GetCharacteristicsDescription(Player player) { var rightHandWeapon = player.Equipment.RightHandItem as IWeaponItem; var leftHandWeapon = player.Equipment.LeftHandItem as IWeaponItem; var result = new List <StyledLine>(); if (Equals(rightHandWeapon) || Equals(leftHandWeapon) || rightHandWeapon == null) { result.Add(TextHelper.GetWeightLine(Weight)); } else { result.Add(TextHelper.GetCompareWeightLine(Weight, rightHandWeapon.Weight)); } result.Add(StyledLine.Empty); result.Add(TextHelper.GetDurabilityLine(Durability, MaxDurability)); result.Add(StyledLine.Empty); AddDamageDescription(result, leftHandWeapon, rightHandWeapon); var hitChanceLine = new StyledLine { "Accuracy: " }; if (Equals(rightHandWeapon) || Equals(leftHandWeapon) || rightHandWeapon == null) { hitChanceLine.Add(TextHelper.GetValueString(Accuracy, "%", false)); } else { hitChanceLine.Add(TextHelper.GetCompareValueString(Accuracy, rightHandWeapon.Accuracy, "%", false)); } result.Add(hitChanceLine); result.Add(StyledLine.Empty); if (Equals(rightHandWeapon) || Equals(leftHandWeapon) || rightHandWeapon == null) { TextHelper.AddBonusesDescription(this, null, result); } else { TextHelper.AddBonusesDescription(this, rightHandWeapon, result); } result.Add(StyledLine.Empty); TextHelper.AddLightBonusDescription(this, result); return(result.ToArray()); }
public StyledLine[] GetDescription(Player player) { var equipedBook = player.Equipment.SpellBook; var result = new List <StyledLine>(); if (equipedBook == null || Equals(equipedBook)) { result.Add(TextHelper.GetWeightLine(Weight)); } else { result.Add(TextHelper.GetCompareWeightLine(Weight, equipedBook.Weight)); } result.Add(StyledLine.Empty); var capacityLine = new StyledLine { "Spells Capacity: " }; if (equipedBook == null || Equals(equipedBook)) { capacityLine.Add(TextHelper.GetValueString(BookSize, formatBonus: false)); } else { capacityLine.Add(TextHelper.GetCompareValueString(BookSize, equipedBook.BookSize, formatBonus: false)); } result.Add(capacityLine); result.Add(new StyledLine { $"Spells In Book: {Spells.Count(spell => spell != null)}" }); result.Add(StyledLine.Empty); TextHelper.AddBonusesDescription(this, equipedBook, result); result.Add(StyledLine.Empty); TextHelper.AddLightBonusDescription(this, result); result.Add(StyledLine.Empty); result.AddRange(TextHelper.ConvertDescription(Description)); return(result.ToArray()); }
private void AddDamageDescription(List <StyledLine> descriptionResult, IWeaponItem equippedWeaponLeft, IWeaponItem equippedWeaponRight) { foreach (Element element in Enum.GetValues(typeof(Element))) { var maxDamage = GetMaxDamage(this, element); var minDamage = GetMinDamage(this, element); var otherMaxDamage = GetMaxDamage(equippedWeaponRight, element); var otherMinDamage = GetMinDamage(equippedWeaponRight, element); if (maxDamage == 0 && minDamage == 0 && otherMaxDamage == 0 && otherMinDamage == 0) { continue; } var damageLine = new StyledLine { new StyledString($"{TextHelper.GetElementName(element)}", TextHelper.GetElementColor(element)), " Damage: " }; if (Equals(equippedWeaponRight) || Equals(equippedWeaponLeft) || equippedWeaponRight == null) { damageLine.Add($"{minDamage} - {maxDamage}"); } else { var thisMinColor = GetValueDependentColor(minDamage, otherMinDamage); var thisMaxColor = GetValueDependentColor(maxDamage, otherMaxDamage); var otherMinColor = GetValueDependentColor(otherMinDamage, minDamage); var otherMaxColor = GetValueDependentColor(otherMaxDamage, maxDamage); damageLine.Add(new StyledString(minDamage.ToString(), thisMinColor)); damageLine.Add(" - "); damageLine.Add(new StyledString(maxDamage.ToString(), thisMaxColor)); damageLine.Add(" (now "); damageLine.Add(new StyledString(otherMinDamage.ToString(), otherMinColor)); damageLine.Add(" - "); damageLine.Add(new StyledString(otherMaxDamage.ToString(), otherMaxColor)); damageLine.Add(")"); } descriptionResult.Add(damageLine); } }
private void AddProtectionDescription(List <StyledLine> descr, ShieldItem leftHandShield, ShieldItem rightHandShield) { var hitChanceLine = new StyledLine { "Protect Chance: " }; if (Equals(rightHandShield) || Equals(leftHandShield) || leftHandShield == null) { hitChanceLine.Add(TextHelper.GetValueString(ProtectChance, "%", false)); } else { hitChanceLine.Add(TextHelper.GetCompareValueString(ProtectChance, leftHandShield.ProtectChance, "%", false)); } descr.Add(hitChanceLine); var blocksDamageLine = new StyledLine { "Blocks Damage: " }; if (Equals(rightHandShield) || Equals(leftHandShield) || leftHandShield == null) { blocksDamageLine.Add(TextHelper.GetValueString(BlocksDamage, formatBonus: false)); } else { blocksDamageLine.Add(TextHelper.GetCompareValueString(BlocksDamage, leftHandShield.BlocksDamage, formatBonus: false)); } descr.Add(blocksDamageLine); var hitChancePenaltyLine = new StyledLine { "Hit Chance Penalty: " }; if (Equals(rightHandShield) || Equals(leftHandShield) || leftHandShield == null) { hitChancePenaltyLine.Add(TextHelper.GetValueString(HitChancePenalty, "%", false)); } else { hitChancePenaltyLine.Add(TextHelper.GetCompareValueString(HitChancePenalty, leftHandShield.HitChancePenalty, "%", false)); } descr.Add(hitChancePenaltyLine); }
private StyledLine[] GetWeaponDetails(IWeaponItem weapon) { var result = new List <StyledLine> { new StyledLine { $"Accuracy: {weapon.Accuracy + Player.AccuracyBonus}%" }, StyledLine.Empty }; foreach (Element element in Enum.GetValues(typeof(Element))) { var maxDamage = WeaponItem.GetMaxDamage(weapon, element); var minDamage = WeaponItem.GetMinDamage(weapon, element); maxDamage = AttackHelper.CalculateDamage(maxDamage, element, Player); minDamage = AttackHelper.CalculateDamage(minDamage, element, Player); if (maxDamage == 0 && minDamage == 0) { continue; } var damageLine = new StyledLine { new StyledString($"{TextHelper.GetElementName(element)}", TextHelper.GetElementColor(element)), " Damage: ", $"{minDamage} - {maxDamage}" }; result.Add(damageLine); } return(result.ToArray()); }
public static ColoredString[] ToColoredString(this StyledLine line, Color backgroundColor) { return(line.Select(part => new ColoredString(part.String.ConvertGlyphs(), part.TextColor.ToXna(), backgroundColor)).ToArray()); }