Exemplo n.º 1
0
        public void AnswerIsXaY(IListener st, INoun noun, INoun @class)
        {
            var edgeSuccessors  = SynSet.Graph.Successors <SynSet>(noun.Synset, Relation.RDFSType).ToList();
            var classSuccessors = SynSet.Graph.Successors <SynSet>(@class.Synset, Relation.RDFSType).ToList();

            if (edgeSuccessors.Any(e => e == @class.Synset))
            {
                st.Say("Yes, all " + noun.Plural.Text + " are " + @class.Plural.Text);
            }
            else
            {
                var intersects = edgeSuccessors.Intersect(classSuccessors).ToList();
                if (intersects.Any())
                {
                    var plurals = intersects.SelectMany(x => x.Lexemes)
                                  .Where(y => y.Interfaces.Contains(typeof(Plural)))
                                  .Select(y => y.Text)
                                  .Distinct();

                    st.Say("No, a " + noun.Singular.Text + " is not a " + @class.Singular.Text + " but they are both " + string.Join(",", plurals));
                }
                else
                {
                    st.Say("No, no " + noun.Singular.Text + " is a " + @class.Singular.Text);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the given message to the <see cref="Log"/> using the given subject
        /// and object.
        /// </summary>
        /// <param name="message">The text of the message.</param>
        public void Log(LogType type, INoun subject, string message, INoun obj)
        {
            bool ignore = false;

            // the log type assumes the hero is the subject. if not, some things
            // change.
            if (!(subject is Hero))
            {
                switch (type)
                {
                case LogType.Bad:
                    // good and bad are relative to the hero
                    type = LogType.Good;
                    break;

                case LogType.Good:
                    // good and bad are relative to the hero
                    type = LogType.Bad;
                    break;

                case LogType.DidNotWork:
                case LogType.Fail:
                    // don't care if a monster does something useless
                    ignore = true;
                    break;
                }
            }

            if (!ignore)
            {
                message = Sentence.Format(message, subject, obj);
                Game.Log.Write(type, message);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new Hit.
 /// </summary>
 public Hit(INoun attacker, Attack attack, bool canDodge, Direction direction)
 {
     Attacker  = attacker;
     Attack    = attack;
     CanDodge  = canDodge;
     Direction = direction;
 }
 public NLPActionResult QuestionIsaXaY(amIsAre isVerb,
                                       [Optional] AAn a, INoun noun,
                                       [Optional] AAn a2, INoun @class)
 {
     intent.AnswerIsXaY(st, noun, @class);
     return(NLPActionResult.None);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new LightAction.
 /// </summary>
 /// <param name="entity">The <see cref="Entity"/> using the light.</param>
 /// <param name="attack">The <see cref="Attack"/> to perform on anything hit by the light.</param>
 /// <param name="noun">The <see cref="Noun"/> describing the light.</param>
 /// <param name="radius">Maximum light radius.</param>
 public LightAction(Entity entity, INoun noun, int radius, Attack attack)
     : base(entity, entity.Position, radius, noun, attack)
 {
     if (!(entity is Hero))
     {
         throw new ArgumentException("Lame. Right now LightAction uses the Hero's cached visibility data, so can't be used by other entities.");
     }
 }
Exemplo n.º 6
0
        public string Conjugate(INoun noun, Tense tense = Tense.Past)
        {
            if (tense == Tense.Past)
            {
                return("became");
            }

            return(noun.Class == NounClass.It
                ? "becomes"
                : "become");
        }
Exemplo n.º 7
0
        public string Conjugate(INoun noun, Tense tense = Tense.Past)
        {
            if (tense == Tense.Past)
            {
                return("went");
            }

            return(noun.Class == NounClass.It
                ? "goes"
                : "go");
        }
Exemplo n.º 8
0
        public string Conjugate(INoun noun, Tense tense = Tense.Past)
        {
            if (tense == Tense.Past)
            {
                return("occurred");
            }

            return(noun.Class == NounClass.It
                ? "occurs"
                : "occur");
        }
Exemplo n.º 9
0
        public string Conjugate(INoun noun, Tense tense = Tense.Past)
        {
            if (tense == Tense.Past)
            {
                return(m_Stem.EndsWith("e") ? $"{m_Stem}d" : $"{m_Stem}ed");
            }

            return(noun.Class == NounClass.It
                ? $"{m_Stem}s"
                : m_Stem);
        }
Exemplo n.º 10
0
 public VerbExpression(
     IVerb verb,
     INoun subject = null,
     INoun objct   = null,
     Tense tense   = Tense.Past)
 {
     Verb    = verb;
     Tense   = tense;
     Subject = subject;
     Object  = objct;
 }
Exemplo n.º 11
0
        public string Conjugate(INoun noun, Tense tense = Tense.Past)
        {
            switch (noun.Class)
            {
            case NounClass.I:
                return(tense == Tense.Present ? "have" : "had");

            case NounClass.You:
                return(tense == Tense.Present ? "have" : "had");

            case NounClass.It:
                return(tense == Tense.Present ? "has" : "had");

            default:
                throw new ArgumentOutOfRangeException(nameof(noun.Class));
            }
        }
Exemplo n.º 12
0
 public ElementBallAction(Entity owner, Vec center, int radius, INoun noun, Attack attack)
     : base(owner, center, radius)
 {
     mNoun   = noun;
     mAttack = attack;
 }
Exemplo n.º 13
0
 public ActionResult Fail(INoun subject, string message)
 {
     return(Fail(subject, message, null));
 }
Exemplo n.º 14
0
 public ActionResult Fail(string message, INoun obj)
 {
     return(Fail(mEntity, message, obj));
 }
Exemplo n.º 15
0
        public ActionResult Fail(INoun subject, string message, INoun obj)
        {
            Log(LogType.Fail, subject, message, obj);

            return(ActionResult.Fail);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Writes the given message to the <see cref="Log"/> using the given subject.
 /// </summary>
 /// <param name="message">The text of the message.</param>
 public void Log(LogType type, INoun subject, string message)
 {
     Log(type, subject, message, null);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Writes the given message to the <see cref="Log"/> using the given subject
 /// and object.
 /// </summary>
 /// <param name="message">The text of the message.</param>
 public void Log(LogType type, string message, INoun obj)
 {
     Log(type, mEntity, message, obj);
 }
Exemplo n.º 18
0
 public static string ConjugatePassive(this IVerb verb, INoun objct, Tense tense = Tense.Past)
 {
     return($"{objct} {Verbs.ToBe.Conjugate(objct, tense)} {verb.Conjugate(objct, tense)}");
 }
 [Priority(-1000)]       // A rule of last resort!
 public NLPActionResult RecognizeAnyOtherNoun(INoun noun)
 {
     st.Say("Hmmm... I haven't been taught about " + noun.Plural.Text + " yet.");
     return(NLPActionResult.None);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Creates a new ElementBoltAction.
 /// </summary>
 public ElementBoltAction(NotNull <Entity> entity, Vec target, INoun noun, Attack attack)
     : base(entity, target)
 {
     mNoun   = noun;
     mAttack = attack;
 }
Exemplo n.º 21
0
 public ElementConeAction(Entity owner, Vec target, int radius, INoun noun, Attack attack)
     : base(owner, target, radius)
 {
     mNoun   = noun;
     mAttack = attack;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new Hit that cannot be dodged.
 /// </summary>
 /// <param name="damage">Damage the hit does.</param>
 public Hit(INoun attacker, Attack attack, Direction direction)
     : this(attacker, attack, false, direction)
 {
 }