Exemplo n.º 1
0
        private Card NextCard()
        {
            int HP  = Utily.Next() % 5 / 2 + 1;
            int dir = Utily.Next() % 4;

            return(new Card(dir, HP));
        }
Exemplo n.º 2
0
        public void TestUtily()
        {
            int a = 2, b = 3;

            Utily.Swap <int>(ref a, ref b);
            Assert.True(a == 3 && b == 2, "Swap isn't correct");
            a = Utily.Next();
            b = Utily.Next();
            int c = Utily.Next();

            Assert.False(a == b && a == c, "It's realy strange Ranodm");
        }
Exemplo n.º 3
0
 public Game()
 {
     Players    = new Player[2];
     Players[0] = new Player();
     for (int i = 0; i < 9; i++)
     {
         Players[0].AddCard(NextCard());
     }
     Players[1] = new Player();
     for (int i = 0; i < 9; i++)
     {
         Players[1].AddCard(NextCard());
     }
     HowStart = Utily.Next() % 2;
     NewRound();
 }
Exemplo n.º 4
0
        public int CreateTable(int idPlayer, string name, string pass)
        {
            if (GetIdByName.ContainsKey(name))
            {
                return(-1);
            }
            if (!NickIsGood(name) || !PassIsGood(pass))
            {
                return(-1);
            }
            int id = Utily.GetTag();

            Tables.Add(id, new WebTable(idPlayer, pass, name));
            GetIdByName.Add(name, id);
            Accounts[idPlayer].JoinTable(id);
            return(id);
        }
Exemplo n.º 5
0
        public int LogIn(string nick, string pass)
        {
            if (GetIdByNick.ContainsKey(nick))
            {
                if (Accounts[GetIdByNick[nick]].Password == pass)
                {
                    return(GetIdByNick[nick]);
                }
                else
                {
                    return(-1);
                }
            }
            if (!NickIsGood(nick) || !PassIsGood(pass))
            {
                return(-1);
            }
            int id = Utily.GetTag();

            GetIdByNick.Add(nick, id);
            Accounts.Add(id, new WebPlayer(nick, pass, id));
            return(id);
        }
Exemplo n.º 6
0
 public void Next(int NumPlayer)
 {
     Players[NumPlayer].IsReady = true;
     if (Players[0].IsReady && Players[1].IsReady)
     {
         if (RoundEnden)
         {
             NewRound();
             return;
         }
         Players[0].IsReady = Players[1].IsReady = false;
         Tag = Utily.GetTag();
         if (HorizDirect == 1)
         {
             if (WasherY == 0)
             {
                 WasherY = 1;
             }
             else
             {
                 WasherY--;
             }
             if (WasherX == 0 && WasherY == 0)
             {
                 NowDirect = 0;
             }
             if (WasherX == 7 && WasherY == 0)
             {
                 NowDirect = 2;
             }
         }
         if (HorizDirect == 3)
         {
             if (WasherY == 2)
             {
                 WasherY = 1;
             }
             else
             {
                 WasherY++;
             }
             if (WasherX == 0 && WasherY == 2)
             {
                 NowDirect = 0;
             }
             if (WasherX == 7 && WasherY == 2)
             {
                 NowDirect = 2;
             }
         }
         HorizDirect = -1;
         while (WasherX >= 0 && WasherX < 8 && (Table[WasherY][WasherX] == null || Table[WasherY][WasherX].Direct == NowDirect))
         {
             if (WasherX == 0 && WasherY != 1 && NowDirect == 2)
             {
                 WasherY   = 1;
                 NowDirect = 0;
             }
             else if (WasherX == 7 && WasherY != 1 && NowDirect == 0)
             {
                 WasherY   = 1;
                 NowDirect = 2;
             }
             else if (NowDirect == 0)
             {
                 WasherX++;
             }
             else
             {
                 WasherX--;
             }
         }
         if (WasherX < 0)
         {
             Players[1].Gool();
             RoundEnden = true;
         }
         else if (WasherX > 7)
         {
             Players[0].Gool();
             RoundEnden = true;
         }
         else
         {
             var NewDir = Table[WasherY][WasherX].Direct;
             Table[WasherY][WasherX].Recive();
             if (Table[WasherY][WasherX].HP == 0)
             {
                 Table[WasherY][WasherX] = null;
             }
             if (NewDir == 1 || NewDir == 3)
             {
                 HorizDirect = NewDir;
             }
             else
             {
                 NowDirect = NewDir;
             }
         }
     }
 }