예제 #1
0
        private static void RecordMoveandResults(BoardState state, CardChoice choice, Card card, CardPlacement placement, int change)
        {
            DecisionResults results = new DecisionResults();

            results.DrawChoice      = choice;
            results.DrawnCardValue  = card.Number;
            results.PlacementChoice = placement;
            results.HandValueChange = change;

            JSONwriter.RecordStateAndResults(state, results);
        }
예제 #2
0
        public static bool RecordStateAndResults(BoardState state, DecisionResults results)
        {
            try
            {
                string basepath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + String.Format("\\Documents\\_code\\_gitHub\\LucysGame\\recordedGameplay\\");
                string filepath = String.Format("{0} play.txt", System.DateTime.Now.ToString("yyyymmddHHmm"));
                string fullpath = basepath + filepath;

                using (StreamWriter writer = File.AppendText(fullpath))
                {
                    writer.WriteLine(JsonStringFromBoardState(state));
                    writer.WriteLine(JsonStringFromResults(results));
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
예제 #3
0
        public static string JsonStringFromResults(DecisionResults results)
        {
            string resultString = JsonConvert.SerializeObject(results);

            return(resultString);
        }