local SRS = require 'tetris.rulesets.standard' local OSpin = SRS:extend() OSpin.name = "SRS O-Spin" OSpin.hash = "OSpin" OSpin.block_offsets = { I={ { {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} }, { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} }, { {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} }, { {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} }, }, J={ { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} }, { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} }, { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} }, { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} }, }, L={ { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} }, { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} }, { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} }, { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} }, }, O={ { {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} }, { {x=-1, y=0}, {x=-2, y=0}, {x=-2, y=-1}, {x=-1, y=-1} }, { {x=-1, y=-1}, {x=-2, y=-1}, {x=-2, y=-2}, {x=-1, y=-2} }, { {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2}, {x=0, y=-2} }, }, S={ { {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} }, { {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} }, { {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} }, { {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} }, }, T={ { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} }, { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} }, { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} }, { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} }, }, Z={ { {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} }, { {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} }, { {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} }, { {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} }, } } function OSpin:attemptWallkicks(piece, new_piece, rot_dir, grid) local kicks if piece.shape == "I" then kicks = SRS.wallkicks_line[piece.rotation][new_piece.rotation] else kicks = SRS.wallkicks_3x3[piece.rotation][new_piece.rotation] end assert(piece.rotation ~= new_piece.rotation) for idx, offset in pairs(kicks) do kicked_piece = new_piece:withOffset(offset) if grid:canPlacePiece(kicked_piece) then piece:setRelativeRotation(rot_dir) piece:setOffset(offset) self:onPieceRotate(piece, grid) return end end end return OSpin