Ejemplo n.º 1
0
        public void FIBS_SettingsValueChangeToYes()
        {
            var monster        = CreateLoggedInCookieMonster();
            var settingPhrases = new Dictionary <string, string> {
                ["allowpip"]   = "** You allow the use the server's 'pip' command.",
                ["autoboard"]  = "** The board will be refreshed after every move.",
                ["autodouble"] = "** You agree that doublets during opening double the cube.",
                ["automove"]   = "** Forced moves will be done automatically.",
                ["away"]       = "You're away. Please type 'back'",
                ["bell"]       = "** Your terminal will ring the bell if someone talks to you or invites you",
                ["crawford"]   = "** You insist on playing with the Crawford rule.",
                ["double"]     = "** You will be asked if you want to double.",
                ["greedy"]     = "** Will use automatic greedy bearoffs.",
                ["moreboards"] = "** Will send rawboards after rolling.",
                ["moves"]      = "** You want a list of moves after this game.",
                ["notify"]     = "** You'll be notified when new users log in.",
                ["ratings"]    = "** You'll see how the rating changes are calculated.",
                ["ready"]      = "** You're now ready to invite or join someone.",
                ["report"]     = "** You will be informed about starting and ending matches.",
                ["silent"]     = "** You will hear what other players shout.",
                ["telnet"]     = "** You use telnet and don't need extra 'newlines'.",
                ["wrap"]       = "** The server will wrap long lines.",
            };

            foreach (var pair in settingPhrases)
            {
                var cm = monster.EatCookie(pair.Value);
                Assert.Equal(FibsCookie.FIBS_SettingsChange, cm.Cookie);
                Assert.Equal(pair.Key, cm.Crumbs["name"]);
                Assert.True(CookieMonster.ParseBool(cm.Crumbs["value"]), $"{cm.Crumbs["name"]}= {cm.Crumbs["value"]}");
            }
        }
Ejemplo n.º 2
0
        public Player(string color, BoardCrumbs b)
        {
            Assert.True(color == "O" || color == "X");

            this.Color = color;
            if (CookieMonster.ParseBoardColor(b.player1Color) == this.Color)
            {
                Name      = b.player1;
                Score     = b.player1Score;
                Bar       = b.player1Bar;
                Home      = b.player1Home;
                Dice      = b.player1Dice == "0:0" ? null : b.player1Dice.Split(':').Select(s => int.Parse(s)).ToArray();
                MayDouble = b.player1MayDouble == 1;
            }
            else
            {
                Name      = b.player2;
                Score     = b.player2Score;
                Bar       = b.player2Bar;
                Home      = b.player2Home;
                Dice      = b.player2Dice == "0:0" ? null : b.player2Dice.Split(':').Select(s => int.Parse(s)).ToArray();
                MayDouble = b.player2MayDouble == 1;
            }

            IsTurn = CookieMonster.ParseTurnColor(b.turnColor) == Color;
        }
Ejemplo n.º 3
0
        public void FIBS_SettingsValueChangeToNo()
        {
            var monster        = CreateLoggedInCookieMonster();
            var settingPhrases = new Dictionary <string, string> {
                ["allowpip"]   = "** You don't allow the use of the server's 'pip' command.",
                ["autoboard"]  = "** The board won't be refreshed after every move.",
                ["autodouble"] = "** You don't agree that doublets during opening double the cube.",
                ["automove"]   = "** Forced moves won't be done automatically.",
                ["away"]       = "Welcome back.",
                ["bell"]       = "** Your terminal won't ring the bell if someone talks to you or invites you",
                ["crawford"]   = "** You would like to play without using the Crawford rule.",
                ["double"]     = "** You won't be asked if you want to double.",
                ["greedy"]     = "** Won't use automatic greedy bearoffs.",
                ["moreboards"] = "** Won't send rawboards after rolling.",
                ["moves"]      = "** You won't see a list of moves after this game.",
                ["notify"]     = "** You won't be notified when new users log in.",
                ["ratings"]    = "** You won't see how the rating changes are calculated.",
                ["ready"]      = "** You're now refusing to play with someone.",
                ["report"]     = "** You won't be informed about starting and ending matches.",
                ["silent"]     = "** You won't hear what other players shout.",
                ["telnet"]     = "** You use a client program and will receive extra 'newlines'.",
                ["wrap"]       = "** Your terminal knows how to wrap long lines.",
            };

            foreach (var pair in settingPhrases)
            {
                var cm = monster.EatCookie(pair.Value);
                Assert.Equal(FibsCookie.FIBS_SettingsChange, cm.Cookie);
                Assert.Equal(pair.Key, cm.Crumbs["name"]);
                Assert.False(CookieMonster.ParseBool(cm.Crumbs["value"]), $"{cm.Crumbs["name"]}= {cm.Crumbs["value"]}");
            }
        }
