public PriorityTablePage()
        {
            InitializeComponent();

            currentPosition = TablePosition.FirstQuadrant;

            listBox1.Items.Add("item1");
            listBox1.Items.Add("item2");
            listBox1.Items.Add("item3");
            listBox1.Items.Add("item4");
            listBox1.Items.Add("item5");

            listBox2.Items.Add("item1");
            listBox2.Items.Add("item2");
            listBox2.Items.Add("item3");
            listBox2.Items.Add("item4");
            listBox2.Items.Add("item5");

            listBox3.Items.Add("item1");
            listBox3.Items.Add("item2");
            listBox3.Items.Add("item3");
            listBox3.Items.Add("item4");
            listBox3.Items.Add("item5");

            listBox4.Items.Add("item1");
            listBox4.Items.Add("item2");
            listBox4.Items.Add("item3");
            listBox4.Items.Add("item4");
            listBox4.Items.Add("item5");
        }
        public async Task <IActionResult> Create(PositionViewModel model)
        {
            if (ModelState.IsValid)
            {
                int TableOrganizations = _context.TableOrganizations.Include(i => i.users).FirstOrDefault
                                             (i => User.Identity.Name == i.users.UserName).TableOrganizationsId;

                TablePosition position = new TablePosition
                {
                    DateOfJobRegistration = DateTime.Now,
                    CountPosition         = model.CountPosition,
                    JobResponsibilities   = model.JobResponsibilities,
                    PositionId            = model.PositionId,
                    TableOrganizationsId  = TableOrganizations,
                };

                _context.TablePosition.Add(position);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                var positions = await _context.Position.ToListAsync();

                model.positions = positions;
                return(View(model));
            }
        }
        public async Task <IActionResult> PutTablePosition(int id, TablePosition tablePosition)
        {
            if (id != tablePosition.TPId)
            {
                return(BadRequest());
            }

            _context.Entry(tablePosition).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TablePositionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <TablePosition> > PostTablePosition(TablePosition tablePosition)
        {
            _context.tablePositions.Add(tablePosition);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTablePosition", new { id = tablePosition.TPId }, tablePosition));
        }
Example #5
0
 public Move(List <Card> movedCards, TablePosition from, TablePosition to, GameState gameSnapshot)
 {
     this.movedCards   = movedCards;
     this.from         = from;
     this.to           = to;
     this.gameSnapshot = gameSnapshot;
 }
Example #6
0
    void OnMouseUp()
    {
        if (PauseMenu.Instance.isPaused)
        {
            return;
        }
        if (flipping)
        {
            return;
        }
        if (isFaceUp == false)
        {
            return;
        }

        if (Input.GetTouch(0).tapCount == 2)
        {
            AutoMoveCard();
            return;
        }

        if (this.cardData.GetZone(CurrGameState) == Zone.Waste)
        {
            if (this.CardAbove != null && this.CardAbove.isFaceUp)
            {
                return; //You can't take cards from the pile if they are not at the top.
            }
        }
        ChangeSortingLayer_Recursive("Default");
        isBeingDragged = false;

        TablePosition dropPosition = SolitaireGraphics.Instance.GetTablePosition(this.transform.position);

        GameManager.Instance.NotifyCardDropped(cardData, dropPosition);
    }
        public ActionResult DeleteConfirmed(int id)
        {
            TablePosition tablePosition = db.TablePositions.Find(id);

            db.TablePositions.Remove(tablePosition);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
 public async Task UpsertAsync(TablePosition tablePositionIn)
 {
     var options = new ReplaceOptions {
         IsUpsert = true
     };
     await _table.ReplaceOneAsync(
         tablePosition => tablePosition.Id == tablePositionIn.Id, tablePositionIn,
         options);
 }
Example #9
0
        public void Test_Check_Default_Positions_Are_0and0_Facing_North()
        {
            Turtle SteadyTurtle = new Turtle();

            TablePosition expected = GetExpectedTablePosition(0, 0, Directions.North);

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
        }
Example #10
0
        private TablePosition GetExpectedTablePosition(int x, int y, Directions direction)
        {
            TablePosition expected = new TablePosition();

            expected.XPosition       = x;
            expected.YPosition       = y;
            expected.FacingDirection = direction;

            return(expected);
        }
Example #11
0
    private void Start()
    {
        _localHuman = tablePositions[3];

        _mRPCErrorEvent ??= new RpcErrorEvent();
        // TODO: Fix for all players
        _mRPCErrorEvent.AddListener(_localHuman.avatar.AnimateShrug);

        _mGameFailedEvent ??= new GameFailedEvent();
        _mGameFailedEvent.AddListener(_localHuman.avatar.AnimateDefeat);
    }
Example #12
0
        internal void Reset(IHtmlParserStatus parser)
        {
            m_Position           = TablePosition.NotInTable;
            m_TableNode          = null;
            m_TableCellNode      = null;
            m_TableRowNode       = null;
            m_CurrTableBlockNode = null;

            m_Parser = parser;
            m_TableContextStack.Clear();
            m_TableContextStack.Push(this);
        }
Example #13
0
        public void Test_Check_Right_Turns_90_Degree_Right_Without_Changing_Position()
        {
            Turtle        SteadyTurtle = new Turtle();
            TablePosition expected     = GetExpectedTablePosition(0, 0, Directions.East);

            SteadyTurtle.Place(0, 0, "North");
            SteadyTurtle.Right();

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
        }
Example #14
0
        public void Test_Check_Move_Forwards_1_Unit_Without_Changing_Direction()
        {
            Turtle        SteadyTurtle = new Turtle();
            TablePosition expected     = GetExpectedTablePosition(0, 1, Directions.North);

            SteadyTurtle.Place(0, 0, "North");
            SteadyTurtle.Move();

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
        }
 public ActionResult Edit([Bind(Include = "IdTablePosition,IdCustomer,IdTable")] TablePosition tablePosition)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tablePosition).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdCustomer = new SelectList(db.Customers, "IdCustomer", "CustomerName", tablePosition.IdCustomer);
     ViewBag.IdTable    = new SelectList(db.Tables, "IdTable", "TableDescription", tablePosition.IdTable);
     return(View(tablePosition));
 }
        // GET: TablePositions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TablePosition tablePosition = db.TablePositions.Find(id);

            if (tablePosition == null)
            {
                return(HttpNotFound());
            }
            return(View(tablePosition));
        }
