Skip to content

Commit

Permalink
light refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
deanrad committed Aug 11, 2008
1 parent 2876a6e commit 7a5a092
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions trunk/app/models/board.rb
Expand Up @@ -134,13 +134,10 @@ def diagonal_piece_is_attacking_king(side, king_position)
next unless self[square]

#otherwise see if validly attacked
if self[square].side != side and [:queen, :bishop].include?( self[square].role )
#we found an attacker
return true
else
#it was a blocker - ignore the rest of this line
break
end
return true if self[square].side != side and [:queen, :bishop].include?( self[square].role )
#or blocker - ignore the rest of this line
break

end
end
false
Expand All @@ -158,13 +155,10 @@ def straight_piece_is_attacking_king(side, king_position)
next unless self[square]

#otherwise see if validly attacked
if self[square].side != side and [:queen, :rook].include?( self[square].role )
#we found an attacker
return true
else
#it was a blocker - ignore the rest of this line
break
end
return true if self[square].side != side and [:queen, :rook].include?( self[square].role )

#or blocker - ignore the rest of this line
break
end
end
false
Expand Down

0 comments on commit 7a5a092

Please sign in to comment.