Exemplo 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");
            }
        }
        public static void CacheRaces()
        {
            Console.WriteLine("Caching Races..");

            hotEntities he = new hotEntities();

            foreach (race r in he.races)
            {
                CachedRace cr = new CachedRace();

                cr.Accuracy = r.Accuracy;
                cr.Attack   = r.Attack;
                cr.BludgeoningResistance = r.BludgeoningResistance;
                cr.Dodge              = r.Dodge;
                cr.FireResistance     = r.FireResistance;
                cr.HitPoints          = r.HitPoints;
                cr.Magic              = r.Magic;
                cr.MagicResistance    = r.MagicResistance;
                cr.MovementSpeed      = r.MovementSpeed;
                cr.PiercingResistance = r.PiercingResistance;
                cr.SlashResistance    = r.SlashResistance;
                cr.Description        = r.Description;
                cr.Name = r.Name;

                CachedRaces.Add(cr);
            }

            Console.WriteLine("Races Cached: " + CachedRaces.Count.ToString());
        }
Exemplo n.º 3
0
        public static string RequestRaceData()
        {
            string returnString = "";

            hotEntities he    = new hotEntities();
            List <race> races = new List <race>();

            races = he.races.ToList();

            foreach (race r in races)
            {
                returnString = returnString + r.Name + ">";
                returnString = returnString + r.Description + ">";
                returnString = returnString + r.Attack + ">";
                returnString = returnString + r.Dodge + ">";
                returnString = returnString + r.Accuracy + ">";
                returnString = returnString + r.HitPoints + ">";

                returnString = returnString + r.Magic + ">";
                returnString = returnString + r.MovementSpeed + ">";
                returnString = returnString + r.FireResistance + ">";
                returnString = returnString + r.MagicResistance + ">";
                returnString = returnString + r.SlashResistance + ">";
                returnString = returnString + r.PiercingResistance + ">";
                returnString = returnString + r.BludgeoningResistance + "#";
            }



            return(returnString);
        }
Exemplo n.º 4
0
        public static string RequestPlayerData(NetworkMessage message)
        {
            string username = message.CommandArgs;

            hotEntities he = new hotEntities();

            user u = he.users.First(a => a.Username == username);

            string returnString = "";

            returnString = returnString + u.Gold.ToString() + ",";
            returnString = returnString + u.Dust.ToString() + ",";
            returnString = returnString + u.Rank.ToString() + ",";
            returnString = returnString + u.Deck0.ToString() + ",";
            returnString = returnString + u.Deck1.ToString() + ",";
            returnString = returnString + u.Deck2.ToString() + ",";
            returnString = returnString + u.Deck3.ToString() + ",";
            returnString = returnString + u.Deck4.ToString() + ",";
            returnString = returnString + u.Deck5.ToString() + ",";
            returnString = returnString + u.Deck6.ToString() + ",";
            returnString = returnString + u.Deck7.ToString() + ",";
            returnString = returnString + u.Deck8.ToString();


            return(returnString);
        }
Exemplo n.º 5
0
        public static Agent CreateAgentFromVaultUnit(int id)
        {
            Agent agent = new Agent();

            hotEntities he = new hotEntities();


            unitvault uv = he.unitvaults.First(a => a.ID == id);

            CachedCatalogueUnit cachedUnit = CachedObjectContainer.GetCachedCatUnitByID(int.Parse(uv.CatalogueID));

            CachedRace cachedRace = CachedObjectContainer.GetCachedRaceByName(cachedUnit.Race);


            agent.ID                        = uv.ID;
            agent.CATID                     = cachedUnit.CatalogueID;
            agent.Name                      = cachedUnit.Name;
            agent.UnitType                  = cachedUnit.UnitType;
            agent.Faction                   = cachedUnit.Faction;
            agent.Rarity                    = cachedUnit.Rarity;
            agent.Collection                = cachedUnit.Collection;
            agent.Race                      = cachedUnit.Race;
            agent.DamageType                = cachedUnit.DamageType;
            agent.BaseAttack                = cachedUnit.Attack + int.Parse(uv.Attack) + cachedRace.Attack;
            agent.BaseAccuracy              = cachedUnit.Accuracy + int.Parse(uv.Accuracy) + cachedRace.Accuracy;
            agent.BaseDodge                 = cachedUnit.Dodge + int.Parse(uv.Dodge) + cachedRace.Dodge;
            agent.BaseHitPoints             = cachedUnit.HitPoints + int.Parse(uv.HitPoints) + cachedRace.HitPoints;
            agent.BaseMagic                 = cachedUnit.Magic + int.Parse(uv.Magic) + cachedRace.Magic;
            agent.BaseMagicResistance       = cachedUnit.MagicResistance + int.Parse(uv.MagicResistance) + cachedRace.MagicResistance;
            agent.BaseFireResistance        = cachedUnit.FireResistance + int.Parse(uv.FireResistance) + cachedRace.FireResistance;
            agent.BaseSlashResistance       = cachedUnit.SlashResistance + int.Parse(uv.SlashResistance) + cachedRace.SlashResistance;
            agent.BasePiercingResistance    = cachedUnit.PiercingResistance + int.Parse(uv.PiercingResistance) + cachedRace.PiercingResistance;
            agent.BaseBludgeoningResistance = cachedUnit.BludgeoningResistance + int.Parse(uv.BludgeoningResistance) + cachedRace.BludgeoningResistance;
            agent.BaseMovementSpeed         = cachedUnit.MovementSpeed + int.Parse(uv.MovementSpeed) + cachedRace.MovementSpeed;
            agent.BaseMinAttackRange        = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange);
            agent.BaseMaxAttackRange        = cachedUnit.MaxAttackRange + int.Parse(uv.MaxAttRange);
            agent.BaseMinAttackRange        = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange);
            agent.BaseMinAttackRange        = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange);
            agent.Level                     = uv.Level;
            agent.Owner                     = uv.Owner;
            //players team id
            //hex to spawn on
            // agent.Abilities = uv.Abilities;
            string returnString = "";


            //               unit.iLevel.ToString().ToString() + ">" +
            //               NetworkManager.Instance.cPlayer.sName + ">" +
            //               GameManager.Instance.GetPlayersTeamID().ToString() + ">" +
            //               hex.gameObject.name + ">" +
            //               unit.Abilities;



            return(agent);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public static string RequestUsersUnits(NetworkMessage message)
        {
            string returnString = "";

            hotEntities he = new hotEntities();

            List <unitvault> vaultUnits = new List <unitvault>();

            vaultUnits = he.unitvaults.ToList();

            List <unitvault> myUnits = new List <unitvault>();

            foreach (unitvault vaultUnit in vaultUnits)
            {
                if (vaultUnit.Owner == message.CommandArgs)
                {
                    myUnits.Add(vaultUnit);
                }
            }

            foreach (unitvault myUnit in myUnits)
            {
                returnString = returnString + myUnit.ID + ",";
                returnString = returnString + myUnit.CatalogueID + ",0,";
                returnString = returnString + myUnit.Attack + ",";
                returnString = returnString + myUnit.Accuracy + ",";
                returnString = returnString + myUnit.Dodge + ",";

                returnString = returnString + myUnit.HitPoints + ",";
                returnString = returnString + myUnit.MovementSpeed + ",";
                returnString = returnString + myUnit.Magic + ",";
                returnString = returnString + myUnit.MagicResistance + ",";
                returnString = returnString + myUnit.FireResistance + ",";
                returnString = returnString + myUnit.PiercingResistance + ",";
                returnString = returnString + myUnit.SlashResistance + ",";
                returnString = returnString + myUnit.BludgeoningResistance + ",0 ,0 ,";
                returnString = returnString + myUnit.Experience + ",";
                returnString = returnString + myUnit.Level + ",";
                returnString = returnString + myUnit.Abilities + "#";
            }


            return(returnString);
        }
Exemplo n.º 8
0
        public static string RequestMapMetaData()
        {
            List <mapmetadata> mapMetas = new List <mapmetadata>();

            hotEntities he = new hotEntities();

            mapMetas = he.mapmetadatas.ToList();

            string returnString = "";

            foreach (mapmetadata mapMeta in mapMetas)
            {
                returnString = returnString + mapMeta.Name + ",";
                returnString = returnString + mapMeta.Expansion + ",";
                returnString = returnString + mapMeta.PlayerCount.ToString() + ",";
                returnString = returnString + mapMeta.MapType + "#";
            }

            return(returnString);
        }
        public static void CacheCatalogueUnits()
        {
            Console.WriteLine("Caching Catalogue Units...");
            hotEntities he = new hotEntities();

            foreach (unitcatalogue uc in he.unitcatalogues)

            {
                CachedCatalogueUnit ccu = new CachedCatalogueUnit();

                ccu.CatalogueID = uc.CatalogueID;
                ccu.Name        = uc.Name;
                ccu.UnitType    = uc.UnitType;
                ccu.Faction     = uc.Faction;
                ccu.Rarity      = uc.Rarity;
                ccu.Collection  = uc.Collection;
                ccu.Race        = uc.Race;

                ccu.DamageType            = uc.DamageType;
                ccu.Attack                = int.Parse(uc.Attack);
                ccu.Accuracy              = uc.Accuracy;
                ccu.Dodge                 = uc.Dodge;
                ccu.HitPoints             = uc.HitPoints;
                ccu.MovementSpeed         = int.Parse(uc.MovementSpeed);
                ccu.Magic                 = uc.Magic;
                ccu.MagicResistance       = uc.MagicResistance;
                ccu.FireResistance        = uc.FireResistance;
                ccu.SlashResistance       = uc.SlashResistance;
                ccu.PiercingResistance    = uc.PiercingResistance;
                ccu.BludgeoningResistance = uc.BludgeoningResistance;
                ccu.MinAttackRange        = int.Parse(uc.MinAttackRange);
                ccu.MaxAttackRange        = int.Parse(uc.MaxAttackRange);
                ccu.Abilities             = uc.Abilities;
                ccu.Artist                = uc.Artist;
                ccu.FlavourText           = uc.FlavourText;

                CachedCatalogueUnits.Add(ccu);
            }

            Console.WriteLine("Catalogue Units cached: " + CachedCatalogueUnits.Count.ToString());
        }
Exemplo n.º 10
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());
            }
        }
Exemplo n.º 11
0
        public static string RequestUnitCatalogue()
        {
            string returnString = "";

            hotEntities he = new hotEntities();

            List <unitcatalogue> catalogueUnits = new List <unitcatalogue>();

            catalogueUnits = he.unitcatalogues.ToList();

            foreach (unitcatalogue curUnit in catalogueUnits)
            {
                returnString = returnString + curUnit.CatalogueID + ">";
                returnString = returnString + curUnit.Name + ">";
                returnString = returnString + curUnit.UnitType + ">";
                returnString = returnString + curUnit.Faction + ">";
                returnString = returnString + curUnit.Rarity + ">";
                returnString = returnString + curUnit.Collection + ">";
                returnString = returnString + curUnit.Race + ">";
                returnString = returnString + curUnit.DamageType + ">";
                returnString = returnString + curUnit.Attack + ">";
                returnString = returnString + curUnit.Accuracy + ">";
                returnString = returnString + curUnit.Dodge.ToString() + ">";
                returnString = returnString + curUnit.HitPoints.ToString() + ">";
                returnString = returnString + curUnit.MovementSpeed + ">";
                returnString = returnString + curUnit.Magic + ">";
                returnString = returnString + curUnit.MagicResistance + ">";
                returnString = returnString + curUnit.FireResistance + ">";
                returnString = returnString + curUnit.SlashResistance + ">";
                returnString = returnString + curUnit.PiercingResistance + ">";
                returnString = returnString + curUnit.BludgeoningResistance + ">";
                returnString = returnString + curUnit.MinAttackRange + ">";
                returnString = returnString + curUnit.MaxAttackRange + ">";
                returnString = returnString + curUnit.Abilities + ">";
                returnString = returnString + curUnit.Artist + ">";
                returnString = returnString + curUnit.FlavourText + "@";
            }

            return(returnString);
        }
Exemplo n.º 12
0
        //Recieves a Login request from the client. Queries the database
        //to 1: check the user exists , 2: check the password.
        //Then we tell the client if we were successfull or not
        public static string RequestLogin(NetworkMessage message)
        {
            //First split relevant details out of the 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);

                if (u != null)
                {
                    if (u.Password == requestedPassword)
                    {
                        return("Success");
                    }
                    else
                    {
                        return("Invalid Password");
                    }
                }
                else
                {
                    return("Invalid Username");
                }
            }
            catch (Exception e)
            {
                return("Invalid Username");
            }
        }
Exemplo n.º 13
0
        public void LoadAgents()
        {
            List <UnitSpawnPoint> spawnPoints = new List <UnitSpawnPoint>();

            foreach (UnitSpawnPoint sp in myRoom.RoomMap.SpawnPoints)
            {
                if (sp.iPlayerTeamId == myRoom.Players.Count - 1)
                {
                    spawnPoints.Add(sp);
                }
            }

            hotEntities he = new hotEntities();

            List <int> idsToLoad = new List <int>();

            user   user       = he.users.First(o => o.Username == Name);
            string deckString = "";

            switch (SelectedDeckIndex)
            {
            case (0):
                deckString = user.Deck0;
                break;

            case (1):
                deckString = user.Deck1;
                break;

            case (2):
                deckString = user.Deck2;
                break;

            case (3):
                deckString = user.Deck3;
                break;

            case (4):
                deckString = user.Deck4;
                break;

            case (5):
                deckString = user.Deck5;
                break;

            case (6):
                deckString = user.Deck6;
                break;

            case (7):
                deckString = user.Deck7;
                break;

            case (8):
                deckString = user.Deck8;
                break;
            }
            string[] deckArgs = deckString.Split("(".ToCharArray());

            string[] idArgs = deckArgs[3].Split("*".ToCharArray());

            foreach (string s in idArgs)
            {
                if (s != "")
                {
                    idsToLoad.Add(int.Parse(s));
                }
            }
        }