/// <summary>
        /// receive the server return for the list of decks
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void r_GLID(object sender, serverReturnEventArgs e)
        {
            _Server.GLIDReturn -= new EventHandler<serverReturnEventArgs>(r_GLID);
            
            List<Deck> decks = DeckSpliting(e.data);

            if (decks.Count > 0)
            {
                _Server.SDTUReturn += new EventHandler<serverReturnEventArgs>(r_SDTU);
                /*
               * empty the deck list
               */
                Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    deckList.Clear();
                }), null);

                /*
                 * fill the deck list
                 */
                foreach (Deck elem in decks)
                {
                    Application.Current.Dispatcher.Invoke(new Action(delegate()
                    {
                        deckList.Insert(0, elem);
                    }), null);

                    _Server.GetDeck(name, deckList.First().Id);
                }
            }
        }
 void r_ADFR(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         _Server.getFriendList(name);
     }
 }
 void r_GETU(object sender, serverReturnEventArgs e)
 {
     name = VMProfile.getval(e.data, "username");
     _Server.getFriendList(name);
     _Server.getBlackList(name);
     _Server.GETUReturn -= new EventHandler<serverReturnEventArgs>(r_GETU);
 }
 void r_ADBL(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         _Server.getBlackList(name);
     }
 }
 /*
  * receive message from server
  */
 protected void read()
 {
     while (true)
     {
         serverReturnEventArgs ret = this.receive();
         this.eventThrowing(ret);
     }
 }
Beispiel #6
0
        void r_DERO(object sender, serverReturnEventArgs e)
        {
            if (e.data.Contains("OK"))
            {
                MoveToEventArgs args = new MoveToEventArgs("Rooms");
                EventHandler<MoveToEventArgs> handler = this.getMoveTo();

                if (handler != null)
                    handler(this, args);
            }
        }
        /*
         * Throw event depending of the server returns
         */
        private void eventThrowing(serverReturnEventArgs e)
        {
            if (AnyReturn != null)
            {
                AnyReturn(this, e);
            }

            EventHandler <serverReturnEventArgs> eventHandler;

            if (this.eventMappping().TryGetValue(e.func, out eventHandler))
            {
                if (eventHandler != null)
                {
                    eventHandler(this, e);
                }
            }
        }
 void r_MESB(object sender, serverReturnEventArgs e)
 {
     if (e.data.Equals("OK") || e.data.Equals("KO"))
     {
     }
     else
     {
         addContent(e.data);
     }
 }
Beispiel #9
0
 void r_DELE(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         _Server.GetListEvent();
     }
 }
Beispiel #10
0
 void r_GETE(object sender, serverReturnEventArgs e)
 {
     creatorName = VMProfile.getval(e.data, "creator");
     eventName = VMProfile.getval(e.data, "name");
     eventContent = VMProfile.getval(e.data, "description").Replace("<br/>","\n");
     eventDate = VMProfile.getval(e.data, "date");
     eventLocation = VMProfile.getval(e.data, "location");
     if (creatorName.Equals(name))
     {
         creatorRight = Visibility.Visible;
     }
     _Server.isUserSuscribedToEvent(name, eventName);
 }
 void r_SNIE(object sender, serverReturnEventArgs servRet)
 {
     if (servRet.data.Contains("OK"))
     {
         goHome(null);
     }
     else
     {
         errMess = "Error: Event name exists already.";
     }
 }
        void r_CNRO(object sender, serverReturnEventArgs e)
        {
            if (!e.data.Contains("KO"))
            {
                Room created = new Room(int.Parse(e.data), name, Format, RoomName, 0);
                RoomEventArgs rargs = new RoomEventArgs(created);
                if (roomCreation != null)
                    roomCreation(this, rargs);


                MoveToEventArgs args = new MoveToEventArgs("Room");
                EventHandler<MoveToEventArgs> handler = this.getMoveTo();

                if (handler != null)
                    handler(this, args);
            }
        }
Beispiel #13
0
 void r_UPGI(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("healthpoints"))
     {
         HISPV = int.Parse(VMProfile.getval(e.data, "healthpoints"));
     }
 }
Beispiel #14
0
        void r_RSET(object sender, serverReturnEventArgs e)
        {

            Application.Current.Dispatcher.Invoke(new Action(delegate()
                        {
            Deck.Clear();
            Hand.Clear();
            MyBoard.Clear();
            OppBoard.Clear();
            Exile.Clear();
            Grave.Clear();
            MYPV = 20;
            HISPV = 20;
                        }), null);
            MoveToEventArgs args = new MoveToEventArgs("Room");
            EventHandler<MoveToEventArgs> handler = this.getMoveTo();

            if (handler != null)
                handler(this, args);
        }
Beispiel #15
0
        void r_SDTU(object sender, serverReturnEventArgs e)
        {
            _Server.SDTUReturn -= new EventHandler<serverReturnEventArgs>(r_SDTU);

            List<Card> cards = CardSpliting(e.data);

            /*
          * empty the deck
          */
            Application.Current.Dispatcher.Invoke(new Action(delegate()
            {
                Deck.Clear();
            }), null);

            /*
             * fill the deck
             */
            foreach (Card elem in cards)
            {
                //if (!elem.Equals(String.Empty))
                Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    Deck.Insert(0, elem);
                }), null);
            }
            Deck.Shuffle();
            DeckCount = "Deck " + Deck.Count;
        }
