fixed some silly mistakes and bugs

This commit is contained in:
gabe farrell 2022-02-21 00:23:12 -05:00
parent 0045790ec4
commit 23cc2b374f
4 changed files with 11 additions and 5 deletions

View file

@ -173,7 +173,7 @@ func (b Board) shipExistsAt(coords []Point) bool {
func (b *Board) PlaceShip(s Ship, p Point, vertical bool) (Ship, error) {
switch vertical {
case true:
if p.Row+rune(s.Length) > 'j' {
if p.Row+rune(s.Length-1) > 'j' {
break
}
for i := 0; i < s.Length; i++ {
@ -189,7 +189,7 @@ func (b *Board) PlaceShip(s Ship, p Point, vertical bool) (Ship, error) {
}
return s, nil
case false:
if p.Col+s.Length > 10 {
if p.Col+s.Length-1 > 10 {
break
}
for i := 0; i < s.Length; i++ {