package greycat.samples.Battleground;

import greycat.Type;
import greycat.Graph;
import greycat.GraphBuilder;
import greycat.Node;

/**
 * Created by Quentin on 18/05/2017.
 */
public class MinimalClasses {


    public static void main(String[] args) {

        //Create a minimal graph with the default configuration
        Graph g = new GraphBuilder().build();

        //Connect the graph
        g.connect(isConnected -> {
            //Display that the graph database is connected!
            System.out.println("Connected : " + isConnected);

            long timepoint_0 = 0;  //the timestamp is a long and represents the time concept



            Node target1 = g.newNode(0, timepoint_0); //the second param is the time
            target1.set("id", Type.STRING, "2");
            target1.set("name", Type.STRING, "Target1");
            target1.set("Resilience", Type.DOUBLE, 5.0); //set the value of the sensor


            Node tank1 = g.newNode(0, timepoint_0); //the second param is the time
            tank1.set("id", Type.STRING, "1");
            tank1.set("name", Type.STRING, "Tank1");
            tank1.set("Power", Type.DOUBLE, 3.0); //set the value of the sensor



            long timepoint_1 = 100;
            tank1.travelInTime(timepoint_1, (Node tank1T1) -> {
                tank1T1.set("Power", Type.DOUBLE, 8.0); //update the value of the time now
                //Display the value at time 0
                System.out.println("T0:" + tank1.toString()); //print T0:{"world":0,"time":0,"id":1,"id":"4494F","name":"sensor0","value":0.5}
                System.out.println("T0:" + target1.toString());

                //Display the value at time now
                System.out.println("T1:" + tank1T1.toString()); //print T1:{"world":0,"time":100,"id":1,"id":"4494F","name":"sensor0","value":21.3}

                tank1.addToRelation("can_destroy", target1); //add the sensor0 to the relation sensors of room0

                tank1.relation("can_destroy", (Node[] can_destroy) -> {
                    System.out.println("Relationship can destroy :");
                    for (Node can_des : can_destroy) {
                        System.out.println("\t" + can_des.toString());
                    }
                });



                long timepoint_2= 200;
                tank1.travelInTime(timepoint_2, (Node tank1T2) ->{

                    tank1T2.set("Power", Type.DOUBLE, 10.0); //update the value of the time now
                    System.out.println("T2:" + tank1T2.toString()); //prints T2:{"world":0,"time":50,"id":1,"id":"4494F","name":"sensor0","value":0.5}
                });



            });

        });
    }




}

@@ -1851,16 +1851,18 @@
    tank1
+T1
 .addToRe
@@ -1948,316 +1948,61 @@
 om0%0A
-%0A                tank1.relation(%22can_destroy%22, (Node%5B%5D can_destroy) -%3E %7B%0A                    System.out.println(%22Relationship can destroy :%22);%0A                    for (Node can_des : can_destroy) %7B%0A                        System.out.println(%22%5Ct%22 + can_des.toString());%0A                    %7D%0A                %7D
+                System.out.println(tank1T1.toString()
 );%0A%0A

Test tank/target