Ejemplo n.º 4
0
        public void CLIP_OWN_INFO()
        {
            var monster = new CookieMonster();
            var s       = "2 myself 1 1 0 0 0 0 1 1 2396 0 1 0 1 3457.85 0 0 0 0 0 Australia/Melbourne";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_OWN_INFO, cm.Cookie);
            Assert.Equal("myself", cm.Crumbs["name"]);
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["allowpip"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["autoboard"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["autodouble"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["automove"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["away"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["bell"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["crawford"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["double"]));
            Assert.Equal(2396, int.Parse(cm.Crumbs["experience"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["greedy"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["moreboards"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["moves"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["notify"]));
            Assert.Equal(3457.85, double.Parse(cm.Crumbs["rating"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["ratings"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["ready"]));
            Assert.Equal("0", cm.Crumbs["redoubles"]);
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["report"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["silent"]));
            Assert.Equal("Australia/Melbourne", cm.Crumbs["timezone"]);
        }
Ejemplo n.º 5
0
        public void FIBS_Board()
        {
            // from http://www.fibs.com/fibs_interface.html#board_state
            var monster = CreateLoggedInCookieMonster();
            var s       = "board:You:someplayer:3:0:1:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:1:6:2:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_Board, cm.Cookie);
            Assert.Equal("You", cm.Crumbs["player1"]);
            Assert.Equal("someplayer", cm.Crumbs["player2"]);
            Assert.Equal(3, int.Parse(cm.Crumbs["matchLength"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["player1Score"]));
            Assert.Equal(1, int.Parse(cm.Crumbs["player2Score"]));
            Assert.Equal("0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0", cm.Crumbs["board"]);
            Assert.Equal("O", CookieMonster.ParseBoardTurn(cm.Crumbs["turnColor"]));
            Assert.Equal("6:2", cm.Crumbs["player1Dice"]);
            Assert.Equal("0:0", cm.Crumbs["player2Dice"]);
            Assert.Equal(1, int.Parse(cm.Crumbs["doublingCube"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["player1MayDouble"]));
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["player2MayDouble"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["wasDoubled"]));
            Assert.Equal("O", CookieMonster.ParseBoardColor(cm.Crumbs["player1Color"]));
            Assert.Equal(-1, int.Parse(cm.Crumbs["direction"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["player1Home"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["player2Home"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["player1Bar"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["player2Bar"]));
            Assert.Equal(2, int.Parse(cm.Crumbs["canMove"]));
            Assert.Equal(0, int.Parse(cm.Crumbs["redoubles"]));
        }
Ejemplo n.º 6
0
        // src - https://github.com/cefsharp/CefSharp/issues/826#issuecomment-75226806
        public IEnumerable <Tuple <string, string, string, string, string, string> > get_cookies()
        {
            //https://github.com/cefsharp/CefSharp/issues/1770
            //https://github.com/cefsharp/CefSharp/blob/cefsharp/51/CefSharp.Core/RequestContext.h#L121


            CookieMonster visitor = new CookieMonster();


            //base
            if (chrome.RequestContext == null)
            {
                if (Cef.GetGlobalCookieManager().VisitAllCookies(visitor))
                {
                    visitor.WaitForAllCookies();
                }
            }
            else
            { //RequestContext
                ICookieManager cookie_manage = chrome.RequestContext.GetCookieManager(null);

                if (cookie_manage.VisitAllCookies(visitor))
                {
                    visitor.WaitForAllCookies();
                }
            }

            return(visitor.NamesValues);
        }
Ejemplo n.º 7
0
        public void FIBS_WARNINGAlreadyLoggedIn()
        {
            var monster = new CookieMonster();
            var s       = "** Warning: You are already logged in.";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_WARNINGAlreadyLoggedIn, cm.Cookie);
        }
Ejemplo n.º 8
0
        CookieMonster CreateLoggedInCookieMonster()
        {
            var monster = new CookieMonster();

            monster.EatCookie("3"); // simulate MOTD
            monster.EatCookie("4"); // simulate MOTD end
            return(monster);
        }
Ejemplo n.º 9
0
        public void CLIP_MOTD_BEGIN()
        {
            var monster = new CookieMonster();
            var s       = "3";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_MOTD_BEGIN, cm.Cookie);
        }
Ejemplo n.º 10
0
        public void FIBS_PreLogin()
        {
            var monster = new CookieMonster();
            var s       = "Saturday, October 15 17:01:02 MEST   ( Sat Oct 15 15:01:02 2016 UTC )";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_PreLogin, cm.Cookie);
            Assert.Equal(s, cm.Crumbs["message"]);
        }
Ejemplo n.º 11
0
        public void FIBS_SettingsValueNo()
        {
            var monster = CreateLoggedInCookieMonster();
            var s       = "autodouble      NO";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_SettingsValue, cm.Cookie);
            Assert.Equal("autodouble", cm.Crumbs["name"]);
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["value"]));
        }
Ejemplo n.º 12
0
        public void CLIP_MOTD_END()
        {
            var monster = new CookieMonster();

            monster.EatCookie("3");
            var s  = "4";
            var cm = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_MOTD_END, cm.Cookie);
        }
Ejemplo n.º 13
0
        public void FIBS_SettingsYoureNotAway()
        {
            var monster = CreateLoggedInCookieMonster();
            var s       = "** You're not away.";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_SettingsValue, cm.Cookie);
            Assert.Equal("away", cm.Crumbs["name"]);
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["value"]));
        }
Ejemplo n.º 14
0
        public void FIBS_SettingsValueYes()
        {
            var monster = CreateLoggedInCookieMonster();
            var s       = "allowpip        YES";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_SettingsValue, cm.Cookie);
            Assert.Equal("allowpip", cm.Crumbs["name"]);
            Assert.True(CookieMonster.ParseBool(cm.Crumbs["value"]));
        }
Ejemplo n.º 15
0
        public void FIBS_MOTD2()
        {
            var monster = new CookieMonster();

            monster.EatCookie("3");
            var s  = "| It was a dark and stormy night in Oakland.  Outside, the rain      |";
            var cm = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_MOTD, cm.Cookie);
            Assert.Equal(s, cm.Raw);
        }
Ejemplo n.º 16
0
        public void FIBS_MOTD1()
        {
            var monster = new CookieMonster();

            monster.EatCookie("3");
            var s  = "+--------------------------------------------------------------------+";
            var cm = monster.EatCookie(s);

            Assert.Equal(FibsCookie.FIBS_MOTD, cm.Cookie);
            Assert.Equal(s, cm.Raw);
        }
Ejemplo n.º 17
0
        public void CLIP_MESSAGE()
        {
            var monster = CreateLoggedInCookieMonster();
            var s       = "9 someplayer 1041253132 I'll log in at 10pm if you want to finish that game.";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_MESSAGE, cm.Cookie);
            Assert.Equal("someplayer", cm.Crumbs["from"]);
            Assert.Equal(DateTime.Parse("12/30/2002 12:58:52 PM"), CookieMonster.ParseTimestamp(cm.Crumbs["time"]));
            Assert.Equal("I'll log in at 10pm if you want to finish that game.", cm.Crumbs["message"]);
        }
Ejemplo n.º 18
0
        public void CLIP_WELCOME()
        {
            var monster = new CookieMonster();
            var s       = "1 myself 1041253132 192.168.1.308";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_WELCOME, cm.Cookie);
            Assert.Equal("myself", cm.Crumbs["name"]);
            var lastLogin = CookieMonster.ParseTimestamp(cm.Crumbs["lastLogin"]);

            Assert.Equal(DateTime.Parse("12/30/2002 12:58:52 PM"), lastLogin);
            Assert.Equal("192.168.1.308", cm.Crumbs["lastHost"]);
        }
