예제 #1
0
        public CombatLogEntry Cast(IDice dice, Combatant attacker, Combatant defender)
        {
            var outcomes = Effects.Select(x => x.Execute(dice, attacker, defender)).ToList();

            var logEntry = new CombatLogEntry
            {
                Attacker = attacker,
                CombatEffect = new CombatOutcome
                {
                    Healing = outcomes.Aggregate(0, (healing, outcome) => healing + outcome.Healing),
                    Damage = outcomes.Aggregate(0, (damage, outcome) => damage + outcome.Damage),
                },
                Text = string.Format(
                    "{0} cast {1} on {2}.{3}{4}",
                    attacker.Name,
                    this.GetLeveledName(),
                    defender.Name,
                    Environment.NewLine,
                    string.Join(Environment.NewLine, outcomes.Select(x => x.Description)))
            };

            return logEntry;
        }
예제 #2
0
        public CombatLogEntry Cast(IDice dice, Combatant caster)
        {
            var outcomes = Effects.Select(x => x.Execute(dice, caster)).ToList();

            var logEntry = new CombatLogEntry
            {
                Attacker = caster,
                CombatEffect = new CombatOutcome
                {
                    Healing = outcomes.Aggregate(0, (healing, outcome) => healing + outcome.Healing),
                    Damage = outcomes.Aggregate(0, (damage, outcome) => damage + outcome.Damage),
                },
                Text = string.Format(
                    "{0} cast {1}.{2}{3}",
                    caster.Name,
                    this.GetLeveledName(),
                    Environment.NewLine,
                    string.Join(Environment.NewLine, outcomes.Select(x => x.Description)))
            };

            caster.CurrentEnergy = Math.Max(0, caster.CurrentEnergy - EnergyCost);

            return logEntry;
        }
예제 #3
0
        public CombatLogEntry Use(IDice dice, Combatant combatant)
        {
            var outcomes = Effects.Select(x => x.Execute(dice, combatant)).ToList();

            var logEntry = new CombatLogEntry
            {
                Attacker = combatant,
                CombatEffect = new CombatOutcome
                {
                    Healing = outcomes.Aggregate(0, (healing, outcome) => healing + outcome.Healing),
                    Damage = outcomes.Aggregate(0, (damage, outcome) => damage + outcome.Damage),
                },
                Text = string.Format(
                    "{0} used {1}.{2}{3}",
                    combatant.Name,
                    this.GetLeveledName(),
                    Environment.NewLine,
                    string.Join(Environment.NewLine, outcomes.Select(x => x.Description)))
            };

            combatant.RemoveItemFromInventory(this);

            return logEntry;
        }