aboutsummaryrefslogtreecommitdiff
path: root/go/client
diff options
context:
space:
mode:
Diffstat (limited to 'go/client')
-rw-r--r--go/client/game.go8
-rw-r--r--go/client/startMenu.go22
2 files changed, 28 insertions, 2 deletions
diff --git a/go/client/game.go b/go/client/game.go
index 71fa6b4c..fdb72683 100644
--- a/go/client/game.go
+++ b/go/client/game.go
@@ -117,12 +117,16 @@ func (g *Game) loadMap(mapName string) *Game {
log.Fatal(err)
}
g.gameState.SetMap(m)
+ g.initMapUi()
+ return g
+}
+
+func (g *Game) initMapUi() {
g.mapView = ui.NewMapView(g.gameState)
g.AddWidget(g.mapView)
- storeTiles := m.FilterTiles(func(t *game.Tile) bool { return t.Type == game.TileTypes.Store })
+ storeTiles := g.gameState.Map().FilterTiles(func(t *game.Tile) bool { return t.Type == game.TileTypes.Store })
g.storesOnMap = len(storeTiles) > 0
- return g
}
func (g *Game) addActivePlayer(name string, deckList string) *Game {
diff --git a/go/client/startMenu.go b/go/client/startMenu.go
index a9ee5c48..2c3225b9 100644
--- a/go/client/startMenu.go
+++ b/go/client/startMenu.go
@@ -132,6 +132,17 @@ func (m *startMenu) build() {
m.startDeck = deckInput.Text()
m.startGame()
}))
+ m.AddWidget(ui.NewSimpleButton(
+ (m.Width-START_BUTTON_WIDTH)/2,
+ deckInput.Y+deckInput.Height+4*START_BUTTON_HEIGHT,
+ START_BUTTON_WIDTH,
+ START_BUTTON_HEIGHT,
+ "Challenge",
+ func(*ui.SimpleButton) {
+ m.playerName = playerInput.Text()
+ s := game.NewRandomChallenge(m.playerName)
+ m.startChallenge(s)
+ }))
}
func (m *startMenu) Update() error {
@@ -178,3 +189,14 @@ func (m *startMenu) startGame() {
activities.PushActivity(g.Start())
}
+
+func (m *startMenu) startChallenge(state game.State) {
+ g := newGame(m.app, state)
+
+ g.initMapUi()
+ p := state.PlayerByName(m.playerName)
+ g.activePlayerId = p.Id
+ g.initPlayerUi(p)
+
+ activities.PushActivity(g.Start())
+}