Example #17
0
        public void Test_Check_Place_Command_Is_The_First_Valid_Command()
        {
            Turtle SteadyTurtle = new Turtle();

            TablePosition expected = GetExpectedTablePosition(0, 0, Directions.North);

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);

            SteadyTurtle.Move();
            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
        }
        // GET: TablePositions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TablePosition tablePosition = db.TablePositions.Find(id);

            if (tablePosition == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdCustomer = new SelectList(db.Customers, "IdCustomer", "CustomerName", tablePosition.IdCustomer);
            ViewBag.IdTable    = new SelectList(db.Tables, "IdTable", "TableDescription", tablePosition.IdTable);
            return(View(tablePosition));
        }
Example #19
0
        public void Test_Check_Place_Places_In_The_Specified_Positions_And_Direction()
        {
            Turtle        SteadyTurtle = new Turtle();
            TablePosition expected     = GetExpectedTablePosition(0, 0, Directions.North);

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);

            expected = GetExpectedTablePosition(3, 4, Directions.East);
            SteadyTurtle.Place(3, 4, "East");

            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id != null)
            {
                TablePosition position = await _context.TablePosition.FirstOrDefaultAsync(p => p.TablePositionId == id);

                if (position != null)
                {
                    _context.TablePosition.Remove(position);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            return(NotFound());
        }
Example #21
0
        public override IEnumerator Place(Vector2[][] map, List <Tile> lst, Action callback, float placeWait)
        {
            var notPlacedLst = new List <Tile>();

            notPlacedLst.AddRange(lst);
            var placedLst = new List <Tile>();

            var rnd = new System.Random();

            Game.Instance.Tplist = TablePosition.GetTablePositions(map);

            foreach (var tp in Game.Instance.Tplist)
            {
                var t = notPlacedLst[rnd.Next(notPlacedLst.Count)];

                t.TablePositionValue = tp;
                tp.GameTile          = t;
                //t.GetComponent<Rigidbody>().isKinematic = true;
                t.gameObject.SetActive(true);
                t.Released           = false;
                t.transform.rotation = new Quaternion(0, 0, 0, 0);

                placedLst.Add(t);
                notPlacedLst.Remove(t);


                if (placeWait == 0)
                {
                    yield return(null);
                }
                else
                {
                    yield return(new WaitForSeconds(placeWait));
                }
            }

            foreach (var tablePosition in Game.Instance.Tplist)
            {
                tablePosition.GameTile.GetAround();
            }

            if (callback != null)
            {
                callback();
            }
        }
        private void OnFlick(object sender, FlickGestureEventArgs e)
        {
            DoubleAnimation da = new DoubleAnimation();
            if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
            {
                da.From = gridTransform.X;
                // flick right
                if (e.HorizontalVelocity < 0 && (currentPosition == TablePosition.FirstQuadrant || currentPosition == TablePosition.ThirdQuadrant))
                {
                    da.To = gridTransform.X - ContentPanel.Width/2;
                    if (currentPosition == TablePosition.FirstQuadrant)
                    {
                        currentPosition = TablePosition.SecondQuadrant;
                    }
                    else
                    {
                        currentPosition = TablePosition.FourthQuadrant;
                    }
                }
                // flick left
                else if (e.HorizontalVelocity > 0 && (currentPosition == TablePosition.SecondQuadrant || currentPosition == TablePosition.FourthQuadrant))
                {
                    da.To = gridTransform.X + ContentPanel.Width/2;
                    if (currentPosition == TablePosition.SecondQuadrant)
                    {
                        currentPosition = TablePosition.FirstQuadrant;
                    }
                    else
                    {
                        currentPosition = TablePosition.ThirdQuadrant;
                    }
                }
                Storyboard.SetTargetProperty(da, new PropertyPath(TranslateTransform.XProperty));
            }
            da.Duration = new Duration(TimeSpan.FromMilliseconds(250));
            Storyboard.SetTarget(da, gridTransform);

            Storyboard sb1 = new Storyboard();
            if (da.To != null)
            {
                sb1.Children.Add(da);
                sb1.Begin();
            }
        }
Example #23
0
        public void Test_Check_Turtle_Is_Prevented_From_Falling_From_Edges()
        {
            Turtle        SteadyTurtle = new Turtle();
            TablePosition expected     = GetExpectedTablePosition(0, 0, Directions.North);

            TablePosition actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);

            expected = GetExpectedTablePosition(5, 3, Directions.East);

            SteadyTurtle.Place(5, 3, "East");
            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(string.Empty, SteadyTurtle.Warning);

            SteadyTurtle.Move();

            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(string.Empty, SteadyTurtle.Warning);

            expected = GetExpectedTablePosition(4, 0, Directions.South);
            SteadyTurtle.Place(4, 0, "South");

            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(string.Empty, SteadyTurtle.Warning);

            SteadyTurtle.Move();

            actual = SteadyTurtle.Report();

            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(string.Empty, SteadyTurtle.Warning);
        }
