示例#1
0
 private static void LoadSaved()
 {
     CardPair.LoadPairs(CardPair.saveFile, CardPair.CardPairs);
     CardPair.LoadPairs(CardPair.fullSaveFile, CardPair.FullCardPairs);
     Game.LoadGameCodes();
 }
示例#2
0
        private static void Save(Game game)
        {
            Game.GameCodes.Add(game.Code);
            HeroClass winner = game.First.IsWinner ? game.First.HeroClass : game.Second.HeroClass;
            HeroClass loser  = game.First.IsWinner ? game.Second.HeroClass : game.First.HeroClass;

            Console.WriteLine(winner + " beats " + loser);
            int          oldPairsCount     = CardPair.CardPairs.Count;
            int          oldFullPairsCount = CardPair.FullCardPairs.Count;
            List <Stats> stats             = new List <Stats>();

            foreach (HeroClass hero in Enum.GetValues(typeof(HeroClass)))
            {
                if (hero == winner || hero == loser)
                {
                    if (stats.Find(x => x.hero == hero) == null)
                    {
                        stats.Add(new Stats(hero));
                    }
                }
            }
            Console.WriteLine("---------------------");
            CardPair.AddGamePairs(game.CardPairs, CardPair.CardPairs);
            CardPair.AddGamePairs(game.FullCardPairs, CardPair.FullCardPairs);
            Console.WriteLine("Adding " + game.CardPairs.Count + " new card pairs.");
            Console.WriteLine("Adding " + game.FullCardPairs.Count + " new full card pairs.");
            CardPair.SavePairs(CardPair.CardPairs, false);
            CardPair.SavePairs(CardPair.FullCardPairs, true);
            Console.WriteLine("Saving " +
                              string.Format("{0:n0}", CardPair.CardPairs.Count) +
                              " (" + string.Format("{0:+#;-#;0}", CardPair.CardPairs.Count - oldPairsCount) + ")" +
                              " total card pairs.");
            Console.WriteLine("Saving " +
                              string.Format("{0:n0}", CardPair.FullCardPairs.Count) +
                              " (" + string.Format("{0:+#;-#;0}", CardPair.FullCardPairs.Count - oldFullPairsCount) + ")" +
                              " total full card pairs.");
            Game.SaveGameCodes();
            Console.WriteLine("Games saved: " + String.Format("{0:n0}", Game.GameCodes.Count));
            double percentage     = 100.0 * Game.GameCodes.Count / CardPair.CardPairs.Count;
            double fullPercentage = 100.0 * Game.GameCodes.Count / CardPair.FullCardPairs.Count;

            Console.WriteLine("Games/Pairs = " +
                              string.Format("{0:0.00}", percentage) +
                              "% (" + string.Format("{0:+#.00;-#.00;0}",
                                                    percentage - 100.0 * (Game.GameCodes.Count - 1) / oldPairsCount) + ")");
            Console.WriteLine("Games/Full Pairs = " +
                              string.Format("{0:0.00}", fullPercentage) +
                              "% (" + string.Format("{0:+#.00;-#.00;0}",
                                                    fullPercentage - 100.0 * (Game.GameCodes.Count - 1) / oldFullPairsCount) + ")");
            Console.WriteLine("---------------------");
            foreach (HeroClass hero in Enum.GetValues(typeof(HeroClass)))
            {
                if (hero == HeroClass.NONE)
                {
                    continue;
                }
                Stats st = stats.Find(x => x.hero == hero);
                Console.WriteLine(hero.ToString() + ":");
                if (st == null)
                {
                    PrintPairs(CardPair.CardPairs, hero);
                }
                else
                {
                    PrintPairs(CardPair.CardPairs, hero, st.pairs, st.wins, st.loses);
                }
                if (st == null)
                {
                    PrintPairs(CardPair.FullCardPairs, hero);
                }
                else
                {
                    PrintPairs(CardPair.FullCardPairs, hero, st.fullPairs, st.fullWins, st.fullLoses);
                }
            }
            Console.WriteLine("---------------------");
        }