Beispiel #16
0
 void r_GLID(object sender, serverReturnEventArgs e)
 {
     _Server.GLIDReturn -= new EventHandler<serverReturnEventArgs>(r_GLID);
     List<Deck> decks = VMDecks.DeckSpliting(e.data);
     if (decks.Count > 0)
     {
         _Server.SDTUReturn += new EventHandler<serverReturnEventArgs>(r_SDTU);
         _Server.GetDeck(name, decks.Last().Id);
     }
     else
     {
         roomChat.addContent("You need at least one deck to play.");
         surrender(null);
     }
 }
 void r_DEBL(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         _Server.getBlackList(name);
     }
     else
     {
         //TODO: in case fail to remove a friend
     }
 }
 void r_GETU(object sender, serverReturnEventArgs e)
 {
     _Server.id = int.Parse(getval(e.data, "id"));
     name = getval(e.data, "username");
     mail = getval(e.data, "email");
     firstName = getval(e.data, "name");
     surName = getval(e.data, "givenname");
     birth = getval(e.data, "birthday");
     location = getval(e.data, "location");
     gender = getval(e.data, "gender");
     phone = getval(e.data, "telephone");
     refresh();
 }
 void r_SETU(object sender, serverReturnEventArgs e)
 {
     String r = e.data;
 }
 void r_GETU(object sender, serverReturnEventArgs e)
 {
     _creatorName = VMProfile.getval(e.data, "username");
     _creatorEmail = VMProfile.getval(e.data, "email");
     _Server.GETUReturn -= new EventHandler<serverReturnEventArgs>(r_GETU);
 }
Beispiel #21
0
        /// <summary>
        /// server return for deck to user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void r_SDTU(object sender, serverReturnEventArgs e)
        {
            _Server.SDTUReturn -= new EventHandler<serverReturnEventArgs>(r_SDTU);

            var idDeck = VMProfile.getval(e.data, "idDeck");
            var deck = deckList.Where(d => d.Id == idDeck).FirstOrDefault();

            List<Card> cards = VMGame.CardSpliting(e.data);

            /*
          * empty the deck
          */
            Application.Current.Dispatcher.Invoke(new Action(delegate()
            {
                deck.Main.Clear();
                deckList.Remove(deck);
            }), null);

            /*
             * fill the deck
             */
            foreach (Card elem in cards)
            {
                Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    deck.Main.Insert(0, elem);
                }), null);
            }

            Application.Current.Dispatcher.Invoke(new Action(delegate()
            {
                deckList.Add(deck);
            }), null);
        }
Beispiel #22
0
 void r_REGU(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
         this.message = "Sign up succed, try to login now.";
     else
         this.message = "Sign up failed.";
 }
Beispiel #23
0
        /* 
         * Throw event depending of the server returns
         */
        private void eventThrowing(serverReturnEventArgs e)
        {
            if (AnyReturn != null)
                AnyReturn(this, e);

            EventHandler<serverReturnEventArgs> eventHandler;
            if (this.eventMappping().TryGetValue(e.func, out eventHandler))
            {
                if (eventHandler != null)
                    eventHandler(this, e);
            }
        }
Beispiel #24
0
        void r_SGNI(object sender, serverReturnEventArgs e)
        {
            if (e.data.Contains("OK"))
            {

                password = "";
                MoveToEventArgs m = new MoveToEventArgs("InnerBoard");
                EventHandler<MoveToEventArgs> handler = this.getMoveTo();

                if (handler != null)
                    handler(this, m);
            }
            else
                this.message = "Log in failed.";
        }
Beispiel #25
0
        void r_GTAL(object sender, serverReturnEventArgs e)
        {
            /*
            * empty the event list
            */
            Application.Current.Dispatcher.Invoke(new Action(delegate()
            {
                eventList.Clear();
            }), null);

            /*
             * fill the event list
             */
            foreach (String elem in e.data.Split('\n'))
            {
                if (!elem.Equals(String.Empty))
                Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    eventList.Insert(0,elem);
                }), null);
            }
        }
Beispiel #26
0
 void r_DERO(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         leaveTheRoom();
     }
 }
Beispiel #27
0
 void r_ISUE(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         signin = false;
     }
     else if (e.data.Contains("KO"))
     {
         signin = true;
     }
 }
Beispiel #28
0
 void r_KILR(object sender, serverReturnEventArgs e)
 {
     leaveTheRoom();
 }
Beispiel #29
0
 void r_SGUE(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("OK"))
     {
         _Server.isUserSuscribedToEvent(name, eventName);
     }
 }
Beispiel #30
0
 void r_PLRO(object sender, serverReturnEventArgs e)
 {
     refreshPlayerList();
 }
 void r_MESP(object sender, serverReturnEventArgs e)
 {
     if (e.data.Equals("OK") || e.data.Equals("KO"))
     {
     }
     else
     {
         Add(e.data.Substring(0, e.data.IndexOf(" ")), e.data);
     }
 }
Beispiel #32
0
 void r_MOVE(object sender, serverReturnEventArgs e)
 {
     if (e.data.Contains("destination"))
     {
         if (VMProfile.getval(e.data, "destination").Equals("Battlefield"))
         {
             string gameId = VMProfile.getval(e.data,"idCard");
             if (OppBoard.Where(c => c.gameId == gameId).Count() == 0)
             {
                 var url = VMProfile.getval(e.data, "url");
                 var x = int.Parse(VMProfile.getval(e.data, "X"));
                 var y = int.Parse(VMProfile.getval(e.data, "Y"));
                 Application.Current.Dispatcher.Invoke(new Action(delegate()
                 {
                     OppBoard.Add(new SimpleCard(url, Location.Battlefield, gameId, x, y));
                 }), null);
             }
             
         }
     }
 }