Example #24
0
 private void Awake()
 {
     TableInstance = this;
 }
Example #25
0
        public override IEnumerator Place(Vector2[][] map, List <Tile> lst, Action callback, float placeWait)
        {
            var notPlacedLst = new List <Tile>();

            notPlacedLst.AddRange(lst);
            var placedLst = new List <Tile>();

            var rnd = new System.Random();

            Game.Instance.Tplist = TablePosition.GetTablePositions(map);

            while (notPlacedLst.Count != 0)
            {
                var t1 = notPlacedLst[rnd.Next(notPlacedLst.Count)];
                var t2 = notPlacedLst.FirstOrDefault(x => x.TyleType.CompareTag == t1.TyleType.CompareTag && x != t1);

                if (t2 == null)
                {
                    continue;
                }

                var freeTps = Game.Instance.Tplist.Where(x => x.IsEdge).ToArray();
                var p1      = freeTps[rnd.Next(freeTps.Length)];
                p1.SetTile(t1);

                t1.TablePositionValue = p1;
                //t1.GetComponent<Rigidbody>().isKinematic = true;
                t1.gameObject.SetActive(true);
                t1.Released           = false;
                t1.transform.rotation = new Quaternion(0, 0, 0, 0);

                freeTps = Game.Instance.Tplist.Where(x => x.IsEdge).ToArray();
                var p2 = freeTps[rnd.Next(freeTps.Length)];
                p2.SetTile(t2);

                t2.TablePositionValue = p2;
                //t2.GetComponent<Rigidbody>().isKinematic = true;
                t2.gameObject.SetActive(true);
                t2.Released           = false;
                t2.transform.rotation = new Quaternion(0, 0, 0, 0);

                placedLst.Add(t1);
                notPlacedLst.Remove(t1);
                placedLst.Add(t2);
                notPlacedLst.Remove(t2);

                if (placeWait == 0)
                {
                    yield return(null);
                }
                else
                {
                    yield return(new WaitForSeconds(placeWait));
                }
            }

            foreach (var tablePosition in Game.Instance.Tplist)
            {
                if (tablePosition.GameTile != null)
                {
                    tablePosition.GameTile.GetAround();
                }
                else
                {
                    Debug.Log(tablePosition.Position);
                }
            }

            if (callback != null)
            {
                callback();
            }
        }
Example #26
0
 public override void SetTablePosition(int x, int y)
 {
     Position = new TablePosition(x, y);
 }
Example #27
0
 public bool Compare(TablePosition p1, TablePosition p2)
 {
     return(!(p1.column == p2.column && p1.row == p2.row));
 }
