internal void BroadcastSkillEffect_LogUpdate(PlayerIndicator player, List <CardModel> targets, CardSkill skill) { #if UNITY_EDITOR || DEVELOPMENT_BUILD if (skill == null) { throw new ArgumentNullException("skill", "Skill argument cannot be null in this context."); } #endif if (targets == null || targets.Count == 0) { return; } // a bit of a hack CardModel dummy = new CardModel(0, PlayerIndicator.Bot); skill.Effect(dummy); // see what this spell does to a dummy bool heals = dummy.CurrentStrength > dummy.DefaultStrength; // true - heals, false - damages int howPowerful = Math.Abs(dummy.DefaultStrength - dummy.CurrentStrength); string lastExecutedCommand = $"<b>{CurrentPlayer.ToString()} Player's</b> card "; lastExecutedCommand += targets.Count == 1 ? $"{HealsOrDamages()} <color=yellow>{DB[targets[0].CardId].Title}</color> for {howPowerful} point(s)" : $"{HealsOrDamages()} following cards: " + string.Join(", ", targets) // many targets + $" for total of {howPowerful * targets.Count} point(s)"; string HealsOrDamages() => heals ? "<color=green>heals</color>" : "<color=red>damages</color>"; GameLogicLogUpdateEventHandler?.Invoke( this, new GameLogicLogUpdateEventArgs( player, GetCurrentStatus(), lastExecutedCommand, TopTotalStrength, BotTotalStrength)); }
public void ApplySkillForUI(List <SkillTargetData> targets, CardSkill skill) { #if UNITY_EDITOR || DEVELOPMENT_BUILD if (skill.ExecutionTime == SkillExecutionTime.OnDeployAutomatic) { throw new ArgumentException("skill", "this method should be used only for manually resolved skills"); } #endif var models = new List <CardModel>(targets.Count); foreach (SkillTargetData target in targets) { // parse target to model CardModel model = _lines[(int)target.Line][target.SlotNumber]; models.Add(model); skill.Effect(model); // apply the skill } // it's important to evaluate strengths before RemoveDeadOnes is called // as we want our data match the upper logic's data // UI removes its elements later on List <List <int> > cardStrengths = GetCardStrengths(); // remove dead ones RemoveDeadOnes(); // inform status panel BroadcastSkillEffect_LogUpdate(CurrentPlayer, models, skill); // inform upper logic about new strengths BroadcastUpdateStrength_StatusUpdate(cardStrengths); }
internal void ApplySkillEffectForAISingleTarget(CardSkill skill, LineIndicator targetLine, int slotNumber) { CardModel card = _lines[(int)targetLine][slotNumber]; skill.Effect(card); BroadcastSkillEffect_LogUpdate(CurrentPlayer, new List <CardModel>(1) { card }, skill); }
internal void ApplySkillEffectForAI(CardSkill skill, List <SkillTargetData> targets) { var models = new List <CardModel>(targets.Count); foreach (SkillTargetData target in targets) { CardModel model = _lines[(int)target.Line][target.SlotNumber]; models.Add(model); skill.Effect(model); } BroadcastSkillEffect_LogUpdate(CurrentPlayer, models, skill); }
void ApplySkillEffectIfAny(CardModel card, LineIndicator deployLine, int slotNumber) { CardSkill skill = DB[card.CardId].Skill; if (skill != null) { var targets = new List <CardModel>(); foreach (SkillTarget target in skill.Targets) { targets.AddRange(ParseOnDeployAutomaticSkillTarget(deployLine, slotNumber, target)); } foreach (CardModel target in targets) { skill.Effect(target); } BroadcastSkillEffect_LogUpdate(CurrentPlayer, targets, skill); } }