Ejemplo n.º 1
0
        public override WrappedCard AskForCard(string reason, string pattern, string prompt, object data)
        {
            UseCard card = Engine.GetCardUsage(reason);

            if (card != null)
            {
                return(card.OnResponding(this, self, pattern, prompt, data).Card);
            }

            SkillEvent skill = Engine.GetSkillEvent(reason);

            if (skill != null)
            {
                return(skill.OnResponding(this, self, pattern, prompt, data).Card);
            }

            return(base.AskForCard(reason, pattern, prompt, data));
        }
Ejemplo n.º 2
0
        public override CardUseStruct AskForUseCard(string pattern, string prompt, FunctionCard.HandlingMethod method)
        {
            const string rx_pattern = @"@?@?([_A-Za-z]+)(\d+)?!?";

            if (!string.IsNullOrEmpty(pattern) && pattern.StartsWith("@"))
            {
                Match result = Regex.Match(pattern, rx_pattern);
                if (result.Length > 0)
                {
                    string  skill_name = result.Groups[1].ToString();
                    UseCard card       = Engine.GetCardUsage(skill_name);
                    if (card != null)
                    {
                        CardUseStruct use = card.OnResponding(this, self, pattern, prompt, method);
                        return(use);
                    }

                    SkillEvent skill = Engine.GetSkillEvent(skill_name);
                    if (skill != null)
                    {
                        CardUseStruct use = skill.OnResponding(this, self, pattern, prompt, method);
                        return(use);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(room.GetRoomState().GetCurrentResponseSkill()))
                {
                    string  skill_name = room.GetRoomState().GetCurrentResponseSkill();
                    UseCard card       = Engine.GetCardUsage(skill_name);
                    if (card != null)
                    {
                        CardUseStruct use = card.OnResponding(this, self, pattern, prompt, method);
                        return(use);
                    }

                    SkillEvent skill = Engine.GetSkillEvent(skill_name);
                    if (skill != null)
                    {
                        CardUseStruct use = skill.OnResponding(this, self, pattern, prompt, method);
                        return(use);
                    }
                }

                foreach (string key in prompt_keys.Keys)
                {
                    if (prompt.StartsWith(key))
                    {
                        string  skill_name = prompt_keys[key];
                        UseCard card       = Engine.GetCardUsage(skill_name);
                        if (card != null)
                        {
                            CardUseStruct use = card.OnResponding(this, self, pattern, prompt, method);
                            return(use);
                        }

                        SkillEvent skill = Engine.GetSkillEvent(skill_name);
                        if (skill != null)
                        {
                            CardUseStruct use = skill.OnResponding(this, self, pattern, prompt, method);
                            return(use);
                        }
                    }
                }
            }

            return(base.AskForUseCard(pattern, prompt, method));
        }