/// <summary> /// Tests if a tile can successfully be removed. /// </summary> public Exception CanRemoveTile(ITile tile, double authority = 0) { if (!tile.IsPlaced) return new InvalidOperationException("Cannot remove an unplaced tile."); Rule<TileMovementArguments> rule; var args = new TileMovementArguments {Space = tile.Space, Tile = tile}; return !TileRemovalRules.CheckAction(args, authority, out rule) ? rule.GetException() : null; }
/// <summary> /// Tests if a tile can successfully be placed. /// </summary> public Exception CanPlaceTile(ITile tile, ISpace space, double authority = 0) { if (tile != null && tile.IsPlaced) return new InvalidOperationException("Cannot place an already placed tile."); if (space.Tile != null) return new InvalidOperationException("Cannot place a tile in an already occupied space."); Rule<TileMovementArguments> rule; var args = new TileMovementArguments {Space = space, Tile = tile}; //ternary is a pain in the ass to debug!!! //return !TilePlacementRules.CheckAction(args, authority, out rule) ? rule.GetException(args) : null; return !TilePlacementRules.CheckAction(args, authority, out rule) ? rule.GetException() : null; }