private static void LogRuleDetails(CardRule rule, bool incombat, AstrologianCard heldcard) { Logger.WriteInfo(@"========================================Card Rule========================================"); if (rule == null) { Logger.WriteInfo("\t" + @"CardRule is null. Nothing to output."); } else { Logger.WriteInfo("\t" + $@"LogicType: {rule.LogicType}" + "\t" + $@"PlayType: {rule.PlayType}" + "\t" + $@"Card: {rule.Card}" + "\t" + $@"Priority: {rule.CardPriority}"); if (rule.Conditions != null) { Logger.WriteInfo("\t" + @"Conditions:"); if (rule.Conditions.InCombat != null) { Logger.WriteInfo("\t\t" + $@"InCombat {rule.Conditions.InCombat}"); } if (rule.Conditions.HasHeldCard != null) { Logger.WriteInfo("\t\t" + $@"HasHeldCard: {string.Join(",", rule.Conditions.HasHeldCard.Select(r => r.ToString()))}"); } if (rule.Conditions.DoesntHaveHeldCard != null) { Logger.WriteInfo("\t\t" + $@"DoesntHaveHeldCard: {string.Join(",", rule.Conditions.DoesntHaveHeldCard.Select(r => r.ToString()))}"); } if (rule.Conditions.JobsNotInParty != null) { Logger.WriteInfo("\t\t" + $@"JobsNotInParty: {string.Join(",", rule.Conditions.JobsNotInParty.Select(r => r.ToString()))}"); } if (rule.Conditions.RolesNotInParty != null) { Logger.WriteInfo("\t\t" + $@"RolesNotInParty: {string.Join(",", rule.Conditions.RolesNotInParty.Select(r => r.ToString()))}"); } } Logger.WriteInfo("\t" + $@"Action: {rule.Action}" + "\t" + $@"Target: {rule.Target}"); if (rule.TargetConditions != null) { Logger.WriteInfo("\tTargetConditions:"); if (rule.TargetConditions.HasTarget != null) { Logger.WriteInfo("\t\t" + $@"HasTarget {rule.TargetConditions.HasTarget}"); } if (rule.TargetConditions.HpLessThan != null) { Logger.WriteInfo("\t\t" + $@"HpLessThan {rule.TargetConditions.HpLessThan}"); } if (rule.TargetConditions.MpLessThan != null) { Logger.WriteInfo("\t\t" + $@"MpLessThan {rule.TargetConditions.MpLessThan}"); } if (rule.TargetConditions.TpLessThan != null) { Logger.WriteInfo("\t\t" + $@"TpLessThan {rule.TargetConditions.TpLessThan}"); } if (rule.TargetConditions.IsRole != null) { Logger.WriteInfo("\t\t" + $@"IsRole {string.Join(",", rule.TargetConditions.IsRole.Select(r => r.ToString()))}"); } if (rule.TargetConditions.JobOrder != null) { Logger.WriteInfo("\t\t" + $@"JobOrder {string.Join(",", rule.TargetConditions.JobOrder.Select(r => r.ToString()))}"); } if (rule.TargetConditions.IsJob != null) { Logger.WriteInfo("\t\t" + $@"IsJob {string.Join(",", rule.TargetConditions.IsJob.Select(r => r.ToString()))}"); } if (rule.TargetConditions.Choice != null) { Logger.WriteInfo("\t\t" + $@"Choice {rule.TargetConditions.Choice}"); } if (rule.TargetConditions.PlayerName != null) { Logger.WriteInfo("\t\t" + $@"PlayerName {rule.TargetConditions.PlayerName}"); } if (rule.TargetConditions.WithAlliesNearbyMoreThan != null) { Logger.WriteInfo("\t\t" + $@"WithAlliesNearbyMoreThan {rule.TargetConditions.WithAlliesNearbyMoreThan}"); } } Logger.WriteInfo("\tCurrent Information"); Logger.WriteInfo("\t\t" + $@"InCombat: {incombat}" + "\t" + $@"Held Card: {heldcard}"); Logger.WriteInfo("\t\t" + $@"CanRedraw: {CanRedraw}"); } Logger.WriteInfo(@"========================================Card Rule========================================"); }
private static void LogRuleProcessed(CardRule rule, bool incombat, AstrologianCard heldcard) { if (rule == null) { return; } LastCardActionDateTime = DateTime.Now; LastCardAction.LastActionDateTime = DateTime.Now; var targetToPrint = ""; if (rule.Target == CardTarget.Me) { targetToPrint = "Me"; } if (rule.Target == CardTarget.PartyMember) { targetToPrint = "a Party Member"; } if (rule.TargetConditions?.PlayerName != null) { targetToPrint = targetToPrint + $" named {rule.TargetConditions?.PlayerName}"; } var relevantConditions = ""; var relevantTargetConditions = ""; switch (rule.Action) { case CardAction.Play: if (rule.LogicType == CardLogicType.Pvp) { LastCardAction.LastAction = Spells.PvpPlayDrawn; } else { switch (rule.PlayType) { case CardPlayType.Held: LastCardAction.LastAction = Spells.PlaySpread; break; case CardPlayType.Drawn: LastCardAction.LastAction = Spells.PlayDrawn; break; } } Logger.WriteInfo("\t" + $@"We're Playing the {rule.PlayType} card {rule.Card} on {targetToPrint}"); break; case CardAction.MinorArcana: LastCardAction.LastAction = Spells.MinorArcana; Logger.WriteInfo("\t" + $@"We're using Minor Arcana on the card {rule.Card}."); break; case CardAction.Redraw: LastCardAction.LastAction = Spells.Redraw; LastCardAction.CardBeforeRedrawn = rule.Card; Logger.WriteInfo("\t" + $@"We're Redrawing the card {rule.Card}."); break; case CardAction.Undraw: LastCardAction.LastAction = Spells.Undraw; Logger.WriteInfo("\t" + $@"We're Undrawing the card {rule.Card}."); break; } if (!BaseSettings.Instance.DebugPlayerCasting) { return; } Logger.WriteInfo($"Drawn Card is {DrawnCard()} Held Card is {HeldCard()}"); Logger.WriteInfo("[CardRules]\t" + $@"LogicType: {rule.LogicType}" + "\t" + $@"PlayType: {rule.PlayType}" + "\t" + $@"Card: {rule.Card}" + "\t" + $@"Priority: {rule.CardPriority}"); if (rule.Conditions != null) { if (rule.Conditions.InCombat != null) { relevantConditions = relevantConditions + $"InCombat ({rule.Conditions.InCombat}) "; } if (rule.Conditions.HasHeldCard.Count > 0) { relevantConditions = relevantConditions + $@"HasHeldCard: ({string.Join(",",rule.Conditions.HasHeldCard.Select(r => r.ToString()))}) "; } if (rule.Conditions.DoesntHaveHeldCard.Count > 0) { relevantConditions = relevantConditions + $@"DoesntHaveHeldCard: ({string.Join(",",rule.Conditions.DoesntHaveHeldCard.Select(r => r.ToString()))}) "; } if (rule.Conditions.JobsNotInParty.Count > 0) { relevantConditions = relevantConditions + $@"JobsNotInParty: ({string.Join(",", rule.Conditions.JobsNotInParty.Select(r => r.ToString()))}) "; } if (rule.Conditions.RolesNotInParty.Count > 0) { relevantConditions = relevantConditions + $@"RolesNotInParty: ({string.Join(",", rule.Conditions.RolesNotInParty.Select(r => r.ToString()))}) "; } if (relevantConditions != "") { Logger.WriteInfo("[CardRules]\t" + $"Relevant Conditions: {relevantConditions}"); } } if (rule.TargetConditions == null) { return; } if (rule.TargetConditions.HasTarget != null) { relevantTargetConditions = relevantTargetConditions + $@"HasTarget ({rule.TargetConditions.HasTarget}) "; } if (rule.TargetConditions.HpLessThan != null && rule.TargetConditions.HpLessThan > 1 && rule.TargetConditions.HpLessThan < 100) { relevantTargetConditions = relevantTargetConditions + $@"HpLessThan ({rule.TargetConditions.HpLessThan}) "; } if (rule.TargetConditions.MpLessThan != null && rule.TargetConditions.MpLessThan > 1 && rule.TargetConditions.MpLessThan < 100) { relevantTargetConditions = relevantTargetConditions + $@"MpLessThan ({rule.TargetConditions.MpLessThan}) "; } if (rule.TargetConditions.TpLessThan != null && rule.TargetConditions.TpLessThan > 1 && rule.TargetConditions.TpLessThan < 100) { relevantTargetConditions = relevantTargetConditions + $@"TpLessThan ({rule.TargetConditions.TpLessThan}) "; } if (rule.TargetConditions.IsRole.Count > 0) { relevantTargetConditions = relevantTargetConditions + $@"IsRole ({string.Join(",", rule.TargetConditions.IsRole.Select(r => r.ToString()))}) "; } if (rule.TargetConditions.JobOrder.Count > 0) { relevantTargetConditions = relevantTargetConditions + $@"JobOrder ({string.Join(",",rule.TargetConditions.JobOrder.Select(r => r.ToString()))}) "; } if (rule.TargetConditions.IsJob.Count > 0) { relevantTargetConditions = relevantTargetConditions + $@"IsJob ({string.Join(",",rule.TargetConditions.IsJob.Select(r => r.ToString()))}) "; } //if (rule.TargetConditions.Choice != null) relevantTargetConditions = relevantTargetConditions + $@"Choice ({rule.TargetConditions.Choice}) "; if (rule.TargetConditions.PlayerName != null) { relevantTargetConditions = relevantTargetConditions + $@"PlayerName ({rule.TargetConditions.PlayerName}) "; } if (rule.TargetConditions.WithAlliesNearbyMoreThan != null && rule.TargetConditions.WithAlliesNearbyMoreThan > 0) { relevantTargetConditions = relevantTargetConditions + $@"WithAlliesNearbyMoreThan ({rule.TargetConditions.WithAlliesNearbyMoreThan}) "; } if (relevantTargetConditions != "") { Logger.WriteInfo("[CardRules]\t" + $"Relevant Target Conditions: {relevantTargetConditions}"); } }
private static async Task <bool> ProcessCardLogic(CardLogicType logictype, CardPlayType playtype, AstrologianCard card) { if (AstrologianSettings.Instance.CardRules == null) { return(false); } //if (TimeSinceTheLastCardAction < LastCardThreshold) return false; if (!LastCardAction.CanCastNewAction) { return(false); } var ruleincombat = Core.Me.InCombat; var cardRulesToProcess = AstrologianSettings.Instance.CardRules.Where(r => r.Card == card && r.LogicType == logictype && r.PlayType == playtype).OrderBy(r => r.CardPriority); return(await ProcessCardRule(cardRulesToProcess, ruleincombat, playtype, logictype)); }