bump github.com/tribalwarshelp/map-generator, add 'largerMarkers' option to server map generator

This commit is contained in:
Dawid Wysokiński 2020-08-01 13:57:18 +02:00
parent 84ba37ebf0
commit 0779ae4658
5 changed files with 11 additions and 3 deletions

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.9.1
github.com/segmentio/encoding v0.1.14 // indirect
github.com/tribalwarshelp/map-generator v0.0.0-20200801101221-2f88a9f17779
github.com/tribalwarshelp/map-generator v0.0.0-20200801113621-fb8892ceb243
github.com/tribalwarshelp/shared v0.0.0-20200728103702-87e7e5f1b8fd
github.com/vektah/gqlparser/v2 v2.0.1
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208

4
go.sum
View File

@ -187,8 +187,8 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
github.com/tribalwarshelp/map-generator v0.0.0-20200801101221-2f88a9f17779 h1:DMOC8/ACW9bllKtZGOFpY6JPp+IPTXNgC6LyTWEF1+s=
github.com/tribalwarshelp/map-generator v0.0.0-20200801101221-2f88a9f17779/go.mod h1:hVGbToOex7CV5+DAV6QfVMx1XDgp30DOoyOapbr+Vj4=
github.com/tribalwarshelp/map-generator v0.0.0-20200801113621-fb8892ceb243 h1:keKNUTnzglR6bfNiFR7xlXNGrQ4bPG4bgNPq2lv5GBI=
github.com/tribalwarshelp/map-generator v0.0.0-20200801113621-fb8892ceb243/go.mod h1:hVGbToOex7CV5+DAV6QfVMx1XDgp30DOoyOapbr+Vj4=
github.com/tribalwarshelp/shared v0.0.0-20200622084436-3a768c8bf574 h1:y2EoH6zRK9Uc0AeswnJRYUUIQYcSLZB5VDFuxPCKxNM=
github.com/tribalwarshelp/shared v0.0.0-20200622084436-3a768c8bf574/go.mod h1:tf+2yTHasV6jAF3V2deZ9slNoCyBzC0fMdTjI7clf6Y=
github.com/tribalwarshelp/shared v0.0.0-20200728103702-87e7e5f1b8fd h1:AHGZw26jj2uPgFRPLRouFjJJV97Y/p9zLgSW79ZdcVk=

View File

@ -55,6 +55,7 @@ func (h *handler) mapHandler(c *gin.Context) {
Tribes: c.Request.URL.Query()["tribe"],
Players: c.Request.URL.Query()["player"],
ShowBarbarianVillages: c.Query("showBarbarian") == "true",
LargerMarkers: c.Query("largerMarkers") == "true",
ShowOtherPlayerVillages: !(c.Query("onlyMarkers") == "true"),
})
if err != nil {

View File

@ -12,6 +12,7 @@ type GetMarkersConfig struct {
Players []string
ShowBarbarianVillages bool
ShowOtherPlayerVillages bool
LargerMarkers bool
}
type Usecase interface {

View File

@ -3,6 +3,7 @@ package usecase
import (
"context"
"fmt"
"sort"
"strconv"
"strings"
"sync"
@ -140,6 +141,7 @@ func (ucase *usecase) GetMarkers(ctx context.Context, cfg servermap.GetMarkersCo
markers = append(markers, &generator.Marker{
Villages: villages,
Color: c,
Larger: cfg.LargerMarkers,
})
mutex.Unlock()
return nil
@ -165,6 +167,7 @@ func (ucase *usecase) GetMarkers(ctx context.Context, cfg servermap.GetMarkersCo
markers = append(markers, &generator.Marker{
Villages: villages,
Color: c,
Larger: cfg.LargerMarkers,
})
mutex.Unlock()
return nil
@ -172,6 +175,9 @@ func (ucase *usecase) GetMarkers(ctx context.Context, cfg servermap.GetMarkersCo
}
err := g.Wait()
sort.SliceStable(markers, func(i, j int) bool {
return markers[i].Color < markers[j].Color
})
return markers, err
}