Browse Source

Fix bug in Y handling

master
xyrex 4 years ago
parent
commit
a4cf28de5f
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      main.go

+ 6
- 4
main.go View File

@@ -65,18 +65,19 @@ func main() {
}

func parseLine(text string) bool {
parts := strings.Split(text, " ")
command := strings.Trim(parts[0], "\n")
parts := strings.Split(strings.Trim(text, "\n"), " ")
command := parts[0]

switch command {
case "stars":
// Process stars
for i := 1; i < len(parts)-1; i++ {
idx := 0
for i := 1; i < len(parts); i+=2 {
var x, y int
x, _ = strconv.Atoi(parts[i])
y, _ = strconv.Atoi(parts[i+1])
star := &models.Star{
Idx: i - 1,
Idx: idx,
X: x,
Y: y,
Richness: 0,
@@ -87,6 +88,7 @@ func parseLine(text string) bool {
Turns: -2,
}
stars = append(stars, star)
idx++
}
break
case "star":

Loading…
Cancel
Save