/// <summary> /// Place the piece in the given orientation at the given x,y position /// </summary> public void PerformPlacePiece(PieceBitmap bitmap, int x, int y) { if (PieceToPlace == null) { throw new Exception("Cannot place a piece when there is none to place"); } if (!PieceToPlace.PossibleOrientations.Contains(bitmap)) { throw new Exception("Given bitmap does not belong to the piece to be placed"); } PlayerBoardState[PieceToPlacePlayer].Place(bitmap, x, y); //Check if they got 7x7 tile if (!SevenXSevenBonusPlayer.HasValue && PlayerBoardState[PieceToPlacePlayer].Has7x7Coverage) { SevenXSevenBonusPlayer = PieceToPlacePlayer; } var piece = PieceToPlace; var player = PieceToPlacePlayer; PieceToPlace = null; PieceToPlacePlayer = -1; PerformPurchasePlaceSteps45(piece, player); Logger.PlayerPlacedPiece(player, piece, x, y, bitmap); }
public bool CanPlace(PieceBitmap bitmap, int x, int y) { #if SAFE_MODE || DEBUG if (x < 0) { throw new Exception("X is outside of range"); } if (y < 0) { throw new Exception("Y is outside of range"); } if (x + bitmap.Width > Width) { throw new Exception("X is outside of range"); } if (y + bitmap.Height > Height) { throw new Exception("Y is outside of range"); } #endif //var shifted = bitmap.Bitmap << (x + y * Width); var shifted = bitmap.GetShifted(x, y); //return (shifted & _state).IsZero; UInt128.And(out shifted, ref shifted, ref _state); return(shifted.IsZero); }
public void Place(PieceBitmap bitmap, int x, int y) { #if SAFE_MODE || DEBUG if (!CanPlace(bitmap, x, y)) { throw new Exception("Cannot place piece here, it overlaps"); } #endif //var shifted = bitmap.Bitmap << (x + y * Width); var shifted = bitmap.GetShifted(x, y); //_state |= shifted; UInt128.Or(out _state, ref _state, ref shifted); }
public PieceDefinition(string name, int buttonCost, int timeCost, int buttonsIncome, string[] bitmap) { Name = name; ButtonCost = buttonCost; TimeCost = timeCost; ButtonsIncome = buttonsIncome; var boolmap = Parse(bitmap); Bitmap = new PieceBitmap(boolmap); TotalUsedLocations = BoolmapOps.SumUsed(boolmap); PossibleOrientations = BoolmapOps.CalculatePossibleOrientations(boolmap).Select(b => new PieceBitmap(b)).ToArray(); Boolmap = boolmap; }