public AdminRestrictionsWindow(ITileBinder iTileBinder)
        {
            Console.WriteLine("Init");
            _savedGameObjects = iTileBinder.AvailableObjects;
            InitializeComponent();
            _budget          = iTileBinder.AvailableFounds;
            _savedBudget     = iTileBinder.AvailableFounds;
            AdminBudget.Text = _budget.ToString();
            _allGameObjects  = new AdminGridObjectsCreator(
                InitializeGameObjects(),
                false,
                AllGameObjectsGrid,
                this
                );

            _availableForUserGameObjects = new AdminGridObjectsCreator(
                _savedGameObjects.ToArray(),
                true,
                AvailableForUserGameObjectsGrid,
                this
                );
            HideSelectedObjects(_savedGameObjects);
            _availableForUserGameObjects.InitializeGridDefinitions();
            _availableForUserGameObjects.CreateGrid();
            _allGameObjects.InitializeGridDefinitions();
            _allGameObjects.CreateGridWithCategoryBreaks(GetCategoryBreakLineIndex());
            _objectDetails = new AdminSelectedObjectDetails(SelectedGameObjectDetails, this);
            OnObjectClick(_allGameObjects.GameObjectsList[0]);
        }
Esempio n. 2
0
 // Serialization
 public static void JsonAddBasicData(JObject jsonMap, ITileBinder tileBinder, string name)
 {
     jsonMap["AuthorID"]       = tileBinder.Credentials.UserID;
     jsonMap["Name"]           = name;
     jsonMap["Size"]           = tileBinder.TileGrid.GetLength(0);
     jsonMap["AvailableMoney"] = tileBinder.AvailableFounds;
 }
Esempio n. 3
0
        public void SaveGame(ITileBinder tileBinder, int mapID, out int gameId)
        {
            if (Choice == "")
            {
                throw new Exception("Name cannot be empty.");
            }

            JObject jsonGame = new JObject();

            SerializationHelper.JsonAddPlacements(jsonGame, tileBinder.PlacedObjects);

            int result = db.CheckGameNameOccupation(Choice, Credentials.UserID);

            if (result == 0)
            {
                result = db.addGame(Credentials.UserID, Choice, jsonGame.ToString(Formatting.None), mapID, Publish);
            }
            else
            {
                result = db.updateGame(Credentials.UserID, jsonGame.ToString(Formatting.None), Choice, mapID, Publish);
            }

            Choice   = "";
            ChoiceId = -1;
            SaveGameCheckBox.IsChecked = false;
            Publish = false;

            if (result == 1)
            {
                throw new Exception("Wystąpił problem przy zapisie gry.");
            }

            gameId = result;
        }
Esempio n. 4
0
 public Selection(TileObject tileObject, ITileBinder binder)
 {
     Binder          = binder;
     TileObject      = tileObject;
     SelectionState  = State.Place;
     ChangedPlacers  = new LinkedList <Placer>();
     Operators       = new IOperator[] { new PlaceOperator(this), new DeleteOperator(this), new BlockOperator(this) };
     CurrentOperator = Operators[0];
     if (IsUserWindow())
     {
         ((UserGameWindow)Binder).CurrentCash.Foreground = Brushes.Azure;
     }
 }
Esempio n. 5
0
        public void SaveMap(ITileBinder tileBinder)
        {
            if (Choice == "")
            {
                throw new Exception("Name cannot be empty.");
            }

            JObject jsonMap = new JObject();

            SerializationHelper.JsonAddBasicData(jsonMap, tileBinder, Choice);
            SerializationHelper.JsonAddTileGridAndDictionary(jsonMap, tileBinder.TileGrid);
            SerializationHelper.JsonAddPlacements(jsonMap, tileBinder.PlacedObjects);
            SerializationHelper.JsonAddAvailableTiles(jsonMap, tileBinder.AvailableObjects);

            BazaDanych db = new BazaDanych();

            int result;

            if (Publish)
            {
                result = db.CheckPublishedMapNameOccupation(Choice, Credentials.UserID);

                if (result == 0)
                {
                    result = db.DodajMape(Credentials.UserID, Choice, jsonMap.ToString(Formatting.None), true);
                }
            }
            else
            {
                result = db.CheckMapNameOccupation(Choice, Credentials.UserID);

                if (result == 0)
                {
                    result = db.DodajMape(Credentials.UserID, Choice, jsonMap.ToString(Formatting.None), false);
                }
                else if (result == 33) // Map name is occupied.
                {
                    result = db.updateMap(Credentials.UserID, jsonMap.ToString(Formatting.None), Choice) ? 0 : -1;
                }
            }

            Choice   = "";
            ChoiceId = -1;
            SaveMapCheckBox.IsChecked = false;
            Publish = false;

            if (result != 0)
            {
                throw new Exception("Wystąpił problem przy zapisie mapy.");
            }
        }
Esempio n. 6
0
        // BazaDanych database = BazaDanych.GetBazaDanych();

        public Score(ITileBinder tileBinder, int boardDensity)
        {
            this.simulation = new Simulation(tileBinder, boardDensity);
        }
 public PlacerSelectorGridCreator(ITileBinder binder, List <TileCategory> categories)
 {
     _selectorCreator = new SelectorCreator(binder.Selection, categories);
     _selectorGrid    = binder.SelectorGrid;
     _selectorGrid.HorizontalAlignment = HorizontalAlignment.Center;
 }
Esempio n. 8
0
 public Simulation(ITileBinder tileBinder, int boardDensity)
 {
     ITileBinder  = tileBinder;
     BoardDensity = boardDensity;
 }