/// <summary> /// Removes the effect of the effect (heh) on the actor. This includes removing it from GameState /// </summary> /// <param name="actor"></param> /// <param name="effect"></param> public static void RemoveEffect(Effect effect) { switch (effect.Name) { case EffectName.AGIL: effect.Actor.Attributes.TempAgil -= effect.EffectAmount; break; case EffectName.BRAWN: effect.Actor.Attributes.TempBrawn -= effect.EffectAmount; break; case EffectName.CHAR: effect.Actor.Attributes.TempChar -= effect.EffectAmount; break; case EffectName.INTEL: effect.Actor.Attributes.TempIntel -= effect.EffectAmount; break; case EffectName.PERC: effect.Actor.Attributes.TempPerc -= effect.EffectAmount; break; case EffectName.BLIND: effect.Actor.Attributes.TempPerc += effect.EffectAmount; break; case EffectName.HEAL: break; } GameState.LocalMap.ActiveEffects.Remove(effect); }
/// <summary> /// Performs the effect on this actor. This includes assigning it to the effects list of the GameState /// </summary> /// <param name="actor"></param> /// <param name="effect"></param> public static void PerformEffect(Actor actor,Effect effect) { switch(effect.Name) { case EffectName.AGIL: actor.Attributes.TempAgil = actor.Attributes.TempAgil ?? 0 + effect.EffectAmount; break; case EffectName.BRAWN: actor.Attributes.TempBrawn = actor.Attributes.TempBrawn ?? 0 + effect.EffectAmount; break; case EffectName.CHAR: actor.Attributes.TempChar = actor.Attributes.TempChar ?? 0 + effect.EffectAmount; break; case EffectName.INTEL: actor.Attributes.TempIntel = actor.Attributes.TempIntel ?? 0 + effect.EffectAmount; break; case EffectName.PERC: actor.Attributes.TempPerc = actor.Attributes.TempPerc ?? 0 + effect.EffectAmount; break; case EffectName.BLIND: actor.Attributes.TempPerc = (actor.Attributes.TempPerc ?? 0) - effect.EffectAmount; break; case EffectName.HEAL: HealthCheckManager.HealCharacter(actor, 5); break; } effect.Actor = actor; GameState.LocalMap.ActiveEffects.Add(effect); }
public ReceiveEffectFeedback(Effect effect) { this.Effect = effect; }
/// <summary> /// The effect to apply when the potion is thrown upon the actors. /// Also handles learnign (for those which give an effect) and feedback /// </summary> /// <param name="actors"></param> /// <returns></returns> public ActionFeedback[] ThrowUpon(Actor attacker, List<Actor> actors) { List<ActionFeedback> feedback = new List<ActionFeedback>(); switch (this.PotionType) { case Enums.PotionType.AGILITY: foreach (var actor in actors) { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 1; effect.MinutesLeft = 2; effect.Name = EffectName.AGIL; if (actor.IsPlayerCharacter) { effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); } feedback.Add(new ReceiveEffectFeedback() { Effect = effect }); } feedback.Add(new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The victims of the splash look faster somehow")); this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return feedback.ToArray(); case Enums.PotionType.BLEEDING: foreach (var actor in actors) { actor.Anatomy.BloodLoss = 2; } feedback.Add(new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Metal shards spray over the area")); this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return feedback.ToArray(); case Enums.PotionType.BLINDING: foreach (var actor in actors) { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 5; effect.MinutesLeft = 3; effect.Name = EffectName.BLIND; if (actor.IsPlayerCharacter) { effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "You can see again"); } feedback.Add(new ReceiveEffectFeedback(effect)); } this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); feedback.Add(new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "There is a blinding flash of light")); return feedback.ToArray(); case Enums.PotionType.BRAWN: foreach (var actor in actors) { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 1; effect.MinutesLeft = 2; effect.Name = EffectName.BRAWN; if (actor.IsPlayerCharacter) { effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); } feedback.Add(new ReceiveEffectFeedback() { Effect = effect }); } feedback.Add(new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The victims of the splash look stronger somehow")); this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return feedback.ToArray(); case Enums.PotionType.CHARISMA: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.DEFENCE: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.DEFENSIVE_KNOWLEDGE: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.FEEDING: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "There is a delicious smell") }; case Enums.PotionType.FIRE: foreach (var actor in actors) { actor.Anatomy.Chest -= 2; actor.Anatomy.Head -= 1; } this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The potion explodes in flames") }; case Enums.PotionType.HEALING: foreach (var actor in actors) { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 0; effect.Name = EffectName.HEAL; feedback.Add(new ReceiveEffectFeedback() { Effect = effect }); } feedback.Add(new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The victims of the splash look healthier")); this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return feedback.ToArray(); case Enums.PotionType.ICE: foreach (var actor in actors) { actor.Anatomy.Chest -= 1; actor.Anatomy.Head -= 1; actor.Anatomy.Legs -= 1; } this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The potion explodes in shards of ice") }; case Enums.PotionType.INTELLIGENCE: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.OFFENSIVE_KNOWLEDGE: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.PARALYSIS: foreach (var actor in actors) { actor.Anatomy.StunAmount += 2; } this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The victims seem to have trouble moving") }; case Enums.PotionType.PERCEPTION: return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "Nothing happens") }; case Enums.PotionType.POISON: foreach (var actor in actors) { actor.Anatomy.Chest -= 3; } this.IsIdentified = true; attacker.Knowledge.LearnToIdentify(this.PotionType); return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The potion vaporises into a thick green cloud") }; default: throw new NotImplementedException("Code for " + this.PotionType + " not implemented"); } }
public override ActionFeedback[] PerformAction(ActionType actionType, Actor actor, object[] args) { //See if we can identify the item if (actor.Knowledge.CanIdentifyPotion(this.PotionType)) { this.IsIdentified = true; //identify! } if (actionType == ActionType.CONSUME) { //Take the effects of the potion //Identify it too! this.IsIdentified = true; actor.Knowledge.LearnToIdentify(this.PotionType); //remove from inventory actor.Inventory.Inventory.Remove(this.Category, this); switch (this.PotionType) { case Enums.PotionType.AGILITY: { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 5; effect.Name = EffectName.AGIL; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel more agile") }; } case Enums.PotionType.BLEEDING: actor.Anatomy.BloodLoss = 2; //Start bleeding. Silly idiot return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion scrapes your insides as you drink it. You start bleeding") }; case Enums.PotionType.BLINDING: { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 10; effect.MinutesLeft = 3; effect.Name = EffectName.BLIND; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "You can see again"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "Your eyes cloud over.") }; } case Enums.PotionType.BRAWN: { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 5; effect.Name = EffectName.BRAWN; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel strong") }; } case Enums.PotionType.CHARISMA: { //AKA Alcohol :) Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 5; effect.Name = EffectName.CHAR; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel more confident") }; } case Enums.PotionType.DEFENCE: actor.CurrentDefences = actor.MaximumDefences; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your defences are ready once more") }; case Enums.PotionType.DEFENSIVE_KNOWLEDGE: { for (int i = 0; i < 20; i++) { actor.Attributes.IncreaseSkill(SkillName.DODGER); } return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You become more knowledgable about not getting hit") }; } case Enums.PotionType.FEEDING: { //Fill em up actor.FeedingLevel = FeedingLevel.STUFFED; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel rather full") }; } case Enums.PotionType.FIRE: { actor.Anatomy.Chest -= 2; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion tastes like fire. That burns a bit...") }; } case Enums.PotionType.HEALING: { //Be healed! This is not strictly speaking an effect, but that should be fine Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 5; effect.MinutesLeft = 0; effect.Name = EffectName.HEAL; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your wounds heal..."); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your wounds close") }; } case Enums.PotionType.ICE: { actor.Anatomy.Chest -= 2; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion freezes your insides.") }; } case Enums.PotionType.INTELLIGENCE: { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 5; effect.Name = EffectName.INTEL; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel smarter") }; } case Enums.PotionType.OFFENSIVE_KNOWLEDGE: { for (int i = 0; i < 20; i++) { actor.Attributes.IncreaseSkill(SkillName.FIGHTER); } return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You become more knowledgable about hitting things") }; } case Enums.PotionType.PARALYSIS: { actor.Anatomy.StunAmount = 3; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "You can't move...") }; } case Enums.PotionType.PERCEPTION: { Effect effect = new Effect(); effect.Actor = actor; effect.EffectAmount = 2; effect.MinutesLeft = 5; effect.Name = EffectName.PERC; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off"); return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your vision feels sharper") }; } case Enums.PotionType.POISON: { actor.Anatomy.Chest -= 2; return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "This potion tastes horrible. You feel sick.") }; } default: throw new NotImplementedException("No code for " + this.PotionType); } } else { return base.PerformAction(actionType, actor, args); } }
/// <summary> /// Get a blessing for this particular actor, and apply it. /// </summary> /// <param name="actor"></param> public static void GetAndApplyBlessing(Actor actor, out LogFeedback logFeedback) { //Determine how much skill they have int effectiveSkill = actor.Attributes.GetSkill(SkillName.RITUALIST) + actor.Attributes.Char - 5; effectiveSkill = effectiveSkill > 1 ? effectiveSkill : 1; //at least 1 //Get a random number from 0 to effectiveskill * 2 int randomNumber = GameState.Random.Next(0, effectiveSkill * 2); //Grab this number and pick the Blessing with the right enum. if we're too big then go for the biggest value BlessingType[] blessings = (BlessingType[])Enum.GetValues(typeof(BlessingType)); if (randomNumber >= blessings.Length) { randomNumber = blessings.Length; } //And your blessing is.... BlessingType blessing = blessings[randomNumber]; //Now let's see what type of blessing it is InventoryItemManager iim = new InventoryItemManager(); Effect effect = new Effect(); logFeedback = null; switch (blessing) { case BlessingType.AGIL_1: //Apply +1 agility for 4 times the effective skill effect.EffectAmount = 1; effect.Name = EffectName.AGIL; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.AGIL_2: effect.EffectAmount = 2; effect.Name = EffectName.AGIL; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.ARMOUR: { //Spawn a piece of armour worth 50 * effective skill var inventoryItem = iim.GetBestCanAfford("ARMOUR", 50 * effectiveSkill); if (inventoryItem != null) { inventoryItem.InInventory = true; actor.Inventory.Inventory.Add(inventoryItem.Category, inventoryItem); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "Your have been given a gift..."); } else { logFeedback = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkRed, "Your prayers have not been answered"); } } break; case BlessingType.BRAWN_1: effect.EffectAmount = 1; effect.Name = EffectName.BRAWN; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.BRAWN_2: effect.EffectAmount = 2; effect.Name = EffectName.BRAWN; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.CHAR_1: effect.EffectAmount = 1; effect.Name = EffectName.CHAR; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.CHAR_2: effect.EffectAmount = 2; effect.Name = EffectName.CHAR; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.DEFENCE: //TODO LATER break; case BlessingType.EXPERIENCE: //Increase the skill in Rituals by a 10 times (fixed) for (int i = 0; i < 10; i++) { actor.Attributes.IncreaseSkill(SkillName.RITUALIST); } logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "Nothing happens, but you feel smarter for having tried"); break; case BlessingType.EXPLORE: //Explore the entire map for (int x = 0; x < GameState.LocalMap.localGameMap.GetLength(0); x++) { for (int y = 0; y < GameState.LocalMap.localGameMap.GetLength(1); y++) { if (GameState.LocalMap.localGameMap[x, y, 0] != null) { GameState.LocalMap.localGameMap[x, y, 0].WasVisited = true; } } } logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You have been granted knowledge on the structure of this level"); break; case BlessingType.FEEDING: //A slap-up meal actor.FeedingLevel = FeedingLevel.STUFFED; logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel very full..."); break; case BlessingType.HEALING: //Heal the user for as many rounds as effective skill HealthCheckManager.HealCharacter(actor, effectiveSkill); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel your wounds knit together"); break; case BlessingType.INTEL_1: effect.EffectAmount = 1; effect.Name = EffectName.INTEL; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.INTEL_2: effect.EffectAmount = 2; effect.Name = EffectName.INTEL; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.KILL: //Go through the map and slaughter a total amount of enemies equal to effective skill for (int i = 0; i < effectiveSkill; i++) { var deadActor = GameState.LocalMap.Actors.Where(a => a.IsAggressive && a.IsActive && a.IsAlive && !a.IsPlayerCharacter).FirstOrDefault(); if (deadActor != null) { CombatManager.KillCharacter(deadActor); } } logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "A sprit of death travels through the location and slaughters a number of your enemies"); break; case BlessingType.LOOT: { //Spawn a piece of loot worth 50 * effective skill var inventoryItem = iim.GetBestCanAfford("LOOT", 50 * effectiveSkill); if (inventoryItem != null) { inventoryItem.InInventory = true; actor.Inventory.Inventory.Add(inventoryItem.Category, inventoryItem); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "Your have been given a gift..."); } else { logFeedback = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkRed, "Your prayers have not been answered"); } } break; case BlessingType.PERC_1: effect.EffectAmount = 1; effect.Name = EffectName.PERC; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.PERC_2: effect.EffectAmount = 2; effect.Name = EffectName.PERC; effect.MinutesLeft = 4 * effectiveSkill; effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "The effect of the blessing disappears"); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "You feel different. Good different"); break; case BlessingType.WEAPON: { //Spawn a piece of loot worth 50 * effective skill var inventoryItem = iim.GetBestCanAfford("WEAPON", 50 * effectiveSkill); if (inventoryItem != null) { inventoryItem.InInventory = true; actor.Inventory.Inventory.Add(inventoryItem.Category, inventoryItem); logFeedback = new LogFeedback(InterfaceSpriteName.SUN, Color.ForestGreen, "Your have been given a gift..."); } else { logFeedback = new LogFeedback(InterfaceSpriteName.MOON, Color.DarkRed, "Your prayers have not been answered"); } } break; } if (effect != null) { //Apply it EffectsManager.PerformEffect(actor, effect); } }