/// <summary> /// Plays a spell /// </summary> /// <param name="spell">The spell to play</param> /// <param name="subTarget">The sub target for this spell card if applicable</param> /// <param name="cardEffect">The card effect to use</param> public void PlaySpell(BaseSpell spell, IDamageableEntity subTarget = null, CardEffect cardEffect = CardEffect.NONE) { if (subTarget != null && subTarget is BaseMinion) { if (((BaseMinion)subTarget).IsImmuneToSpellTarget || ((BaseMinion)subTarget).IsStealthed) { throw new InvalidOperationException("Can't target minion that is immune to spell targeting or is stealthed"); } } // Remove it from the player's hand this.hand.Remove(spell); // Remove mana from the player this.Mana -= spell.CurrentManaCost; // Fire spell casting event bool shouldAbort; GameEventManager.SpellCasting(spell, subTarget, out shouldAbort); // Check if we need to abort the spell or redirect if (!shouldAbort) { spell.Activate(subTarget, cardEffect); } // Fire spell casted event (if we need to) }
/// <summary> /// Apply damage from the attacker to the target /// </summary> /// <param name="attacker">The card doing the attacking</param> /// <param name="target">The object receiving the attack</param> /// <param name="isRetaliation">Whether or not the attack is a retaliation</param> public static void ApplyAttackDamage(IAttacker attacker, IDamageableEntity target, bool isRetaliation = false) { // If the attacker is a spell card or hero power, you can't retaliate // If the target is a hero, he can't retaliate if (target is BaseMinion) { var targetMinion = (BaseMinion)target; targetMinion.TakeDamage(attacker.GetCurrentAttackPower()); if (!isRetaliation && (attacker is BaseMinion || attacker is BaseWeapon)) { if (attacker is BaseWeapon) { var weapon = (BaseWeapon)attacker; ApplyAttackDamage(targetMinion, weapon.WeaponOwner, isRetaliation: true); } else { // Then we must be attacking a minion ApplyAttackDamage(targetMinion, (IDamageableEntity)attacker, isRetaliation: true); } } } else if (target is BasePlayer) { var targetPlayer = (BasePlayer)target; targetPlayer.TakeDamage(attacker.GetCurrentAttackPower()); } }
/// <summary> /// Plays a weapon /// </summary> /// <param name="weapon">The weapon to play</param> /// <param name="subTarget">The sub target for this weapon if applicable</param> public void PlayWeapon(BaseWeapon weapon, IDamageableEntity subTarget = null) { this.hand.Remove(weapon); this.Mana -= weapon.CurrentManaCost; weapon.WeaponOwner = this; this.Weapon = weapon; // Register deathrattle if applicable var deathrattleCard = weapon as IDeathrattler; if (deathrattleCard != null) { deathrattleCard.RegisterDeathrattle(); } // Call the card's battle cry var battlecryWeapon = weapon as IBattlecry; if (battlecryWeapon != null) { battlecryWeapon.Battlecry(subTarget); } // Fire card played event // TODO: Add weapon played event? }
/// <summary> /// First Effect: Draw 2 cards /// Second Effect: Restore 5 Health /// </summary> /// <param name="cardEffect">The card effect to use</param> /// <param name="target">The target of the heal</param> public void UseCardEffect(CardEffect cardEffect, IDamageableEntity target = null) { if (cardEffect == CardEffect.FIRST) { // Draw cards this.Owner.DrawCards(DRAW_COUNT); } else if (cardEffect == CardEffect.SECOND) { // Heal if (target == null) { throw new InvalidOperationException("Needs to have a target!"); } bool shouldAbort; GameEventManager.Healing(this.Owner, target, HEAL_AMOUNT, out shouldAbort); if (!shouldAbort) { target.TakeHealing(HEAL_AMOUNT); } } else { throw new InvalidOperationException("You must choose a card effect to play it!"); } }
public void Attack(IDamageableEntity target) { if (!this.CanAttack) { throw new InvalidOperationException("Player can't attack yet!"); } if (this.Weapon != null) { this.Weapon.Attack(target); } else if (this.TemporaryAttackBuff > 0) { // Fire attacking event bool shouldAbort; GameEventManager.Attacking(this, target, isRetaliation: false, shouldAbort: out shouldAbort); } else { throw new InvalidOperationException("Player has no attack damage to attack with!"); } this.attacksThisTurn++; if (!this.HasWindfury || (this.HasWindfury && this.attacksThisTurn >= 2)) { this.ApplyStatusEffects(PlayerStatusEffects.EXHAUSTED); } }
internal void OnDamagedEffect(IDamageableEntity target, int damageDealt) { if (target == this) { this.Owner.DrawCard(); } }
public void SetupDamage( IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId, float missileDistance, float missileSpeed, IDamageableEntity lockingTarget) { SetupDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); this.missileDistance = missileDistance; this.missileSpeed.Value = missileSpeed; if (missileDistance <= 0 && missileSpeed <= 0) { // Explode immediately when distance and speed is 0 Explode(); NetworkDestroy(destroyDelay); destroying = true; return; } LockingTarget = lockingTarget; launchTime = Time.unscaledTime; missileDuration = missileDistance / missileSpeed; }
private void TriggerEnter(GameObject other) { if (destroying) { return; } IDamageableEntity target = null; if (IsHitGroundOrWall(other) || FindTargetEntity(other, out target)) { if (explodeDistance <= 0f) { // If this is not going to explode, just apply damage to target ApplyDamageTo(target); } else { // Explode immediately when hit something Explode(); } NetworkDestroy(destroyDelay); destroying = true; } }
public static DamageEvent Damage(IDamageableEntity entityToDamage, DamageSource damageSource) { return(new DamageEvent() { Entity = entityToDamage, DamageSource = damageSource }); }
public void DoOrder(Order order) { if (IsDestroyed()) // you are dead... no orders for you :) { return; } switch (order.Type) { case OrderType.HELM: var setCourseOrder = (HelmOrder)order; if (setCourseOrder.AngleInDegrees != null) { SetCourse((float)setCourseOrder.AngleInDegrees); } if (setCourseOrder.ThrottlePercent != null) { SetThrottle((float)setCourseOrder.ThrottlePercent); } break; case OrderType.LOCK: var lockOrder = (LockOrder)order; target = lockOrder.Target; break; case OrderType.ALL_STOP: AllStop(); break; default: break; } }
public void Battlecry(IDamageableEntity subTarget) { if (this.Owner.Weapon != null) { this.TakeBuff(this.Owner.Weapon.CurrentAttackPower, 0); } }
protected virtual List <GameObject> SortObjectsInView(bool cycling = false) { List <GameObject> Sorted_List = m_CandidateTargets.OrderBy(go => GetSortWeight(go, cycling)).ToList(); List <GameObject> objectsInView = new List <GameObject>(); for (var i = 0; i < Sorted_List.Count(); ++i) { IDamageableEntity damageable = Sorted_List[i].GetComponent <IDamageableEntity>(); BaseGameEntity agent = Sorted_List[i].GetComponentInParent <BaseGameEntity>(); if ((agent == null && damageable == null) || (bool)(damageable != null && damageable.IsHideOrDead())) { continue; } Vector2 screenPosition = Camera.main.WorldToScreenPoint(Sorted_List[i].transform.position); // Entity is within the screen (no targeting offscreen) if (screenPosition.x > 0 && screenPosition.x < Screen.width && screenPosition.y > 0 && screenPosition.y < Screen.height && Sorted_List[i].activeInHierarchy) { // MAKE SURE ALL NON-COLLIDING ENTITIES ARE OFF OF THE DEFAULT LAYER PLEASE // If this does not work, change the layer for playercharactercontroller to Player or something LayerMask mask = 1 << LayerMask.NameToLayer("Default") | 1 << LayerMask.NameToLayer("Building"); bool didHit = Physics.Linecast(Controller.CacheGameplayCamera.transform.position, GetCenter(Sorted_List[i]), mask); if (!didHit) { objectsInView.Add(Sorted_List[i]); } } } Debug.Log(objectsInView.Count); return(objectsInView); }
public static void OnAttacking(IAttacker attacker, IDamageableEntity target, bool isRetaliation, out bool shouldAbort) { shouldAbort = false; if (_minionAttackingListeners.Any()) { // Triggered Effects get called first, then Secrets, then the game engine var sortedListeners = _minionAttackingListeners.Where(kvp => kvp.Item1.Type != CardType.ACTIVE_SECRET).OrderBy(kvp => kvp.Item1.TimePlayed).ToList(); var secrets = _minionAttackingListeners.Where(kvp => kvp.Item1.Type == CardType.ACTIVE_SECRET).OrderBy(kvp => kvp.Item1.TimePlayed).ToList(); sortedListeners.AddRange(secrets); foreach (var handler in sortedListeners.Select(kvp => kvp.Item2)) { handler(attacker, target, isRetaliation, out shouldAbort); } } if (!shouldAbort) { GameEngine.ApplyAttackDamage(attacker, target, isRetaliation); // Time to trigger deathrattles // If it was a weapon attacking, wait until after the weapon has taken durability hit if (!(attacker is BaseWeapon)) { GameEngine.TriggerDeathrattles(); } } }
public void Battlecry(IDamageableEntity subTarget) { if (subTarget != null && !GameEngine.GameState.CurrentPlayerPlayZone.Any(card => card != null && card.CurrentAttackPower >= BATTLECRY_POWER && card != this) && !GameEngine.GameState.WaitingPlayerPlayZone.Any(card => card != null && card.CurrentAttackPower >= BATTLECRY_POWER)) { throw new InvalidOperationException("No valid targets!"); } if (subTarget == null && (GameEngine.GameState.CurrentPlayerPlayZone.Any(card => card != null && card.CurrentAttackPower >= BATTLECRY_POWER && card != this) || GameEngine.GameState.WaitingPlayerPlayZone.Any(card => card != null && card.CurrentAttackPower >= BATTLECRY_POWER))) { throw new InvalidOperationException("There is a valid target, must select one!"); } if (subTarget != null && !(subTarget is BaseMinion)) { throw new InvalidOperationException("Must target minions!"); } var targetMinion = subTarget as BaseMinion; if (targetMinion != null) { if (targetMinion.CurrentAttackPower < BATTLECRY_POWER) { throw new InvalidOperationException( string.Format( "Invalid minion {0}! It does not have enough attack power! Needs to be at least {1}", targetMinion, BATTLECRY_POWER)); } targetMinion.Die(); } }
/// <summary> /// Heals a target /// </summary> /// <param name="target">The target to heal</param> /// <param name="healAmount">The amount to heal for</param> protected void HealTarget(IDamageableEntity target, int healAmount) { if (target == null) { return; } // Ok, we have to do some hacky stuff here. Heals don't get affected by spell power UNLESS the heal actually does // damage instead. Auchenai Soulpriest's current implementation can't handle this nuance right now. // So instead of going through the normal flow, change the "heal amount" based on whether or not the current player // has a non-silenced Auchenai Soulpriest. int actualHealAmount = healAmount; var playZone = GameEngine.GameState.CurrentPlayerPlayZone; if (playZone.Any(card => card is AuchenaiSoulpriest && !((BaseMinion)card).IsSilenced)) { actualHealAmount += this.BonusSpellPower; } bool shouldAbort; GameEventManager.Healing(this.Owner, target, actualHealAmount, out shouldAbort); if (!shouldAbort) { target.TakeHealing(actualHealAmount); } }
public void Battlecry(IDamageableEntity subTarget) { BaseWeapon weapon = GameEngine.GameState.CurrentPlayer.Weapon; if (weapon != null) { weapon.TakeBuff(BATTLECRY_BUFF_VALUE, BATTLECRY_BUFF_VALUE); } }
private void OnDamageDealt(IDamageableEntity target, int damageDealt) { var targetMinion = target as BaseMinion; if (targetMinion != null && GameEngine.GameState.CurrentPlayerPlayZone.Contains(targetMinion)) { this.Owner.Armor++; } }
public void Battlecry(IDamageableEntity subTarget) { var enemy = GameEngine.GameState.WaitingPlayer; if (enemy.Weapon != null) { enemy.Weapon.Die(); } }
public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE) { int totalSpellDamage = MAX_SPELL_POWER + this.BonusSpellPower; GameEngine.GameState.CurrentPlayer.TakeDamage(totalSpellDamage); GameEngine.GameState.WaitingPlayer.TakeDamage(totalSpellDamage); GameEngine.GameState.CurrentPlayerPlayZone.Where(card => card != null).ToList().ForEach(card => ((IDamageableEntity)card).TakeDamage(totalSpellDamage)); GameEngine.GameState.WaitingPlayerPlayZone.Where(card => card != null).ToList().ForEach(card => ((IDamageableEntity)card).TakeDamage(totalSpellDamage)); }
private void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { if (spell.Owner == this.Owner) { var fireball = HearthEntityFactory.CreateCard<Fireball> (); this.Owner.AddCardToHand (fireball); } shouldAbort = false; }
public virtual void ApplyDamageTo(IDamageableEntity target) { if (target == null) { return; } target.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId); }
/// <summary> /// Plays a card /// </summary> /// <param name="card">The card to play</param> /// <param name="subTarget">The sub target for this card, usually for targeting batlle cry spells</param> /// <param name="cardEffect">The card effect to use</param> /// <param name="gameboardPos">The position on the gameboard to place the card (if applicable). A value of -1 means play it in the next available slot</param> public void PlayCard(BaseCard card, IDamageableEntity subTarget, int gameboardPos = -1, CardEffect cardEffect = CardEffect.NONE) { // Is it even our turn to play? var gameState = GameEngine.GameState; if (gameState.CurrentPlayer != this) { throw new InvalidOperationException(string.Format("You can't play out of turn! It is currently {0}'s turn", gameState.CurrentPlayer)); } // Check if it exists in the player's hand BaseCard cardInHand = this.Hand.FirstOrDefault(c => c.Equals(card)); if (cardInHand == null) { throw new InvalidOperationException(string.Format("You can't play a card that's not in hand (or deck if force summoned from there)! {0}", card)); } // Check if we have enough mana to make the play if (this.Mana < cardInHand.CurrentManaCost) { throw new InvalidOperationException(string.Format("Not enough mana {0} to play that card {1}!", this.Mana, card.CurrentManaCost)); } var minionCard = cardInHand as BaseMinion; if (minionCard != null) { this.SummonMinion(minionCard, subTarget, gameboardPos, cardEffect, forceSummoned: false, cardSource: this.hand); } var spellCard = cardInHand as BaseSpell; if (spellCard != null) { this.PlaySpell(spellCard, subTarget, cardEffect); } var weaponCard = cardInHand as BaseWeapon; if (weaponCard != null) { this.PlayWeapon(weaponCard, subTarget); } // Register any triggered effects var triggeredEffectCard = cardInHand as ITriggeredEffectOwner; if (triggeredEffectCard != null) { triggeredEffectCard.RegisterEffect(); } // Trigger any deathrattles GameEngine.TriggerDeathrattles(); GameEngine.CheckForGameEnd(); }
public void Battlecry(IDamageableEntity subTarget) { if (subTarget is BasePlayer) { throw new InvalidOperationException("Can't buff players!"); } subTarget.TakeTemporaryBuff(BATTLECRY_POWER); }
public void OnTriggerEnter2D(Collider2D collision) { IDamageableEntity ent = collision.transform.GetComponent <IDamageableEntity>(); if (ent != null) { this.GiveDamage(ent, collision.transform); } }
/// <summary> /// Constructs an instance of DeathrattleHealTarget /// </summary> /// <param name="owner">The owner of the deathrattle</param> /// <param name="healTarget">The target to heal</param> /// <param name="healAmount">The amount to heal</param> public DeathrattleHealTarget(BaseCard owner, IDamageableEntity healTarget, int healAmount) { if (owner == null) throw new ArgumentNullException("owner"); if (healTarget == null) throw new ArgumentNullException("healTarget"); this.owner = owner; this.healTarget = healTarget; this.healAmount = healAmount; }
private void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { if (spell.Owner == this.Owner) { var fireball = HearthEntityFactory.CreateCard <Fireball> (); this.Owner.AddCardToHand(fireball); } shouldAbort = false; }
public void OnCollisionStay2D(Collision2D collision) { IDamageableEntity ent = collision.transform.GetComponent <IDamageableEntity>(); if (ent != null) { this.GiveDamage(ent, collision.transform); AudioManager.instance.PlaySound("SawHit"); } }
protected virtual void OnCollisionEnter2D(Collision2D other) { IDamageableEntity damageable = other.transform.GetComponent <IDamageableEntity>(); if (damageable != null) { this.Damage(damageable); this.Disappear(); } }
public void Battlecry(IDamageableEntity subTarget) { var targetPlayer = subTarget as BasePlayer; if (targetPlayer == null) { throw new InvalidOperationException("Target must be a player!"); } targetPlayer.Health = 15; }
} // End setConsoleSize() public static void UpdateDisplay(IDamageableEntity target, IDamageableEntity flagship, List <IGameEntity> ships, IConsole scanPanel, IConsole statusPanel, IConsole radarPanel, IConsole shipListPanel) { if (target != null) { ConsoleVisualizer.PrintShip((Ship)target, scanPanel, ConsoleColor.White); } ConsoleVisualizer.PrintShip((Ship)flagship, statusPanel, ConsoleColor.White); ConsoleVisualizer.DrawRadar(radarPanel, ships, flagship, 2000); ConsoleVisualizer.DrawShipList(shipListPanel, ships, flagship); }
public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE) { if (target == null) { throw new ArgumentNullException("Fireball must be cast with target in mind"); } // Deal damage to the target var damageToDeal = MAX_SPELL_POWER + this.BonusSpellPower; target.TakeDamage(damageToDeal); }
public override void Setup( IGameEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> damageAmounts, BaseSkill skill, short skillLevel, float missileDistance, float missileSpeed, IDamageableEntity lockingTarget) { base.Setup(attacker, weapon, damageAmounts, skill, skillLevel, missileDistance, missileSpeed, lockingTarget); //Initial configuration inipos = this.transform.position; collided = false; //Configuration bullet and effects if (ProjectileObject) { ProjectileObject.SetActive(true); } if (ImpactEffect && !instantiateImpact) { ImpactEffect.SetActive(false); iniImpactEffectPos = ImpactEffect.transform.localPosition; } if (disappearEffect && !instantiateDisappear) { disappearEffect.SetActive(false); } //Movement Vector3 targetPos = inipos + (this.transform.forward * missileDistance); if (lockingTarget != null && lockingTarget.CurrentHp > 0) { targetPos = lockingTarget.GetTransform().position; } float dist = Vector3.Distance(inipos, targetPos); float yOffset = -transform.forward.y; if (recalculateSpeed) { missileSpeed = LaunchSpeed(dist, yOffset, Physics.gravity.magnitude, angle * Mathf.Deg2Rad); } if (useAngle) { this.transform.eulerAngles = new Vector3(-angle, this.transform.eulerAngles.y, this.transform.eulerAngles.z); } bulletVelocity = this.transform.forward * missileSpeed; }
private void OnHealing(BasePlayer healer, IDamageableEntity target, int healAmount, out bool shouldAbort) { shouldAbort = false; if (healer == this.Owner) { shouldAbort = true; // Instead, do damage! target.TakeDamage(healAmount); } }
public MiteEnemyController(MiteEnemy e) : base(e) { this.enemy = e; this.enemyAnimator = e.GetComponentInChildren <Animator>(); this.transform = e.transform; this.rb = e.GetComponent <Rigidbody2D>(); this.patrolController = e.GetComponent <PatrolController>(); this.playerTransform = PlayerManager.instance.playerObject.transform; this.playerCharacter = PlayerManager.instance.playerCharacter; this.playerDamageable = this.playerTransform.GetComponent <IDamageableEntity>(); }
public virtual void Attack(IDamageableEntity target) { // Fire attacking event bool shouldAbort; GameEventManager.Attacking(this, target, isRetaliation: false, shouldAbort: out shouldAbort); if (!shouldAbort) { // Use up a durability charge this.TakeDamage(1); GameEngine.TriggerDeathrattles(); } }
public void Battlecry(IDamageableEntity subTarget) { var battleAxe = HearthEntityFactory.CreateCard<BattleAxe>(); // kill the old weapon if (this.Owner.Weapon != null) { this.Owner.Weapon.Die(); } this.Owner.Weapon = battleAxe; battleAxe.Owner = this.Owner; battleAxe.WeaponOwner = this.Owner; }
public void Battlecry(IDamageableEntity subTarget) { var targetMinion = subTarget as BaseMinion; var targetPlayer = subTarget as BasePlayer; if (targetMinion != null) { targetMinion.ApplyStatusEffects(MinionStatusEffects.FROZEN); } else if (targetPlayer != null) { targetPlayer.ApplyStatusEffects(PlayerStatusEffects.FROZEN); } }
public void Battlecry(IDamageableEntity subTarget) { var opponent = GameEngine.GameState.WaitingPlayer; if (opponent.Weapon != null) { if (opponent.Weapon is Gorehowl) { // HACK: this card can bypass gorehowl's override of TakeDamage ((Gorehowl)opponent.Weapon).TakeDamage(BATTLECRY_DAMAGE, forceUseBaseImplementation: true); } else { opponent.Weapon.TakeDamage(BATTLECRY_DAMAGE); } } }
public void Battlecry(IDamageableEntity subTarget) { var targetMinion = subTarget as BaseMinion; if (targetMinion == null) { throw new InvalidOperationException("Target needs to be a minion!"); } if (!GameEngine.GameState.WaitingPlayerPlayZone.Contains(targetMinion)) { throw new InvalidOperationException("Target must be an enemy"); } var attackToSubtract = targetMinion.CurrentAttackPower - 1; targetMinion.TakeBuff(-attackToSubtract, 0); }
public void UseCardEffect(CardEffect cardEffect, IDamageableEntity target = null) { if (cardEffect == CardEffect.FIRST) { this.TakeBuff(ATTACK_BUFF, 0); } else if (cardEffect == CardEffect.SECOND) { this.TakeBuff(0, HEALTH_BUFF); this.ApplyStatusEffects(MinionStatusEffects.TAUNT); } else { throw new InvalidOperationException("You must choose a card effect to play!"); } }
public void Battlecry(IDamageableEntity subTarget) { // Check to see if the enemy board has a minion with 2 or less attack if (GameEngine.GameState.WaitingPlayerPlayZone.Any( card => card != null && card.CurrentAttackPower <= BATTLECRY_POWER) && subTarget == null) { throw new InvalidOperationException("There is a valid target on the board so a target must be supplied!"); } // If there are no valid targets but a target was supplied if (!GameEngine.GameState.WaitingPlayerPlayZone.Any( card => card != null && card.CurrentAttackPower <= BATTLECRY_POWER) && subTarget != null) { throw new InvalidOperationException("There are no valid targets on the board!"); } if (subTarget != null) { if (!(subTarget is BaseMinion)) { throw new InvalidOperationException("Only minions can be targeted"); } var targetMinion = (BaseMinion) subTarget; if (targetMinion.CurrentAttackPower > BATTLECRY_POWER) { throw new InvalidOperationException(string.Format("{0}'s attack is too high!", targetMinion)); } var currentPlayZone = GameEngine.GameState.CurrentPlayerPlayZone; var playZoneCount = currentPlayZone.Count(card => card != null); if (playZoneCount == Constants.MAX_CARDS_ON_BOARD) { throw new InvalidOperationException("There is not enough room on the board!"); } GameEngine.GameState.Board.RemoveCard(targetMinion); currentPlayZone[playZoneCount] = targetMinion; targetMinion.Owner = this.Owner; } }
public void Battlecry(IDamageableEntity subTarget) { var playZone = GameEngine.GameState.CurrentPlayerPlayZone; int indexOfMage = playZone.FindIndex(card => card == this); if (indexOfMage - 1 >= 0) { var leftMinion = playZone[indexOfMage - 1] as BaseMinion; if (leftMinion != null) { leftMinion.BonusSpellPower += BATTLE_CRY_POWER; } } if (indexOfMage + 1 < Constants.MAX_CARDS_ON_BOARD) { var rightMinion = playZone [indexOfMage + 1] as BaseMinion; if (rightMinion != null) { rightMinion.BonusSpellPower += BATTLE_CRY_POWER; } } }
public void Battlecry(IDamageableEntity subTarget) { if (GameEngine.GameState.CurrentPlayerPlayZone.Any(card => (card != null && card != this)) && subTarget == null) { throw new InvalidOperationException("Must have a target if there are minions on the board!"); } if (GameEngine.GameState.CurrentPlayerPlayZone.All(card => card == null || card == this) && subTarget == null) { // No battlecry if there are no friendly minions on the board return; } var targetMinion = subTarget as BaseMinion; if (targetMinion == null || !GameEngine.GameState.CurrentPlayerPlayZone.Contains(targetMinion)) { throw new InvalidOperationException("Must target friendly minions!"); } GameEngine.GameState.Board.RemoveCard(targetMinion); this.Owner.AddCardToHand(targetMinion); }
public void Battlecry(IDamageableEntity subTarget) { var playZone = GameEngine.GameState.CurrentPlayerPlayZone; if (playZone.Any(card => card != null && card != this) && subTarget == null) { throw new InvalidOperationException("There are friendly minions on the board, you must target one!"); } if (playZone.All(card => card == null) && subTarget != null) { throw new InvalidOperationException("There are no other friendly minions on the board so you can't target something!"); } if (subTarget != null) { if (!(subTarget is BaseMinion)) { throw new InvalidOperationException("You must target a minion!"); } ((BaseMinion)subTarget).ApplyStatusEffects(MinionStatusEffects.DIVINE_SHIELD); } }
/// <summary> /// Heals a target /// </summary> /// <param name="target">The target to heal</param> /// <param name="healAmount">The amount to heal for</param> protected void HealTarget(IDamageableEntity target, int healAmount) { if (target == null) return; // Ok, we have to do some hacky stuff here. Heals don't get affected by spell power UNLESS the heal actually does // damage instead. Auchenai Soulpriest's current implementation can't handle this nuance right now. // So instead of going through the normal flow, change the "heal amount" based on whether or not the current player // has a non-silenced Auchenai Soulpriest. int actualHealAmount = healAmount; var playZone = GameEngine.GameState.CurrentPlayerPlayZone; if (playZone.Any(card => card is AuchenaiSoulpriest && !((BaseMinion)card).IsSilenced)) { actualHealAmount += this.BonusSpellPower; } bool shouldAbort; GameEventManager.Healing(this.Owner, target, actualHealAmount, out shouldAbort); if (!shouldAbort) { target.TakeHealing(actualHealAmount); } }
public override void Activate(IDamageableEntity target = null, CardEffect cardEffect = CardEffect.NONE) { throw new NotImplementedException(); }
/// <summary> /// Apply damage from the attacker to the target /// </summary> /// <param name="attacker">The card doing the attacking</param> /// <param name="target">The object receiving the attack</param> /// <param name="isRetaliation">Whether or not the attack is a retaliation</param> public static void ApplyAttackDamage(IAttacker attacker, IDamageableEntity target, bool isRetaliation = false) { // If the attacker is a spell card or hero power, you can't retaliate // If the target is a hero, he can't retaliate if (target is BaseMinion) { var targetMinion = (BaseMinion) target; targetMinion.TakeDamage(attacker.GetCurrentAttackPower()); if (!isRetaliation && (attacker is BaseMinion || attacker is BaseWeapon)) { if (attacker is BaseWeapon) { var weapon = (BaseWeapon) attacker; ApplyAttackDamage(targetMinion, weapon.WeaponOwner, isRetaliation: true); } else { // Then we must be attacking a minion ApplyAttackDamage(targetMinion, (IDamageableEntity)attacker, isRetaliation: true); } } } else if (target is BasePlayer) { var targetPlayer = (BasePlayer) target; targetPlayer.TakeDamage(attacker.GetCurrentAttackPower()); } }
public static void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { shouldAbort = false; if (!_spellCastingListeners.Any()) return; // Listeners for this are called in the order in which they were played on the board var sortedListeners = _spellCastingListeners.OrderBy(kvp => kvp.Item1.TimePlayed).ToList(); foreach (var handler in sortedListeners.Select(kvp => kvp.Item2)) { handler(spell, target, out shouldAbort); } }
public void Battlecry(IDamageableEntity subTarget) { var waitingPlayer = GameEngine.GameState.WaitingPlayer; waitingPlayer.AddManaCrystal(); }
public void Battlecry(IDamageableEntity subTarget) { GameEngine.GameState.CurrentPlayerPlayZone.ForEach(card => this.RemoveDivineShieldAndBuffBloodKnight((BaseMinion)card)); GameEngine.GameState.WaitingPlayerPlayZone.ForEach(card => this.RemoveDivineShieldAndBuffBloodKnight((BaseMinion)card)); }