public bool validateDistance(Square start, Square end, int distance) { int x = 0, y = 0; int startx = 0, starty = 0; int endx = 0, endy = 0; foreach (var list in board) { foreach (var item in list) { if (item == start) { startx = x; starty = y; } if (item == end) { endx = x; endy = y; } y++; } y = 0; x++; } //needs work, on the logic here if (endx - startx + endy - starty == distance) { return true; } return false; }
public SquareButton(Square pS) : base() { Visible = true; parentSquare = pS; //BackColor = Color.Transparent; }
public void SquareTest() { Square testSquare = new Square(); testSquare.IsOccupied(); testSquare.occupied(); testSquare.occupiedBy(); testSquare.ownerPlayer(); testSquare.highlighted(); testSquare.SetOccupied(); }
public void SquareButtonPressed(object sender, EventArgs e) { var curSquareButton = (SquareButton)sender; var squarePressed = curSquareButton.parentSquare; if (prevCard == null) return; if (prevSquarePressed == null) { if (squarePressed.IsOccupied() != null && squarePressed.IsOccupied().ownerPlayer == currentPlayerTurn) { prevSquarePressed = squarePressed; } } else { //logic comes in to play // we now need to validate the move switch (prevCard.cardVal) { case Card.VALUE.One: if (prevSquarePressed.type == SquareType.Start) { if (board.validateDistance(prevSquarePressed, squarePressed, 1)) { squarePressed.SetOccupied(prevSquarePressed.IsOccupied()); prevSquarePressed.SetOccupied(null); } } break; case Card.VALUE.TWO: break; case Card.VALUE.THREE: break; case Card.VALUE.FOUR: break; case Card.VALUE.FIVE: break; case Card.VALUE.SEVEN: break; case Card.VALUE.EIGHT: break; case Card.VALUE.TEN: break; case Card.VALUE.ELEVEN: break; case Card.VALUE.TWELVE: break; case Card.VALUE.SORRY: break; } } panel.Render(); }
public void SquareTest() { Square testSquare = new Square(); testSquare.IsOccupied(); //testSquare.SetOccupied(); }