Ejemplo n.º 1
0
        /// <summary>
        /// 指定されたGuidに対応するSpellTimerの後方参照で置換を行う
        /// 置換文字列は "$C" + 条件の出現順(1~) + "-" + 後方参照の番号
        /// 例: $C1-2(一つ目の条件となるタイマーの二つ目のグループに置換)
        /// </summary>
        /// <param name="message">元の文字列</param>
        /// <param name="timers">置換候補のタイマー</param>
        /// <param name="baseIndex">条件の出現順の開始番号</param>
        /// <returns>候補となったタイマーの個数</returns>
        private static int ReplaceMessageWithSpell(
            StringBuilder message,
            Guid[] timers,
            int baseIndex)
        {
            int count = 0;

            for (int i = 0; i < timers.Length; i++)
            {
                var spell = SpellTimerTable.GetSpellTimerByGuid(timers[i]);
                if (spell != null)
                {
                    count++;

                    if (spell.RegexEnabled && spell.Regex != null && spell.MatchedLog != string.Empty)
                    {
                        foreach (Match match in spell.Regex.Matches(spell.MatchedLog))
                        {
                            foreach (var number in spell.Regex.GetGroupNumbers())
                            {
                                message.Replace(String.Format("$C{0}-{1}", (baseIndex + i), number), match.Groups[number].Value);
                            }
                        }
                    }
                }
            }

            return(count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 指定された全てのTimerが条件を満たしているか確認する
        /// </summary>
        /// <param name="timersMustRunning">稼働中であることが求められているTimerの配列</param>
        /// <param name="timersMustStopping">停止中であることが求められているTimerの配列</param>
        /// <returns>全てのTimerが条件を満たしていればtrue</returns>
        private static bool CheckConditions(
            Guid[] timersMustRunning,
            Guid[] timersMustStopping)
        {
            if (timersMustRunning.Length == 0 && timersMustStopping.Length == 0)
            {
                return(true);
            }

            // 動作中か確認する
            var condition = true;

            foreach (var guid in timersMustRunning)
            {
                var spell = SpellTimerTable.GetSpellTimerByGuid(guid);
                if (spell != null)
                {
                    condition = condition & IsRunning(spell);
                }

                var telop = OnePointTelopTable.Default.GetOnePointTelopByGuid(guid);
                if (telop != null)
                {
                    condition = condition & IsRunning(telop);
                }
            }

            // 停止中か確認する(稼働中でなければ停止中として扱う)
            foreach (var guid in timersMustStopping)
            {
                var spell = SpellTimerTable.GetSpellTimerByGuid(guid);
                if (spell != null)
                {
                    condition = condition & !IsRunning(spell);
                }

                var telop = OnePointTelopTable.Default.GetOnePointTelopByGuid(guid);
                if (telop != null)
                {
                    condition = condition & !IsRunning(telop);
                }
            }

            return(condition);
        }