public HumanPerson([NotNull] IPersonScheme scheme, [NotNull] ITacticalActScheme defaultActScheme, [NotNull] IEvolutionData evolutionData, [NotNull] ISurvivalRandomSource survivalRandomSource) { _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme)); Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); EvolutionData = evolutionData ?? throw new ArgumentNullException(nameof(evolutionData)); _survivalRandomSource = survivalRandomSource ?? throw new ArgumentNullException(nameof(survivalRandomSource)); Name = scheme.Sid; Effects = new EffectCollection(); Effects.Added += Effects_CollectionChanged; Effects.Removed += Effects_CollectionChanged; Effects.Changed += Effects_CollectionChanged; EquipmentCarrier = new EquipmentCarrier(Scheme.Slots); EquipmentCarrier.EquipmentChanged += EquipmentCarrier_EquipmentChanged; TacticalActCarrier = new TacticalActCarrier(); EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp; CombatStats = new CombatStats(); ClearCalculatedStats(); CalcCombatStats(); TacticalActCarrier.Acts = CalcActs(EquipmentCarrier); Survival = new HumanSurvivalData(scheme, survivalRandomSource); Survival.StatCrossKeyValue += Survival_StatCrossKeyValue; }
public MonsterPerson([NotNull] IMonsterScheme scheme) { Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); Hp = scheme.Hp; TacticalActCarrier = new TacticalActCarrier { Acts = new ITacticalAct[] { new MonsterTacticalAct(scheme.PrimaryAct) } }; var defenses = scheme.Defense?.Defenses? .Select(x => new PersonDefenceItem(x.Type, x.Level)) .ToArray(); CombatStats = new CombatStats { DefenceStats = new PersonDefenceStats( defenses ?? new PersonDefenceItem[0], new PersonArmorItem[0]) }; Survival = new MonsterSurvivalData(scheme); Effects = new EffectCollection(); }
private static void CalcSurvivalHazardOnTacticalAct(EffectCollection effects, ref int toHitModifierValue, ref int efficientModifierValue) { var greaterSurvivalEffect = effects.Items.OfType <SurvivalStatHazardEffect>() .OrderByDescending(x => x.Level).FirstOrDefault(); if (greaterSurvivalEffect == null) { return; } var effecientDebuffRule = greaterSurvivalEffect.Rules .FirstOrDefault(x => x.RollType == RollEffectType.Efficient); var toHitDebuffRule = greaterSurvivalEffect.Rules .FirstOrDefault(x => x.RollType == RollEffectType.ToHit); if (effecientDebuffRule != null) { efficientModifierValue += -1; } if (toHitDebuffRule != null) { toHitModifierValue += -1; } }
private static ITacticalAct[] CalcActs(ITacticalActScheme defaultActScheme, IEnumerable <Equipment> equipments, EffectCollection effects, IEnumerable <IPerk> perks) { if (equipments == null) { throw new ArgumentNullException(nameof(equipments)); } var actList = new List <ITacticalAct>(); var defaultAct = CreateTacticalAct(defaultActScheme, equipment: null, effects: effects, perks: perks); actList.Insert(0, defaultAct); foreach (var equipment in equipments) { if (equipment == null) { continue; } foreach (var actScheme in equipment.Acts) { var act = CreateTacticalAct(actScheme, equipment, effects, perks); actList.Insert(0, act); } } return(actList.ToArray()); }
public MonsterPerson(MonsterScheme scheme) { Scheme = scheme; Hp = scheme.Hp; TacticalActCarrier = new TacticalActCarrier { Acts = new ITacticalAct[] { new MonsterTacticalAct(scheme.PrimaryAct, 1) } }; Effects = new EffectCollection(); }
private static ITacticalAct CreateTacticalAct([NotNull] ITacticalActScheme scheme, [NotNull] Equipment equipment, [NotNull] EffectCollection effects, [NotNull, ItemNotNull] IEnumerable <IPerk> perks) { var toHitModifierValue = 0; var efficientModifierValue = 0; var efficientRollUnmodified = scheme.Stats.Efficient; CalcSurvivalHazardOnTacticalAct(effects, ref toHitModifierValue, ref efficientModifierValue); CalcPerkBonusesOnTacticalAct(perks, equipment, ref toHitModifierValue, ref efficientModifierValue); var toHitRoll = CreateTacticalActRoll(6, 1, toHitModifierValue); var efficientRoll = CreateTacticalActRoll(efficientRollUnmodified.Dice, efficientRollUnmodified.Count, efficientModifierValue); return(new TacticalAct(scheme, efficientRoll, toHitRoll, equipment)); }
private ITacticalAct CreateTacticalAct(ITacticalActScheme scheme, EffectCollection effects, Equipment equipment) { var greaterSurvivalEffect = effects.Items.OfType <SurvivalStatHazardEffect>() .OrderByDescending(x => x.Level).FirstOrDefault(); if (greaterSurvivalEffect == null) { return(new TacticalAct(scheme, scheme.Stats.Efficient, new Roll(6, 1), equipment)); } else { var effecientBuffRule = greaterSurvivalEffect.Rules .FirstOrDefault(x => x.RollType == RollEffectType.Efficient); var toHitBuffRule = greaterSurvivalEffect.Rules .FirstOrDefault(x => x.RollType == RollEffectType.ToHit); var efficientRoll = scheme.Stats.Efficient; if (effecientBuffRule != null) { var modifiers = new RollModifiers(-1); efficientRoll = new Roll(efficientRoll.Dice, efficientRoll.Count, modifiers); } Roll toHitRoll; if (toHitBuffRule == null) { toHitRoll = new Roll(6, 1); } else { var modifiers = new RollModifiers(-1); toHitRoll = new Roll(6, 1, modifiers); } return(new TacticalAct(scheme, efficientRoll, toHitRoll, equipment)); } }
public HumanPerson(PersonScheme scheme, TacticalActScheme defaultActScheme, IEvolutionData evolutionData) { Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); _defaultActScheme = defaultActScheme ?? throw new ArgumentNullException(nameof(defaultActScheme)); Name = scheme.Sid; Effects = new EffectCollection(); Effects.Added += Effects_CollectionChanged; Effects.Removed += Effects_CollectionChanged; Effects.Changed += Effects_CollectionChanged; EquipmentCarrier = new EquipmentCarrier(Scheme.Slots); EquipmentCarrier.EquipmentChanged += EquipmentCarrier_EquipmentChanged; TacticalActCarrier = new TacticalActCarrier(); EvolutionData = evolutionData; if (EvolutionData != null) { EvolutionData.PerkLeveledUp += EvolutionData_PerkLeveledUp; } CombatStats = new CombatStats(); ClearCombatStats((CombatStats)CombatStats); if (EvolutionData != null) { CalcCombatStats(CombatStats, EvolutionData, Effects); } TacticalActCarrier.Acts = CalcActs(EquipmentCarrier.Equipments, CombatStats); Survival = new SurvivalData(); Survival.StatCrossKeyValue += Survival_StatCrossKeyValue; }
private static void CalcCombatStats(ICombatStats combatStats, IEvolutionData evolutionData, EffectCollection effects) { var bonusDict = new Dictionary <CombatStatType, float>(); var archievedPerks = evolutionData.Perks.Where(x => x.CurrentLevel != null).ToArray(); foreach (var archievedPerk in archievedPerks) { var currentLevel = archievedPerk.CurrentLevel; var currentLevelScheme = archievedPerk.Scheme.Levels[currentLevel.Primary]; if (currentLevelScheme.Rules == null) { continue; } for (var i = 0; i <= currentLevel.Sub; i++) { foreach (var rule in currentLevelScheme.Rules) { var ruleType = rule.Type; switch (ruleType) { case PersonRuleType.Melee: AddStatToDict(bonusDict, CombatStatType.Melee, PersonRuleLevel.Lesser, PersonRuleDirection.Positive); break; case PersonRuleType.Ballistic: AddStatToDict(bonusDict, CombatStatType.Ballistic, PersonRuleLevel.Lesser, PersonRuleDirection.Positive); break; } } } } foreach (var effect in effects.Items) { foreach (var rule in effect.Rules) { AddStatToDict(bonusDict, rule.StatType, rule.Level, PersonRuleDirection.Negative); } } foreach (var bonusItem in bonusDict) { var stat = combatStats.Stats.SingleOrDefault(x => x.Stat == bonusItem.Key); if (stat != null) { stat.Value += stat.Value * bonusItem.Value; if (stat.Value <= 1) { stat.Value = 1; } } } foreach (var statItem in combatStats.Stats) { statItem.Value = (float)Math.Round(statItem.Value, 1); } }