Ejemplo n.º 19
0
        private void button5_Click(object sender, EventArgs e)
        {
            var visitor = new CookieMonster(all_cookies =>
            {
                var sb = new StringBuilder();
                foreach (var nameValue in all_cookies)
                {
                    sb.AppendLine(nameValue.Item1 + " = " + nameValue.Item2);
                }
                BeginInvoke(new MethodInvoker(() =>
                {
                    MessageBox.Show(sb.ToString());
                }));
            });

            Cef.VisitAllCookies(visitor);
        }
Ejemplo n.º 20
0
        private void cookie_Click(object sender, EventArgs e)
        {
            //cookieManager.VisitUrlCookies("https://www.ctrip.com",true,visitor);
            //MessageBox.Show(cookies);

            var visitor = new CookieMonster(all_cookies => {
                var sb = new StringBuilder();
                foreach (var nameValue in all_cookies)
                {
                    sb.AppendLine(nameValue.Item1 + " = " + nameValue.Item2);
                }
                BeginInvoke(new MethodInvoker(() => {
                    MessageBox.Show(sb.ToString());
                }));
            });

            cookieManager.VisitUrlCookies("https://www.ctrip.com", true, visitor);
        }
Ejemplo n.º 21
0
        public void CLIP_WHO_INFO()
        {
            var monster = CreateLoggedInCookieMonster();
            var s       = "5 someplayer mgnu_advanced - 0 0 1418.61 23 1914 1041253132 192.168.40.3 MacFIBS [email protected]";
            var cm      = monster.EatCookie(s);

            Assert.Equal(FibsCookie.CLIP_WHO_INFO, cm.Cookie);
            Assert.Equal("someplayer", cm.Crumbs["name"]);
            Assert.Equal("mgnu_advanced", cm.Crumbs["opponent"]);
            Assert.Null(CookieMonster.ParseOptional(cm.Crumbs["watching"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["ready"]));
            Assert.False(CookieMonster.ParseBool(cm.Crumbs["away"]));
            Assert.InRange(double.Parse(cm.Crumbs["rating"]), 1418.60, 1418.62);
            Assert.Equal(23, int.Parse(cm.Crumbs["experience"]));
            Assert.Equal(1914, int.Parse(cm.Crumbs["idle"]));
            Assert.Equal(DateTime.Parse("12/30/2002 12:58:52 PM"), CookieMonster.ParseTimestamp(cm.Crumbs["login"]));
            Assert.Equal("192.168.40.3", cm.Crumbs["hostName"]);
            Assert.Equal("MacFIBS", CookieMonster.ParseOptional(cm.Crumbs["client"]));
            Assert.Equal("*****@*****.**", CookieMonster.ParseOptional(cm.Crumbs["email"]));
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Console.Title = "Dungeon of Tommorrow";
            Console.WriteLine("WELCOME TO THE DUNGEON OF TOMORROOOWWW!!!");
            //todo create player
            Weapon sword  = new Weapon("Sword of Poop", 35, 45, 75, false);
            Player player = new Player("Neil", 80, 40, 75, Race.Elf, sword, 75);
            //todo create do While
            bool exit = false;

            do
            {
                //todo create a room
                Console.WriteLine(GetRoom());
                //todo create monster
                Dragon d1 = new Dragon();
                Dragon d2 = new Dragon("Undead Dragon", 25, 25, 25, 50, 20, 2, " its bones are melting away", true);
                Yeti   y1 = new Yeti();
                HeWhoShallNotBeNamed h1 = new HeWhoShallNotBeNamed();
                Gargoyles            g1 = new Gargoyles();
                Shredder             s1 = new Shredder();
                Kraken        k1        = new Kraken();
                Frankenstein  f1        = new Frankenstein();
                CookieMonster c1        = new CookieMonster();
                bool          reload    = false;
                Monster[]     monsters  =
                {
                    d2, s1, d1, d1, y1, g1, g1, g1, g1, c1, c1, c1, c1, f1, f1, f1, k1, k1, h1, h1, y1, y1, d1, d1, d2, d1
                };

                Random  rand    = new Random();
                Monster monster = monsters[rand.Next(monsters.Length)];

                Console.WriteLine("\n in this room: " + monster.Name);
                do
                {
                    //todo menu of choice
                    #region MENU

                    Console.WriteLine(
                        "PLEASE CHOOSE AN ACTION:\n\n" +

                        "\nA) Attack" +
                        "\nR) RUN AWAY" +
                        "\nC) Character Info" +
                        "\nM) monster Info" +
                        "\nX) Exit" +
                        "\nEnter your choice: ");
                    //todo catch the unser input
                    string userChoice = Console.ReadLine().ToUpper();


                    //todo switch for user choice
                    switch (userChoice)
                    {
                    case "A":
                        // Console.WriteLine("Attack method goes here");
                        //todo handle if player wins
                        //todo handle if player loses
                        Combat.DoBattle(player, monster);
                        if (monster.Life <= 0)
                        {
                            Console.WriteLine("\n you defrated a {0}", monster.Name);
                            reload = true;
                        }
                        break;

                    case "R":
                        Console.WriteLine("RUN AWAY!!!");
                        //todo monster gers a free attack
                        //todo load a new room
                        Combat.DoAttack(monster, player);     //free attack
                        reload = true;

                        break;

                    case "C":
                        Console.WriteLine("Character info");
                        //todo add players info to the screen
                        Console.WriteLine(player);
                        break;

                    case "M":
                        Console.WriteLine("monster info");
                        Console.WriteLine(monster);
                        break;

                    case "X":
                    case "E":
                        Console.WriteLine("ya ninny");
                        exit = true;
                        break;

                    default:
                        Console.WriteLine("invalid choice. ya ninny!! try again");
                        break;
                    }//end switch

                    #endregion
                    //todo:address players life
                    if (player.Life <= 0)
                    {
                        Console.WriteLine("uhhh I got some bad news for you...you died\a");
                        exit = true;
                    }
                } while (!reload && !exit);
            } while (!exit);
        }//end Main()
Ejemplo n.º 23
0
 private void button5_Click(object sender, EventArgs e)
 {
     var visitor = new CookieMonster(all_cookies =>
     {
         var sb = new StringBuilder();
         foreach (var nameValue in all_cookies)
             sb.AppendLine(nameValue.Item1 + " = " + nameValue.Item2);
         BeginInvoke(new MethodInvoker(() =>
         {
             MessageBox.Show(sb.ToString());
         }));
     });
     Cef.VisitAllCookies(visitor);
 }