mirror of
https://github.com/gabehf/go-battleship.git
synced 2026-04-23 08:01:50 -07:00
fixed some silly mistakes and bugs
This commit is contained in:
parent
0045790ec4
commit
23cc2b374f
4 changed files with 11 additions and 5 deletions
|
|
@ -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++ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue