public static Alliance CreateAlliance()
        {
            Alliance alliance;

            var seed = m_vAllianceSeed;

            alliance = new Alliance(seed);
            m_vAllianceSeed++;

            DatabaseManager.Instance.CreateAlliance(alliance);

            ResourcesManager.AddAllianceInMemory(alliance);
            return(alliance);
        }
        public static Alliance CreateAlliance(long seed)
        {
            Alliance alliance;

            if (seed == 0)
            {
                seed = m_vAllianceSeed;
            }
            alliance = new Alliance(seed);
            m_vAllianceSeed++;
            m_vDatabase.CreateAlliance(alliance);
            ResourcesManager.AddAllianceInMemory(alliance);
            return(alliance);
        }
        public static Alliance GetAlliance(long allianceId)
        {
            var alliance = default(Alliance);

            // Try to get alliance from memory first then db.
            // Could be improved.
            if (ResourcesManager.InMemoryAlliancesContain(allianceId))
            {
                return(ResourcesManager.GetInMemoryAlliance(allianceId));
            }

            alliance = DatabaseManager.Instance.GetAlliance(allianceId);

            if (alliance != null)
            {
                ResourcesManager.AddAllianceInMemory(alliance);
            }

            return(alliance);
        }
Example #4
0
        public static Alliance GetAlliance(long allianceId)
        {
            Alliance alliance;

            if (ResourcesManager.InMemoryAlliancesContain(allianceId))
            {
                return(ResourcesManager.GetInMemoryAlliance(allianceId));
            }
            var alliancedb = m_vDatabase.GetAlliance(allianceId);

            alliancedb.Wait();

            alliance = alliancedb.Result;
            if (alliance != null)
            {
                ResourcesManager.AddAllianceInMemory(alliance);
                return(alliance);
            }
            return(null);
        }
Example #5
0
        /*public static void LoadAllAlliancesFromDB()
         * {
         *  ResourcesManager.AddAllianceInMemory(m_vDatabase.GetAllAlliances());
         * }*/

        public static Alliance GetAlliance(long allianceId)
        {
            Alliance alliance;

            if (ResourcesManager.InMemoryAlliancesContain(allianceId))
            {
                return(ResourcesManager.GetInMemoryAlliance(allianceId));
            }
            else
            {
                alliance = m_vDatabase.GetAlliance(allianceId);
                if (alliance != null)
                {
                    ResourcesManager.AddAllianceInMemory(alliance);
                }
                else
                {
                    return(null);
                }
                return(alliance);
            }
        }
Example #6
0
 public static void Load100AlliancesFromDB()
 {
     ResourcesManager.AddAllianceInMemory(m_vDatabase.Get100Alliances());
 }