Ejemplo n.º 1
0
        public void Accept1()
        {
            int       level   = 1;
            string    name    = "FOO";
            string    patt    = "9V99";
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.DA_DIV)),
                X.A(X.PIC(level, name, patt)),
                X.A(X.D(X.PR_DIV)),
                X.B(X.ACCEPT(name))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(1, program.Data.Count);
            ValidateDataField(program.Data[0], level, name, patt);
            Assert.AreEqual(1, program.Paragraphs.Count);
            var paraname = program.Paragraphs.Keys.First();

            Assert.AreEqual("", paraname);
            Assert.AreEqual(1, program.Paragraphs[paraname].Sentences.Count);
            Assert.AreEqual(1, program.Paragraphs[paraname].Sentences[0].Statements.Count);
            var stmt = program.Paragraphs[paraname].Sentences[0].Statements[0] as BcAccept;

            Assert.IsNotNull(stmt);
            Assert.AreEqual(1, stmt.Accepted.Count);
            Assert.AreEqual(name, stmt.Accepted[0].Name);
        }
Ejemplo n.º 2
0
 private void Update()
 {
     hit2D = Physics2D.Raycast(new Vector2(transform.position.x - 15, transform.position.y + 5), Vector2.right, 30f);
     if (hit2D && Input.GetKeyDown(KeyCode.E) && !WorldVariables.dialogueActive)
     {
         if (hit2D.collider.gameObject.tag == "Door")
         {
             Door door = hit2D.collider.gameObject.GetComponent <Door>();
             door.Interact(this.gameObject);
         }
         else if (hit2D.collider.gameObject.tag == "Interactable")
         {
             Interactable inter = hit2D.collider.gameObject.GetComponent <Interactable>();
             if (ps.Interact())
             {
                 inv.AddItem(inter.GetItem());
                 inter.CanInteract(false);
             }
         }
         else if (hit2D.collider.gameObject.tag == "Item")
         {
             FreeItem item = hit2D.collider.gameObject.GetComponent <FreeItem>();
             inv.AddItem(item.id);
             Destroy(hit2D.collider.gameObject);
         }
         else if (hit2D.collider.gameObject.tag == "BackDoor")
         {
             BackDoor door = hit2D.collider.gameObject.GetComponent <BackDoor>();
             door.Interact(this.gameObject);
         }
     }
 }
Ejemplo n.º 3
0
        public void EmptyLine12()
        {
            string            input = X.Six + X.Six;
            List <LineOfCode> lines = BackDoor.Preprocess(input);

            Assert.IsNotNull(lines);
            Assert.AreEqual(0, lines.Count);
        }
Ejemplo n.º 4
0
        public void EmptyProgram()
        {
            string    input   = String.Empty;
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.ID_DIV))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(0, program.Paragraphs.Count);
        }
Ejemplo n.º 5
0
        public void LineZoneB()
        {
            string            input = X.B(X.D(X.S_NXT_SEN));
            List <LineOfCode> lines = BackDoor.Preprocess(input);

            Assert.IsNotNull(lines);
            Assert.AreEqual(1, lines.Count);
            LineZoneB line = lines[0] as LineZoneB;

            Assert.IsNotNull(line);
            Assert.AreEqual((uint)1, line.Line);
            Assert.AreEqual(X.D(X.S_NXT_SEN), line.Content);
        }
Ejemplo n.º 6
0
        public void LineZoneA()
        {
            string            input = X.A(X.D(X.ID_DIV));
            List <LineOfCode> lines = BackDoor.Preprocess(input);

            Assert.IsNotNull(lines);
            Assert.AreEqual(1, lines.Count);
            LineZoneA line = lines[0] as LineZoneA;

            Assert.IsNotNull(line);
            Assert.AreEqual((uint)1, line.Line);
            Assert.AreEqual(X.D(X.ID_DIV), line.Content);
        }
Ejemplo n.º 7
0
        public void TopLevelPicName()
        {
            int       level   = 1;
            string    name    = "PICTUREISCOOL";
            string    patt    = "X(20)";
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.DA_DIV)),
                X.A(X.PIC(level, name, patt))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(1, program.Data.Count);
            X.ValidateDataField(program.Data[0], level, name, patt);
        }
Ejemplo n.º 8
0
        public void TopLevelLike()
        {
            int       level = 3;
            string    name1 = "FOO", name2 = "BAR";
            string    patt    = "X(20)";
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.DA_DIV)),
                X.A(X.PIC(level, name1, patt)),
                X.A(X.LIKE(level, name2, name1))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(2, program.Data.Count);
            X.ValidateDataField(program.Data[0], level, name1, patt);
            X.ValidateDataField(program.Data[1], level, name2, patt);
        }
Ejemplo n.º 9
0
        public void TopLevelPicLike()
        {
            int       level   = 3;
            string    name1   = "LY";
            string    patt1   = "S9(10)V9(2)";
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.DA_DIV)),
                X.A(X.PIC(level, name1, patt1)),
                X.A("03 UNLIKELY.")     // should be perceived as UN LIKE LY where LY is a PIC above
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(2, program.Data.Count);
            X.ValidateDataField(program.Data[0], level, name1, patt1);
            X.ValidateDataField(program.Data[1], level, "UN", patt1);
        }
Ejemplo n.º 10
0
        public void OneClaimBoolean()
        {
            string    claim   = "AUTHOR-is-grammarware";
            string    input   = String.Empty;
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.ID_DIV)),
                X.B(X.D(claim))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(1, program.Identifications.Count);
            string k = program.Identifications.Keys.First();

            Assert.AreEqual(claim, k);
            Assert.AreEqual("", program.Identifications[k]);
            Assert.AreEqual(0, program.Paragraphs.Count);
        }
Ejemplo n.º 11
0
        public void OneClaimManyDots()
        {
            string    claim1  = "AUTHOR";
            string    claim2  = "g.r.a.m.m.a.r.w.a.r.e";
            string    input   = String.Empty;
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.ID_DIV)),
                X.B(X.D(claim1) + X.D(claim2))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(1, program.Identifications.Count);
            string k = program.Identifications.Keys.First();

            Assert.AreEqual(claim1, k);
            Assert.AreEqual(claim2, program.Identifications[k]);
            Assert.AreEqual(0, program.Paragraphs.Count);
        }
Ejemplo n.º 12
0
        public void NestedPicName2()
        {
            int       level1 = 1, level2 = 5;
            string    name1 = "UNLIKELY", name2 = "FOO";
            string    patt    = "99999V999";
            BcProgram program = BackDoor.Parse(
                X.A(X.D(X.DA_DIV)),
                X.A(X.VIEW(level1, name1)),
                X.B(X.PIC(level2, name2, patt))
                );

            Assert.IsNotNull(program);
            Assert.AreEqual(0, program.Identifications.Count);
            Assert.AreEqual(1, program.Data.Count);
            var view = program.Data[0] as BcDataView;

            Assert.IsNotNull(view);
            Assert.AreEqual(level1, view.Level);
            Assert.AreEqual(name1, view.Name);
            Assert.AreEqual(1, view.Inners.Count);
            X.ValidateDataField(view.Inners[0], level2, name2, patt);
        }