// Code generated by testifylint/internal/testgen. DO NOT EDIT.

package suitethelper

import (
	"testing"

	"github.com/stretchr/testify/suite"
)

type GameRoomSuite struct {
	suite.Suite

	rooms   map[int]*Room
	players map[int]*Player
}

func TestGameRoomSuite(t *testing.T) {
	suite.Run(t, &GameRoomSuite{
		rooms:   map[int]*Room{},
		players: map[int]*Player{},
	})
}

func (s *GameRoomSuite) SetupTest() {
	s.Require().Empty(s.rooms)
	s.Require().Empty(s.players)
}

func (s *GameRoomSuite) TearDownTest() {
	s.rooms = map[int]*Room{}
	s.players = map[int]*Player{}
}

func (s *GameRoomSuite) TestJoinRoom() {
	p := s.newPlayer(100, "DoomGuy")
	r := s.newRoom(200)
	s.joinRoom(p.ID, r.ID)
	s.assertPlayerNickName(100, "DoomGuy")
	s.AssertPlayersNumber(200, 1)
}

func (s *GameRoomSuite) newPlayer(id int, nickname string) *Player {
	p := &Player{ID: id, Nickname: nickname}
	s.players[p.ID] = p
	return p
}

func (s *GameRoomSuite) newRoom(id int) *Room {
	r := &Room{ID: id}
	s.rooms[r.ID] = r
	return r
}

func (suite *GameRoomSuite) joinRoom(playerID, roomID int) { // want "suite-thelper: suite helper method must start with suite\\.T\\(\\)\\.Helper\\(\\)"
	room, ok := suite.rooms[roomID]
	suite.Require().True(ok)

	player, ok := suite.players[playerID]
	suite.Require().True(ok)

	err := room.AddPlayer(player)
	suite.Require().NoError(err)
}

func (s *GameRoomSuite) assertPlayerNickName(playerID int, expectedNickname string) {
	s.T().Helper()

	player, ok := s.players[playerID]
	s.Require().True(ok)

	s.Assert().Equal(playerID, player.ID)
	s.Equal(expectedNickname, player.Nickname)
}

func (s *GameRoomSuite) AssertPlayersNumber(roomID int, playersNum int) { // want "suite-thelper: suite helper method must start with s\\.T\\(\\)\\.Helper\\(\\)"
	room, ok := s.rooms[roomID]
	s.Require().True(ok)
	s.Len(room.Players, playersNum)
}

type Player struct {
	ID       int
	Nickname string
}

type Room struct {
	ID      int
	Players []*Player
}

func (r Room) AddPlayer(player *Player) error {
	r.Players = append(r.Players, player)
	return nil
}
