public List <Intent> LoadIntents()
        {
            List <IntentFromFile> intentsFromFile;

            using (StreamReader r = new StreamReader("Implementations/RestaurantReservation/intents.json"))
            {
                string json = r.ReadToEnd();
                intentsFromFile = JsonConvert.DeserializeObject <List <IntentFromFile> >(json);
            }

            foreach (IntentFromFile intentFromFile in intentsFromFile)
            {
                if (!Goals.Select(x => x.ID).Contains(intentFromFile.StartGoalID))
                {
                    throw new Exception("Intent references a goal that does not exist");
                }
            }

            List <Intent> intents = new List <Intent>();

            foreach (IntentFromFile intentFromFile in intentsFromFile)
            {
                intents.Add(new Intent()
                {
                    ID          = intentFromFile.ID,
                    StartGoalID = intentFromFile.StartGoalID
                });
            }

            return(intents);
        }
Пример #2
0
 public Achievement Clone()
 {
     return(new Achievement
     {
         Name = Name,
         Goals = Goals.Select(g => g.Clone()).ToList(),
     });
 }
        public MoveType GetClosestDirection()
        {
            var closestGoal = Goals.Select(q => new
            {
                goal     = q,
                distance = GetDistance(q)
            }).OrderBy(q => q.distance).Select(q => q.goal).FirstOrDefault();

            return(GetDirectionToGoal(closestGoal));
        }
 Messages.SuggestAction IToBase <Messages.SuggestAction> .ToBase()
 {
     return(new Messages.SuggestAction()
     {
         gameId = GameId,
         GoalFields = Goals?.Select(q => q.ToBase()).ToArray(),
         playerGuid = PlayerGUID,
         playerId = PlayerId,
         senderPlayerId = SenderPlayerId,
         TaskFields = Tasks?.Select(q => q.ToBase()).ToArray()
     });
 }
        public static Achievement ToMock(this Achievement ad, Uri uri)
        {
            string          rawText = Lipsums.LoremIpsum;
            LipsumGenerator lipsum  = new LipsumGenerator(rawText, false);
            var             goals   = new Goals().ToMock(uri, 2);

            return(new Achievement()
            {
                SimpleName = $"{lipsum.GenerateWords(1)[0]}",
                NameTranslations = new StringTranslationsCore().Map(new StringTranslations().ToMock()),
                MediaTranslations = new MediaTranslationsCore().Map(new MediaTranslations().ToMock(uri)),
                Goals = goals.Select(a => a.EntityRefId).ToList()
            });
        }
Пример #6
0
 public GameMasterSettingsGameDefinition ToBase()
 {
     return(new GameMasterSettingsGameDefinition()
     {
         Goals = Goals?.Select(q => new Messages.GoalField((uint)q.X, (uint)q.Y, q.Team, q.Type)).ToArray(),
         ShamProbability = ShamProbability,
         PlacingNewPiecesFrequency = (uint)PlacingNewPiecesFrequency,
         InitialNumberOfPieces = (uint)InitialNumberOfPieces,
         BoardWidth = (uint)BoardWidth,
         TaskAreaLength = (uint)TaskAreaLength,
         GoalAreaLength = (uint)GoalAreaLength,
         NumberOfPlayersPerTeam = (uint)NumberOfPlayersPerTeam,
         GameName = GameName,
         NumberOfGoalsPerGame = NumberOfGoalsPerGame,
     });
 }