Пример #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Program.objinf = new clsCampaignInfo();

            if (System.IO.File.Exists(".\\CCDate.dat") && MessageBox.Show("laden?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Program.objinf.load();
                Program.m_objCampaign = new CampaignBuilderSchach().restoreFromDb(objinf.strCCKey, objinf.strSaveKey);
                List<Player> listPlayers = Program.m_objCampaign.getPlayerList();
                foreach (Player newP in listPlayers)
                {
                    frmPlayerMainForm frmP = new frmPlayerMainForm();
                    frmP.strMyPlayerID = newP.Id;
                    frmP.button1.Visible = false;
                    frmP.Text = newP.Playername;
                    frmP.Show();
                    lisForms.Add(frmP);
                }

                }
            else
            {
                Program.m_objCampaign = new CampaignBuilderSchach().buildNew();

            }
            Program.m_objCampaign.onStatus += new Field.delStatus(Global_onStatus);

            frmGameMainForm frm = new frmGameMainForm();
            frm.Text = Program.m_objCampaign.CampaignKey;
            Application.Run(frm);
        }
Пример #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 CampaignController getCampaignController(string campaignId)
        {
            CampaignController result = null;
            using (var ctx = new GcmlDbContext())
            {
                var existing = ctx.CampaignStates.FirstOrDefault(c => c.CampaignId == campaignId);
                if (existing != null)
                {
                    CampaignEngine engine = CampaignEngine.restoreFromState(existing);
                    result = new CampaignController(engine);
                }
            }

            return result;
        }
Пример #4
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (MessageBox.Show("Schachbrett?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
            Program.m_objCampaign = new CampaignController(new CampaignEngine(new Field_Schachbrett(5, 5)));
            }
            else
            {
            Program.m_objCampaign = new CampaignController(new CampaignEngine(new Field_Schlauch(8)));
            }

              using (clsProtoClient game = new clsProtoClient())
              {
            game.Run();
              }
        }
Пример #5
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;
        }
Пример #6
0
        public CampaignController getController(string campaignId)
        {
            CampaignController controller;
            if ((!String.IsNullOrEmpty(campaignId)) &&
                (m_dictLoadedController.ContainsKey(campaignId)))
            {
                controller = m_dictLoadedController[campaignId];
            }
            else
            {
                ICampaignDatabase db = m_dictRunningCampaigns[campaignId];
                CampaignState state = db.getLastGameState();
                CampaignEngine engine = CampaignEngine.restoreFromState(state);
                controller = new CampaignController(engine);
                controller.CampaignKey = campaignId;
                controller.CampaignDataBase = db;
                m_dictLoadedController[campaignId] = controller;
            }

            return controller;
        }
Пример #7
0
        public string createNewCampaign(string playerid, string campaignname, clsSektorKoordinaten fielddim, int anzUnitsPerPlayer)
        {
            Player player = getPlayer(playerid);
            if (player == null)
                return "";

            // Datenbank
            ICampaignDatabase database = (ICampaignDatabase)getCampaignDbOrNew("");

            // Spielfeld
            Field field = new Field(fielddim);

            // Engine
            CampaignEngine engine = new CampaignEngine(field);
            engine.CampaignName = campaignname;
            engine.FieldField.Id = 123;
            engine.addPlayer(player);

            CampaignController controller = new CampaignController();
            controller.CampaignDataBase = database;
            controller.campaignEngine = engine;
            controller.CampaignKey = database.CampaignKey;
            controller.saveCurrentGameState();

            m_dictLoadedController[controller.CampaignKey] = controller;
            return database.CampaignKey;
        }
Пример #8
0
        public string createNewCampaign(string playerid, string fielddimension)
        {
            Player player = getPlayer(playerid);
            if (player == null)
                return "";

            // Datenbank
            ICampaignDatabase database = (ICampaignDatabase)getCampaignDbOrNew("");

            // Spielfeld
            Field field = new Field(3, 3);

            // Engine
            CampaignEngine engine = new CampaignEngine(field);
            engine.FieldField.Id = 123;
            engine.addPlayer(player);
            engine.addUnit(player, new clsUnit(new Random().Next(1000, 9999).ToString(), 0), field.getSektorList()[0]);

            CampaignController controller = new CampaignController();
            controller.CampaignDataBase = database;
            controller.campaignEngine = engine;
            controller.CampaignKey = database.CampaignKey;
            controller.saveCurrentGameState();

            m_dictLoadedController[controller.CampaignKey] = controller;
            return database.CampaignKey;
        }
Пример #9
0
        public static CampaignController createNewCampaign(CampaignInfo info)
        {
            string newCampaignId = Guid.NewGuid().ToString();
            info.campaignId = newCampaignId;

            Field field = new Field(info.FieldDimension);
            CampaignEngine engine = new CampaignEngine(field);
            engine.CampaignName = info.campaignName;
            engine.CampaignId = info.campaignId;
            engine.setPlayerList(info.ListPlayerInfo.Select(p => new Player(p)).AsEnumerable());

            CampaignController controller = new CampaignController(engine);
            return controller;
        }
Пример #10
0
        public bool safeCampaignState(CampaignController controller)
        {
            bool result = false;
            CampaignState state = controller.CampaignEngine.getState();

            using (var ctx = new GcmlDbContext())
            {
                //var existing = ctx.CampaignStates.Find(state.CampaignId);
                //if (existing == null)
                //{
                //    ctx.CampaignStates.Add(state);
                //}
                //else
                //{
                //    existing = state;
                //}

                ctx.CampaignStates.AddOrUpdate(state);
                ctx.SaveChanges();
                result = true;
            }
            return result;
        }
Пример #11
0
 private CampaignController getControllerFromStateRow(GcmlData.CampaignStatesRow stateRow)
 {
     CampaignController result;
     string statedata = stateRow.CampaignData;
     CampaignState state = CampaignState.FromString(statedata);
     CampaignEngine engine = CampaignEngine.restoreFromState(state);
     result = new CampaignController(engine);
     return result;
 }