Ejemplo n.º 1
0
        public static string RequestSaveDeck(NetworkMessage message)
        {
            string[] args = message.CommandArgs.Split(">".ToCharArray());

            int deckID = int.Parse(args[0]);

            try
            {
                hotEntities he = new hotEntities();

                user u = he.users.First(o => o.Username == message.SendingPlayerName);

                switch (deckID)
                {
                case 0:
                    u.Deck0 = args[1];
                    break;

                case 1:
                    u.Deck1 = args[1];
                    break;

                case 2:
                    u.Deck2 = args[1];
                    break;

                case 3:
                    u.Deck3 = args[1];
                    break;

                case 4:
                    u.Deck4 = args[1];
                    break;

                case 5:
                    u.Deck5 = args[1];
                    break;

                case 6:
                    u.Deck6 = args[1];
                    break;

                case 7:
                    u.Deck7 = args[1];
                    break;

                case 8:
                    u.Deck8 = args[1];
                    break;
                }
                he.SaveChanges();


                return("Success");
            }
            catch (Exception)
            {
                return("Failure");
            }
        }
Ejemplo n.º 2
0
        public static string RequestNewUnitVaultUnit(NetworkMessage message)
        {
            string returnString = "";

            hotEntities he = new hotEntities();

            int           i             = int.Parse(message.CommandArgs);
            unitcatalogue catalogueUnit = he.unitcatalogues.First(o => o.CatalogueID == i);

            unitvault vaultUnit = new unitvault();

            vaultUnit.Abilities             = catalogueUnit.Abilities;
            vaultUnit.CatalogueID           = catalogueUnit.CatalogueID.ToString();
            vaultUnit.Accuracy              = 0.ToString();
            vaultUnit.Attack                = 0.ToString();
            vaultUnit.BludgeoningResistance = 0.ToString();
            vaultUnit.Dodge              = 0.ToString();
            vaultUnit.Experience         = 0;
            vaultUnit.FireResistance     = 0.ToString();
            vaultUnit.HitPoints          = 0.ToString();
            vaultUnit.Level              = 0;
            vaultUnit.Magic              = 0.ToString();
            vaultUnit.MagicResistance    = 0.ToString();
            vaultUnit.MaxAttRange        = 0.ToString();
            vaultUnit.MinAttRange        = 0.ToString();
            vaultUnit.MovementSpeed      = 0.ToString();
            vaultUnit.Owner              = message.SendingPlayerName;
            vaultUnit.PiercingResistance = 0.ToString();
            vaultUnit.SlashResistance    = 0.ToString();

            try
            {
                he.unitvaults.Add(vaultUnit);
                he.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            returnString = vaultUnit.ID.ToString();



            return(returnString);
        }
Ejemplo n.º 3
0
        //Recieves a Signup request from the client.
        //1st queries the database to make sure the username isnt taken
        //if the username isnt taken we insert a new user
        public static string RequestSignup(NetworkMessage message)
        {
            string[] args = message.CommandArgs.Split(">".ToCharArray());
            string   requestedUsername = args[0];
            string   requestedPassword = args[1];

            //initialise database entity

            hotEntities he = new hotEntities();

            try
            {
                user u = he.users.First(a => a.Username == requestedUsername);
                return("Sadly this Username has been taken");
            }
            catch (Exception e)
            {
                user u = new user();
                u.Username = requestedUsername;
                u.Password = requestedPassword;
                u.Rank     = 0;
                u.Gold     = 300;
                u.Dust     = 0;
                u.Deck0    = "";
                u.Deck1    = "";
                u.Deck2    = "";
                u.Deck3    = "";
                u.Deck4    = "";
                u.Deck5    = "";
                u.Deck6    = "";
                u.Deck7    = "";
                u.Deck8    = "";


                he.users.Add(u);

                he.SaveChanges();

                return("Success>" + u.Gold.ToString() + ">" + u.Dust.ToString());
            }
        }