예제 #1
0
        private void init()
        {
#if USENOSQL
            string playerdbfile = Path.Combine(STOREPATH, PLAYER_DB);
            string campaigndbfile = Path.Combine(STOREPATH, CAMPAIGN_DB);

            m_playerDb = RaptorDB<string>.Open(playerdbfile, false);
            m_campaignDb = RaptorDB<string>.Open(campaigndbfile, true);

            if (m_campaignDb.Count() > 0)
            {
                for (int i = 0; i < m_campaignDb.Count(); i++)
                {
                    string campaignStr = m_campaignDb.FetchRecordString(i);
                    string campaignKey = campaignStr.Split('#')[0];
                    string dbfilepath = campaignStr.Split('#')[1];

                    CampaignDatabaseRaptorDb db = new CampaignDatabaseRaptorDb();
                    db.CampaignKey = campaignKey;
                    db.StorePath = dbfilepath;
                    db.init();

                    m_dictRunningCampaigns.Add(campaignKey, (ICampaignDatabase)db);
                }
            }
#endif

        }
예제 #2
0
        public override CampaignController restoreFromDb(string campaignKey, string stateKey)
        {
            CampaignDatabaseRaptorDb database = new CampaignDatabaseRaptorDb();
            database.CampaignKey = campaignKey;
            database.StorePath = Environment.CurrentDirectory;
            database.init();

            CampaignState state = database.getCampaignStateByKey(stateKey);
            CampaignEngine engine = CampaignEngine.restoreFromState(state);
            CampaignController controller = new CampaignController(engine);
            controller.CampaignKey = campaignKey;
            controller.CampaignDataBase = database;
            return controller;
        }
예제 #3
0
        public override CampaignController buildNew()
        {
            string campaignkey = Guid.NewGuid().ToString();
            string storepath = Environment.CurrentDirectory;

            CampaignDatabaseRaptorDb database = new CampaignDatabaseRaptorDb();
            database.CampaignKey = campaignkey;
            database.StorePath = storepath;
            database.init();

            CampaignEngine engine = new CampaignEngine(new Field(5, 5));
            engine.FieldField.Id = 123;

            CampaignController controller = new CampaignController();
            controller.CampaignDataBase = database;
            controller.campaignEngine = engine;
            controller.CampaignKey = campaignkey;
            return controller;
        }
예제 #4
0
        private ICampaignDatabase getCampaignDbOrNew(string campaignId)
        {
            ICampaignDatabase result = null;
            if (!m_dictRunningCampaigns.ContainsKey(campaignId) || String.IsNullOrEmpty(campaignId))
            {
#if USENOSQL
                CampaignDatabaseRaptorDb rdb = new CampaignDatabaseRaptorDb();
                rdb.CampaignKey = Guid.NewGuid().ToString();
                rdb.StorePath = STOREPATH;
                rdb.init();
                result = rdb;

#else
#endif

                m_dictRunningCampaigns.Add(result.CampaignKey, result);
                m_campaignDb.Set(result.CampaignKey, result.CampaignKey + "#" + STOREPATH);
                m_campaignDb.SaveIndex();
            }
            else
            {
                result = (ICampaignDatabase)m_dictRunningCampaigns[campaignId];
            }

            return result;
        }