public void ReadjustMaxes(BuffBox buffs) { MaxHealth = Convert.ToDecimal(GetWillpowerBaseByLevel(Level)) * (1.0M + (buffs.HealthBonusPercent() / 100.0M)); MaxMana = Convert.ToDecimal(GetManaBaseByLevel(Level)) * (1.0M + (buffs.ManaBonusPercent() / 100.0M)); ExtraInventory = buffs.ExtraInventorySpace(); SneakPercent = buffs.SneakPercent(); MoveActionPointDiscount = buffs.MoveActionPointDiscount(); ForceWithinBounds(); }
/// <summary> /// Have the player cleanse, restoring some willpower and reduce TF Energies, modified by the player's buffs /// </summary> /// <param name="buffs">Player's buffs</param> /// <returns>Cleanse amount</returns> public string Cleanse(BuffBox buffs) { CleansesMeditatesThisRound++; ActionPoints -= PvPStatics.CleanseCost; Mana -= PvPStatics.CleanseManaCost; LastActionTimestamp = DateTime.UtcNow; var result = ""; var cleanseBonusTFEnergyRemovalPercent = buffs.CleanseExtraTFEnergyRemovalPercent() + PvPStatics.CleanseTFEnergyPercentDecrease; var cleanseWPRestore = PvPStatics.CleanseHealthRestoreBase + buffs.CleanseExtraHealth(); var outOfCombat = false; // Increase the rate of cleansing outside of combat var lastAttackTimeAgo = Math.Abs(Math.Floor(GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalSeconds)); if (lastAttackTimeAgo > 3 * TurnTimesStatics.GetTurnLengthInSeconds()) { outOfCombat = true; } if (cleanseWPRestore <= 0) { result = "You try to cleanse, but due to the magical effects on your body you fail to restore any willpower."; } else { if (outOfCombat) { AddHealth(cleanseWPRestore * 3); result = $"You take your time cleansing yourself, restoring {cleanseWPRestore * 3:#} willpower."; } else { AddHealth(cleanseWPRestore); result = $"You quickly cleanse, restoring {cleanseWPRestore:#} willpower."; } } if (cleanseBonusTFEnergyRemovalPercent > 0) { CleanseTFEnergies(buffs); } if (BotId == AIStatics.ActivePlayerBotId) { var location = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == Location); AddLog($"You cleansed at {location.Name}.", false); } return(result); }
/// <summary> /// Return the player's stat of a given QuestConnectionRequirement. Ex: player has 50 luck /// </summary> /// <param name="q">QuestConnectionRequirement to be evaluated</param> /// <param name="buffs">The player's stats</param> /// <returns></returns> private static float GetValueFromType(QuestConnectionRequirement q, BuffBox buffs) { float playerValue = 0; // get correct ability type requirement if (q.RequirementType == (int)QuestStatics.RequirementType.Discipline) { playerValue = buffs.Discipline(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Perception) { playerValue = buffs.Perception(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Charisma) { playerValue = buffs.Charisma(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Fortitude) { playerValue = buffs.Fortitude(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Agility) { playerValue = buffs.Agility(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Allure) { playerValue = buffs.Allure(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Magicka) { playerValue = buffs.Magicka(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Succour) { playerValue = buffs.Succour(); } else if (q.RequirementType == (int)QuestStatics.RequirementType.Luck) { playerValue = buffs.Luck(); } return(playerValue); }
public string Meditate(BuffBox buffs) { CleansesMeditatesThisRound++; ActionPoints -= PvPStatics.MeditateCost; LastActionTimestamp = DateTime.UtcNow; var result = ""; var meditateManaRestore = PvPStatics.MeditateManaRestoreBase + buffs.MeditationExtraMana(); var outOfCombat = false; // Increase the rate of meditation outside of combat var lastAttackTimeAgo = Math.Abs(Math.Floor(GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalSeconds)); if (lastAttackTimeAgo > 3 * TurnTimesStatics.GetTurnLengthInSeconds()) { outOfCombat = true; } if (meditateManaRestore < 0) { result = "You try to meditate, but due to the magical effects on your body you fail to restore any mana."; } else { if (outOfCombat) { AddMana(meditateManaRestore * 3); result = $"You take your time meditating, restoring {meditateManaRestore * 3:#} mana."; } else { AddMana(meditateManaRestore); result = $"You quickly meditate, restoring {meditateManaRestore:#} mana."; } } if (BotId == AIStatics.ActivePlayerBotId) { var location = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == Location); AddLog($"You meditated at {location.Name}.", false); } return(result); }
/// <summary> /// Removes a percentage of TF energy that this player has, determined by the stats passed in /// </summary> /// <param name="buffs">Buffs owned by the player</param> public void CleanseTFEnergies(BuffBox buffs) { var cleansePercentage = buffs.CleanseExtraTFEnergyRemovalPercent() + PvPStatics.CleanseTFEnergyPercentDecrease; // Increase the rate of TFE cleansing outside of combat var lastAttackTimeAgo = Math.Abs(Math.Floor(GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalSeconds)); if (lastAttackTimeAgo > 3 * TurnTimesStatics.GetTurnLengthInSeconds()) { cleansePercentage = (cleansePercentage * 5); } foreach (var energy in TFEnergies) { var newValue = energy.Amount - cleansePercentage; energy.SetAmount(newValue); } }
public void reducing_tf_energy_reduces_by_greater_percent_with_buffs() { var tfEnergies = new List <TFEnergy> { new TFEnergyBuilder().With(t => t.Amount, 100).BuildAndSave() }; var player = new PlayerBuilder() .With(p => p.Id, 50) .With(p => p.TFEnergies, tfEnergies) .BuildAndSave(); var buffs = new BuffBox { FromForm_CleanseExtraTFEnergyRemovalPercent = 10 }; player.CleanseTFEnergies(buffs); Assert.That(player.TFEnergies.First().Amount, Is.EqualTo(40)); }
public void ReadjustMaxes(BuffBox buffs) { // readjust this health/mana by grabbing base amount plus effects from buffs this.MaxHealth = Convert.ToDecimal(PlayerProcedures.GetWillpowerBaseByLevel(this.Level)) * (1.0M + (buffs.HealthBonusPercent() / 100.0M)); this.MaxMana = Convert.ToDecimal(PlayerProcedures.GetManaBaseByLevel(this.Level)) * (1.0M + (buffs.ManaBonusPercent() / 100.0M)); // keep this's health within proper bounds if (this.MaxHealth < 1) { this.MaxHealth = 1; } if (this.MaxMana < 1) { this.MaxMana = 1; } if (this.Health > this.MaxHealth) { this.Health = this.MaxHealth; } if (this.Mana > this.MaxMana) { this.Mana = this.MaxMana; } if (this.Health < 0) { this.Health = 0; } if (this.Mana < 0) { this.Mana = 0; } this.ExtraInventory = buffs.ExtraInventorySpace(); SneakPercent = buffs.SneakPercent(); MoveActionPointDiscount = buffs.MoveActionPointDiscount(); }
public void Init() { originalForm = new FormSourceBuilder() .With(n => n.Id, 1) .With(n => n.FriendlyName, "Base Form") .With(n => n.Gender, PvPStatics.GenderFemale) .BuildAndSave(); currentForm = new FormSourceBuilder() .With(n => n.Id, 2) .With(n => n.FriendlyName, "Current Form") .With(n => n.Gender, PvPStatics.GenderMale) .BuildAndSave(); player = new PlayerBuilder() .With(p => p.Id, 23) .With(p => p.FormSource, currentForm) .With(p => p.OriginalFormSource, originalForm) .With(p => p.ActionPoints, 50) .With(p => p.Mana, 25) .BuildAndSave(); buffs = new BuffBox(); }
public string AddSelfRestoreEnergy(BuffBox buffs) { var actualAmount = 10 + (float)Math.Floor(buffs.Allure() / 10); if (this.SelfRestoreEnergy == null) { this.SelfRestoreEnergy = SelfRestoreEnergy.Create(this, actualAmount); } else { this.SelfRestoreEnergy.AddAmount(actualAmount); } this.CleansesMeditatesThisRound++; this.ActionPoints -= (decimal)PvPStatics.SelfRestoreAPCost; this.Mana -= (decimal)PvPStatics.SelfRestoreManaCost; this.LastActionTimestamp = DateTime.UtcNow; if (this.SelfRestoreEnergy.Amount < PvPStatics.SelfRestoreTFnergyRequirement) { var output = $"You rest and attempt to restore yourself to your base form. [+{(int)actualAmount}, {(int)this.SelfRestoreEnergy.Amount}/{PvPStatics.SelfRestoreTFnergyRequirement}]. Keep trying and you'll find yourself in a familiar form in no time..."; this.AddLog(output, false); return(output); } else { this.SelfRestoreEnergy.Reset(); this.FormSource = this.OriginalFormSource; this.Gender = this.OriginalFormSource.Gender; this.FirstName = this.OriginalFirstName ?? this.FirstName; this.LastName = this.OriginalLastName ?? this.LastName; var output = "<span class='meditate'>With this final cast, you manage to restore yourself back to your base form as a <b>" + OriginalFormSource.FriendlyName + "</b>!<span>"; this.AddLog(output, false); return(output); } }
public override void SetUp() { base.SetUp(); b = new QuestConnectionBuilder(); buffs = new BuffBox(); }
public void Init() { buffs = new BuffBox(); }
public static string AttackLocation(Player player, BuffBox buffs) { ILocationInfoRepository repo = new EFLocationInfoRepository(); ICovenantRepository covRepo = new EFCovenantRepository(); var location = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == player.dbLocationName); var output = ""; if (location == null) { output = "You cast an enchantment here, but you aren't actually anywhere!"; return(output); } var info = repo.LocationInfos.FirstOrDefault(l => l.dbName == player.dbLocationName) ?? new LocationInfo { TakeoverAmount = 75, CovenantId = -1, dbName = player.dbLocationName, }; if (player.Covenant == null) { output = "You cast an enchantment here, but it did no effect as you aren't part of a covenant"; return(output); } if (info.TakeoverAmount >= 100 && info.CovenantId == player.Covenant) { output = "You cast an enchantment here, but it did no effect as this location's enchantment is already at its highest possible level, 100."; return(output); } var takeoverAmount = (float)player.Level / 2.0F; takeoverAmount += buffs.EnchantmentBoost; decimal XPGain = 0; try { XPGain = 40 / Math.Round(Convert.ToDecimal(101 - Math.Abs(info.TakeoverAmount)), 1); } catch (Exception) { XPGain = 0; } if (XPGain > PvPStatics.XP__EnchantmentMaxXP) { XPGain = PvPStatics.XP__EnchantmentMaxXP; } var XPGainText = String.Format("{0:0.#}", XPGain); // location is not controlled; give it to whichever covenant is attacking it if (info.TakeoverAmount <= 0) { info.CovenantId = (int)player.Covenant; info.TakeoverAmount = takeoverAmount; if (info.TakeoverAmount > 100) { info.TakeoverAmount = 100; } info.LastTakeoverTurn = PvPWorldStatProcedures.GetWorldTurnNumber(); output = "<b>Your enchantment settles in this location, converting its energies from the previous controlling covenant to your own! (+" + XPGainText + " XP)</b>"; location.CovenantController = (int)player.Covenant; location.TakeoverAmount = info.TakeoverAmount; var myCov = covRepo.Covenants.First(c => c.Id == player.Covenant); var locationLogMessage = "<b class='playerAttackNotification'>" + player.GetFullName() + " enchanted this location and claimed it for " + myCov.Name + "!</b>"; LocationLogProcedures.AddLocationLog(player.dbLocationName, locationLogMessage); var covLogWinner = player.GetFullName() + " enchanted " + location.Name + " and has claimed it for this covenant."; CovenantProcedures.WriteCovenantLog(covLogWinner, myCov.Id, true); } // otherwise the location is controlled by someone else { // add points toward the attacker's covenant or take them away if it belongs to another if (info.CovenantId == player.Covenant) { info.TakeoverAmount += takeoverAmount; location.TakeoverAmount = info.TakeoverAmount; var cov = covRepo.Covenants.FirstOrDefault(c => c.Id == player.Covenant); output = $"Your enchantment reinforces this location by {takeoverAmount}. New influence level is {info.TakeoverAmount} for your covenant, {cov?.Name ?? "unknown"}. (+{XPGainText} XP)</b>"; } else { info.TakeoverAmount -= takeoverAmount; location.TakeoverAmount = info.TakeoverAmount; var cov = info.CovenantId == null ? null : covRepo.Covenants.FirstOrDefault(c => c.Id == info.CovenantId); if (info.TakeoverAmount <= 0) { // notify old covenant who stole the location and their covenant if (info.CovenantId != null && info.CovenantId > 0) { var attackingCov = CovenantProcedures.GetCovenantViewModel((int)player.Covenant); var covLogLoser = player.GetFullName() + " of " + attackingCov.dbCovenant.Name + " enchanted " + location.Name + ", removing it from this covenant's influence!"; CovenantProcedures.WriteCovenantLog(covLogLoser, (int)info.CovenantId, true); } info.CovenantId = -1; info.LastTakeoverTurn = PvPWorldStatProcedures.GetWorldTurnNumber(); } if (cov != null) { output = "You dispel the enchantment at this location by " + takeoverAmount + ". New influence level is " + info.TakeoverAmount + " for the location's existing controller, " + cov.Name + ". (+" + XPGainText + " XP)</b>"; } else { output = "You dispel the enchantment at this location by " + takeoverAmount + ". New influence level is " + info.TakeoverAmount + ". (+" + XPGainText + " XP)</b>"; } } var locationLogMessage = "<span class='playerAttackNotification'>" + player.GetFullName() + " cast an enchantment on this location.</span>"; LocationLogProcedures.AddLocationLog(player.dbLocationName, locationLogMessage); } if (info.TakeoverAmount > 100) { info.TakeoverAmount = 100; } // cap at 0 to 100 points else if (info.TakeoverAmount <= 0) { info.CovenantId = -1; info.TakeoverAmount = 0; } repo.SaveLocationInfo(info); PlayerProcedures.GiveXP(player, XPGain); PlayerLogProcedures.AddPlayerLog(player.Id, output, false); return(output); }
/// <summary> /// Returns true if a player passes all rolls for a quest connection. /// </summary> /// <param name="connection"></param> /// <param name="player">Player attempting to go down this connection</param> /// <param name="buffs">Player's statistics from effects and equipment</param> /// <param name="variables">All quest variables created by this player previously in the quest</param> /// <returns></returns> public static bool RollForQuestConnection(QuestConnection connection, Player player, BuffBox buffs, IEnumerable <QuestPlayerVariable> variables) { foreach (var q in connection.QuestConnectionRequirements) { if (!q.IsRandomRoll) { continue; } var playerValue = GetValueFromType(q, buffs); var chance = q.RollModifier * playerValue + q.RollOffset; var r = new Random(); var roll = r.NextDouble() * 100; if (roll > chance) { return(false); } } return(true); }
public static string GetRequirementsAsString(QuestConnection q, BuffBox buffs) { var output = ""; if (!q.QuestConnectionRequirements.Any()) { return(output); } var len = q.QuestConnectionRequirements.Count(); var i = 0; output += "["; foreach (var qs in q.QuestConnectionRequirements.ToList()) { // don't print anything for variables or gender requirements if (qs.RequirementType == (int)QuestStatics.RequirementType.Variable || qs.RequirementType == (int)QuestStatics.RequirementType.Gender || qs.RequirementType == (int)QuestStatics.RequirementType.Form) { continue; } // random roll, calculate % chance and display that if (qs.IsRandomRoll) { var playerValue = GetValueFromType(qs, buffs); var chance = Math.Round(qs.RollModifier * playerValue + qs.RollOffset, 1); if (chance < 0) { chance = 0; } else if (chance > 100) { chance = 100; } output += qs.PrintRequirementStatAsString() + " - " + chance + "%"; } // strict requirement else { output += qs.PrintOperatorAsString() + " " + qs.RequirementValue + " " + qs.PrintRequirementStatAsString(); } if (i < len - 1) { output += ", "; } i++; } output += "]"; // no requirements were found, so clear up if (output == "[]") { output = ""; } return(output); }
/// <summary> /// Returns true if a connection is available to the player to take. /// </summary> /// <param name="questConnection"></param> /// <param name="player">Player attempting to go down this connection</param> /// <param name="buffs">Player's statistics from effects and equipment</param> /// <param name="variables">All quest variables created by this player previously in the quest</param> /// <returns></returns> public static bool QuestConnectionIsAvailable(QuestConnection questConnection, Player player, BuffBox buffs, IEnumerable <QuestPlayerVariable> variables) { var isAvailable = true; if (questConnection.QuestStateFromId < 0 || questConnection.QuestStateToId < 0) { return(false); } foreach (var q in questConnection.QuestConnectionRequirements) { // skip all roll-based requirements; a player can always attempt a roll if (q.IsRandomRoll) { continue; } // evaluate variable if (q.RequirementType == (int)QuestStatics.RequirementType.Variable) { var var = variables.FirstOrDefault(v => v.VariableName == q.VariabledbName); // variable has never been set, so fail if (var == null) { return(false); } isAvailable = ExpressionIsTrue(float.Parse(var.VariableValue), q); if (!isAvailable) { return(false); } else { continue; } } else if (q.RequirementType == (int)QuestStatics.RequirementType.Gender) { if (q.RequirementValue == PvPStatics.GenderMale && player.Gender != PvPStatics.GenderMale) { return(false); } else if (q.RequirementValue == PvPStatics.GenderFemale && player.Gender != PvPStatics.GenderFemale) { return(false); } else { continue; } } // evaluate player buff/ability var playerValue = GetValueFromType(q, buffs); isAvailable = ExpressionIsTrue(playerValue, q); if (!isAvailable) { return(false); } } return(true); }