Example #28
0
        static void Main(string[] args)
        {
            string inputCommand = string.Empty;
            string inputCommandText = "------INPUT------";
            int    xPosition = 0, yPosition = 0;
            string facingDirection = "North";

            Console.WriteLine(inputCommandText);
            Console.WriteLine("Note: Input EXIT to quit the application");
            inputCommand = Console.ReadLine();

            string[] inputCommandParts = inputCommand.Split(' ');

            while (inputCommandParts.Length != 2 || inputCommandParts[0].ToUpper() != "PLACE")
            {
                Console.WriteLine("Initial command needs to be a valid PLACE command (e.g. PLACE 3,4,SOUTH)");
                Console.WriteLine(inputCommandText);
                inputCommand      = Console.ReadLine();
                inputCommandParts = inputCommand.Split(' ');
            }

            string inputCommandSecondPart = inputCommandParts[1];

            string[] inputCommandSecondParts = inputCommandParts[1].Split(',');

            int.TryParse(inputCommandSecondParts[0].Trim(), out xPosition);
            int.TryParse(inputCommandSecondParts[1].Trim(), out yPosition);
            facingDirection = inputCommandSecondParts[2];

            //Due to the deliverable constraint (no other dependences apart from unit test),
            //implementation of DI (Dependency Injection) has been avoided here.
            ITurtle NinjaTurtle = new Turtle();

            NinjaTurtle.Place(xPosition, yPosition, facingDirection);

            inputCommand = Console.ReadLine();

            while (inputCommand.ToUpper() != "EXIT")
            {
                switch (inputCommand.ToUpper())
                {
                case "MOVE":
                    NinjaTurtle.Move();
                    break;

                case "LEFT":
                    NinjaTurtle.Left();
                    break;

                case "RIGHT":
                    NinjaTurtle.Right();
                    break;

                case "REPORT":
                    TablePosition currentPosition = NinjaTurtle.Report();

                    Console.WriteLine("------OUTPUT------");
                    Console.WriteLine("{0},{1},{2}", currentPosition.XPosition, currentPosition.YPosition, currentPosition.FacingDirection.ToString().ToUpper());

                    if (!string.IsNullOrEmpty(NinjaTurtle.Warning))
                    {
                        Console.WriteLine("Warning: {0}", NinjaTurtle.Warning);
                    }

                    break;

                default:
                    break;
                }

                inputCommand = Console.ReadLine();
            }

            Console.WriteLine("------EXITED------");
            Console.ReadLine();
        }
Example #29
0
 public bool Compare(TablePosition p1, TablePosition p2)
 {
     return !(p1.column == p2.column && p1.row == p2.row);
 }
Example #30
0
    public void NotifyCardDropped(Card selectedCard, TablePosition dropPosition)
    {
        bool isValidMove             = false;
        Zone selectedCardZone        = selectedCard.GetZone(gameState);
        int  selectedCardColumnIndex = selectedCard.GetColumn(gameState);

        TablePosition from = new TablePosition(selectedCardZone, selectedCardColumnIndex);

        if (from.zone == dropPosition.zone && from.index == dropPosition.index)
        {
            isValidMove = false;
        }
        else if (dropPosition.zone == Zone.Tableu)
        {
            int        targetColumn     = dropPosition.index;
            CardColumn targetCardColumn = this.Tableu[targetColumn];
            Card       cardToDropOn     = targetCardColumn.faceUpCards.LastOrDefault();

            isValidMove = IsLegal_TableuMove(selectedCard, cardToDropOn);
        }
        else if (dropPosition.zone == Zone.Foundation)
        {
            isValidMove = IsLegal_FoundationMove(selectedCard, FoundationPiles[dropPosition.index]);
        }
        else
        {
            //Card was dropped on the upper part of the table, between foundation piles and deckPile, or on the same column as it started
            isValidMove = false;
        }

        if (isValidMove)
        {
            List <Card> cardsBeingMoved = new List <Card>();
            cardsBeingMoved.Add(selectedCard);
            //If the moved card comes from the tableu, there might other cards above that need to be moved as well.
            //This doens't happen for moves where the selected card comes from foundation piles, stock pile or waste pile.

            if (selectedCardZone == Zone.Tableu)
            {
                cardsBeingMoved.AddRange(this.Tableu[selectedCardColumnIndex].faceUpCards.SkipWhile(c => c != selectedCard).Skip(1));
            }
            GameState snapshot = gameState.Clone() as GameState;
            Move      move     = new Move(cardsBeingMoved, from, dropPosition, snapshot);
            //Notify subscribers
            foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances)
            {
                subscribedHandler.NotifyLegalMove(move);
            }
            //Store move in history
            Debug.Log("Legal move");
            //Update Game data
            ExecuteMove(move);
            movesHistory.Push(move);
        }
        else
        {
            IllegalMove move = new IllegalMove(selectedCard);
            //Notify subscribers
            foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances)
            {
                subscribedHandler.NotifyIllegalMove(move);
            }
            Debug.Log("Illegal move");
        }
    }