/// <summary> /// Sends attack message with added target for computation, then delivers results /// as messages to the player. /// </summary> /// <param name="target">The target of the attack (in this case, the hero)</param> public void Attack(ICombatant target) { var attackPacket = AttackDeliveryPacket; attackPacket.Target = target; var attackResult = CombatManager.DeliverAttack(attackPacket); if (attackResult.Critical) { DungeonGameEngine.ProcessMessageQueue(false, "The " + EntityName + " got a lucky shot inflicting extra damage."); } else if (attackResult.Fumble) { DungeonGameEngine.ProcessMessageQueue(false, "You are slightly amused to see the " + EntityName + " strike at your shadow."); } else if (attackResult.Hit) { DungeonGameEngine.ProcessMessageQueue(false, "The " + EntityName + " hit you."); } else { DungeonGameEngine.ProcessMessageQueue(false, "The " + EntityName + " missed you."); } }
public void Attack(ICombatant target) { // Construct attack message CombatManager.AttackDelivery attackMessage = new CombatManager.AttackDelivery(); var currentWeapon = Inventory.CurrentWeapon; if (currentWeapon != null) { attackMessage.CombatType = currentWeapon.CombatType; attackMessage.DamageDice = currentWeapon.DamageDice; } else { // http://www.dandwiki.com/wiki/SRD:Unarmed_Strike attackMessage.CombatType = CombatManager.CombatType.Melee; attackMessage.DamageDice = new KeyValuePair <CombatManager.DamageType, CombatManager.DieType>[] { new KeyValuePair <CombatManager.DamageType, CombatManager.DieType> (CombatManager.DamageType.Bludgeoning, CombatManager.DieType.D3) }; } attackMessage.CombatType = CombatManager.CombatType.Melee; attackMessage.Attacker = this; attackMessage.Target = target; attackMessage.ToHitModifier = 0; attackMessage.DamageModifiers = new Dictionary <CombatManager.DamageType, int>(0); // Set Capacity to 1 // Send the attack CombatManager.AttackResult attackResult = CombatManager.DeliverAttack(attackMessage); // Process the attack results if (attackResult.Critical) { DungeonGameEngine.ProcessMessageQueue(false, "You struck a Critical blow to the " + target.EntityName + "."); } else if (attackResult.Fumble) { // Not all fumbles have to cause trouble if (Utility.Rand.Next(4) == 0) { // But this one did, so what happened var fumbleAction = Utility.Rand.Next(100); if (fumbleAction < 70) { // Either you hit yourself DungeonGameEngine.ProcessMessageQueue(false, "You swing wildly and miss, hitting yourself in the head in the process."); if (Utility.Rand.Next(2) == 0) { InventoryEffectManager.HeroConfused = true; } else { InventoryEffectManager.KnockHeroUnconcious(); } } else { // Or you broke your weapon if (currentWeapon != null) { DungeonGameEngine.ProcessMessageQueue(false, currentWeapon.Break()); } } } } else if (attackResult.Hit) { DungeonGameEngine.ProcessMessageQueue(false, "You hit the " + target.EntityName + "."); } else { DungeonGameEngine.ProcessMessageQueue(false, "You missed the " + target.EntityName + "."); } } // ICombatant