Skip to content

Commit

Permalink
feat: fill active issue hint
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Jun 30, 2024
1 parent c30d3a0 commit 736ad32
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions pkg/game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"time"

"github.com/jonboulle/clockwork"
"github.com/pkg/errors"
"go.uber.org/zap"
"golang.org/x/exp/slices"

"github.com/six78/2-story-points-cli/internal/transport"
"github.com/six78/2-story-points-cli/pkg/protocol"
"github.com/six78/2-story-points-cli/pkg/storage"
"go.uber.org/zap"
"golang.org/x/exp/slices"
"reflect"
"time"
)

var (
Expand Down Expand Up @@ -187,6 +189,10 @@ func (g *Game) CurrentState() *protocol.State {
}

func (g *Game) notifyChangedState(publish bool) {
if g.state != nil && g.state.VotesRevealed {
g.fillActiveIssueHint()
}

state := g.hiddenCurrentState()

g.logger.Debug("notifying state change",
Expand Down Expand Up @@ -798,3 +804,21 @@ func (g *Game) loadStateFromStorage(roomID protocol.RoomID) *protocol.State {

return state
}

func (g *Game) fillActiveIssueHint() {
if g.state == nil {
return
}

item := g.state.Issues.Get(g.state.ActiveIssue)
if item == nil {
g.logger.Error("failed to fill active issue hint: vote item not found in the vote list")
return
}

var err error
item.Hint, err = GetResultHint(g.state.Deck, item.Votes)
if err != nil {
g.logger.Error("failed to generate hint", zap.Error(err))
}
}

0 comments on commit 736ad32

Please sign in to comment.