public ActionResult Create(FormCollection collection)
        {
            try
            {
                string name = collection.Get("campaignname");
                int x = -1;
                int y = -1;

                Int32.TryParse(collection.Get("fieldx"), out x);
                Int32.TryParse(collection.Get("fieldy"), out y);

                // Angemeldeten Spieler hinzufügen
                //PlayerInfo pinfo = data.getPlayerByName(User.Identity.Name);

                CampaignInfo newCampaignInfo = new CampaignInfo()
                {
                    campaignId = "",
                    campaignName = name,
                    FieldDimension = new clsSektorKoordinaten() {X = x, Y = y},
                    ListPlayerInfo = new List<PlayerInfo>() { new PlayerInfo() { playerName = User.Identity.Name } }
                };

                ICampaignController ctrl = data.createNewCampaign(newCampaignInfo);
                //ctrl.CampaignEngine.addPlayer(new Player(pinfo) { });
                //data.safeCampaignState(ctrl.CampaignEngine.getState());

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
예제 #2
0
        //----------------------------------------------------------------------
        protected override void Initialize()
        {
            base.Initialize();

            Program.objCampaignState = new GCML.clsCampaignInfo();

            CampaignInfo cnfo = new CampaignInfo();
            cnfo.campaignName = "test";
            cnfo.FieldDimension = new clsSektorKoordinaten(6, 6, 0) ;
            Program.m_objCampaign = Program.gcmlData.createNewCampaign(cnfo);

            SetWindowTitle("GCML Demo");

            //------------------------------------------------------------------
            Window.AllowUserResizing = true;

            Form.MinimumSize = new System.Drawing.Size(800,600);

            IsMouseVisible = true;

            //------------------------------------------------------------------
            // Game states
            gmsIntro       = new GameStates.GameStateIntro( this );
            gmsMainMenu    = new GameStates.GameStateMainMenu( this );
            GameStateMgr.SwitchState(gmsMainMenu);

            //------------------------------------------------------------------
            Form.Resize += delegate { EnsureProperPresentationParams(); };
        }
예제 #3
0
        public string createNewCampaign(CampaignInfo info)
        {
            CampaignController ctrl = CampaignEngine.createNewCampaign(info);

            //using (var ctx = new GcmlDbContext())
            //{
            //    foreach (PlayerInfo nfo in ctrl.ListPlayers)
            //    {
            //        //ctx.Players.Attach(nfo);
            //        //nfo.Campaigns = new List<CampaignState>();
            //        //nfo.Campaigns.Add(state);
            //        //ctx.Players.AddOrUpdate(nfo);
            //        PlayerInfo p = getPlayer(nfo.playerName);
            //        p.Campaigns.Add(ctrl);
            //        ctx.Entry(nfo).State = EntityState.Modified;
            //        ctx.SaveChanges();

            //    }

            //    ctx.CampaignStates.Add(ctrl);
            //    ctx.SaveChanges();

            //    CampaignState s = ctx.CampaignStates.FirstOrDefault(c => c.CampaignId == ctrl.CampaignId);
            //}

            return ctrl.CampaignEngine.CampaignId;
        }
예제 #4
0
        static void Main(string[] args)
        {
            CampaignRepositorySql da = new CampaignRepositorySql();

            CampaignInfo cinfo = new CampaignInfo()
            {
                campaignId = "",
                campaignName = "test",
                FieldDimension = new clsSektorKoordinaten(6, 6, 0),
                ListPlayerInfo = new List<PlayerInfo>(){ new PlayerInfo(){playerName = "asdf"} }
            };

            CampaignController ctrl = (CampaignController) da.createNewCampaign(cinfo);

            //GcmlDataAccessEF data = new GcmlDataAccessEF();

            //PlayerInfo pinfo = data.getPlayer("test123");

            //data.createNewCampaign(cinfo);

            //GcmlDataAccess.GcmlDataAccessEF accessSqlServer = new GcmlDataAccess.GcmlDataAccessEF();
            //accessSqlServer.safeCampaignState(state);
            //state.ListPlayers.Add(new PlayerInfo() { playerId = "1234", playerName = "asdf" });

            //accessSqlServer.safeCampaignState(state);
        }
        public ActionResult Edit(CampaignInfo cmpinfo)
        {
            try
            {
                ICampaignController ctrl = data.getCampaignController(cmpinfo.campaignId);
                ctrl.CampaignEngine.CampaignName = cmpinfo.campaignName;

                data.safeCampaignState(ctrl);

                return RedirectToAction("Index");
            }
            catch
            {
                return RedirectToAction("Index");
            }
        }
예제 #6
0
        public CampaignInfo Campaign_getInfo()
        {
            CampaignInfo nfo = new CampaignInfo();
            nfo.campaignId = this.CampaignEngine.CampaignId;
            nfo.campaignName = this.CampaignEngine.CampaignName;
            nfo.ListPlayerInfo = this.CampaignEngine.lisPlayers.Select(p => p.getPlayerInfo()).ToList<PlayerInfo>();
            nfo.FieldDimension = this.FieldField.FieldDimension;

            int y = this.FieldField.FieldDimension.Y;
            int x = this.FieldField.FieldDimension.X;
            nfo.SektorField = new SektorInfo[y, x];

            for (int iy = 0; iy < y; iy++)
            {
                for (int jx = 0; jx < x; jx++)
                {
                    var sektor = this.CampaignEngine.FieldField.get(new clsSektorKoordinaten(jx, iy) { });
                    nfo.SektorField[iy, jx] = sektor.getInfo();
                }
            }

            return nfo;
        }
예제 #7
0
        public CampaignInfo getCampaignInfo()
        {
            CampaignInfo nfo = new CampaignInfo();
            nfo.campaignId = this.CampaignKey;
            nfo.campaignName = this.campaignEngine.CampaignName;

            nfo.players = new Dictionary<string, string>();
            foreach (Player p in this.campaignEngine.ListPlayers)
            {
                nfo.players.Add(p.Id, p.Playername);
            }

            return nfo;
        }
예제 #8
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;
        }
예제 #9
0
        /// <summary>
        /// Erzeugt und Konfiguriert ein Mockobjekt für das Repository
        /// incl. Testdaten.
        /// </summary>
        /// <returns></returns>
        private Mock<ICampaignRepository> getGcmlRepository()
        {
            var campaignInfo = new CampaignInfo()
            {
                campaignId = _campaignId,
                campaignName = _campaignName,
                //ListPlayerInfo = fixture.Create<List<PlayerInfo>>(),
                SektorField = new SektorInfo[,]
                {
                    {fixture.Create<SektorInfo>(), fixture.Create<SektorInfo>()},
                    {fixture.Create<SektorInfo>(), fixture.Create<SektorInfo>()}
                },
                ListUnits = new List<UnitInfo>()
                {
                    fixture.Create<UnitInfo>()
                }
            };

            // Testplayer
            _testPlayer = new Player(new PlayerInfo() {playerName = _playername});

            // Mock für CampaignController
            _mockController = kernel.GetMock<ICampaignController>();
            _mockController.Setup(c => c.Player_getByName(_playername)).Returns(_testPlayer);
            _mockController.Setup(c => c.Player_getUnitsForPlayer(_testPlayer)).Returns(new List<clsUnit>()
            {
                 new clsUnit()
                 {
                     Id = fixture.Create<string>()
                 }
            });

            // Mock für CampaignRepository
            _gcmlRepository = kernel.GetMock<ICampaignRepository>();
            _gcmlRepository.Setup(m => m.getCampaignsForPlayer(_playername)).Returns(new List<CampaignInfo>() {campaignInfo});
            _gcmlRepository.Setup(m => m.getCampaignController(_campaignId)).Returns(_mockController.Object);

            return _gcmlRepository;
        }
예제 #10
0
 public ICampaignController createNewCampaign(CampaignInfo info)
 {
     CampaignController controller = CampaignEngine.createNewCampaign(info);
     safeCampaignState(controller);
     return controller;
 }