Esempio n. 1
0
        public static string GetRandomDataPart(ConnectorData.ConnectorType type, RandomMessageData data)
        {
            string toReturn = "unsupported";

            switch (type)
            {
            case ConnectorData.ConnectorType.Objects:
            {
                var yes = random.Next(data.objects.Count);
                Console.WriteLine($"DEBUG OBJECTS:\nrand int {yes}\nobjects size {data.objects.Count}");
                toReturn = data.objects[yes];
                break;
            }

            case ConnectorData.ConnectorType.People:
            {
                var yes = random.Next(data.people.Count);
                Console.WriteLine($"DEBUG PEOPLE:\nrand int {yes}\npeople size {data.people.Count}");
                toReturn = data.people[yes];
                break;
            }

            case ConnectorData.ConnectorType.Places:
            {
                var yes = random.Next(data.places.Count);
                Console.WriteLine($"DEBUG PLACES:\nrand int {yes}\nplaces size {data.places.Count}");
                toReturn = data.places[yes];
                break;
            }
            }

            return(toReturn);
        }
Esempio n. 2
0
 public void ParseRandomMessage()
 {
     using (StreamReader r = new StreamReader("data_rand.json"))
     {
         string json = r.ReadToEnd();
         randomData = JsonConvert.DeserializeObject <RandomMessageData>(json);
     }
 }
Esempio n. 3
0
        public static string GetRandomSentence(ConnectorData connector, RandomMessageData randomData)
        {
            string final = null;

            bool noRepeat    = connector.conditions.Contains(ConnectorData.ConnectorConditions.NoTypeRepeat);
            bool onlyOneType = connector.conditions.Contains(ConnectorData.ConnectorConditions.OnlyOneTypeStart) ||
                               connector.conditions.Contains(ConnectorData.ConnectorConditions.OnlyOneTypeEnd);

            string firstPart  = GetRandomDataPart(connector.firstType, randomData);
            string middlePart = connector.connector;
            string secondPart = GetRandomDataPart(connector.secondType, randomData);

            if (noRepeat && secondPart == firstPart)
            {
                while (secondPart == firstPart)
                {
                    Console.WriteLine($"{secondPart} compared to {firstPart}");
                    secondPart = GetRandomDataPart(connector.secondType, randomData);
                }
            }

            if (onlyOneType)
            {
                if (connector.conditions.Contains(ConnectorData.ConnectorConditions.OnlyOneTypeStart))
                {
                    final = firstPart + " " + middlePart;
                }
                else
                {
                    final = middlePart + " " + firstPart;
                }
            }
            else
            {
                final = firstPart + " " + middlePart + " " + secondPart;
            }

            return(final);
        }