Fix: bot recovery
This commit is contained in:
		| @@ -248,7 +248,7 @@ func (b *Bot) StartBot() { | ||||
|  | ||||
| // EndBot | ||||
|  | ||||
| func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) { | ||||
| func NewBot(role, team, name, roomID string, cfg *config.Config, recovery bool) (*Bot, error) { | ||||
| 	bot := &Bot{ | ||||
| 		Role:    role, | ||||
| 		RoomID:  roomID, | ||||
| @@ -271,7 +271,7 @@ func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	// check if not running | ||||
| 	if role == "mime" && room.IsRunning { | ||||
| 	if role == "mime" && room.IsRunning && !recovery { | ||||
| 		return nil, errors.New("cannot join after game started") | ||||
| 	} | ||||
| 	room.PlayerList = append(room.PlayerList, name) | ||||
| @@ -282,7 +282,7 @@ func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) { | ||||
| 	// check if already has the same team-role bot | ||||
| 	// only one is allowed | ||||
| 	for n, p := range room.BotMap { | ||||
| 		if p.Role == bp.Role && p.Team == bp.Team { | ||||
| 		if p.Role == bp.Role && p.Team == bp.Team && !recovery { | ||||
| 			return nil, fmt.Errorf("already has such bot with name: %s", n) | ||||
| 		} | ||||
| 	} | ||||
| @@ -292,7 +292,7 @@ func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) { | ||||
| 		if role == "mime" { | ||||
| 			room.RedTeam.Mime = name | ||||
| 		} else if role == "guesser" { | ||||
| 			room.RedTeam.Guessers = append(room.RedTeam.Guessers, name) | ||||
| 			room.RedTeam.Guessers = []string{name} | ||||
| 		} else { | ||||
| 			return nil, fmt.Errorf("uknown role: %s", role) | ||||
| 		} | ||||
| @@ -300,7 +300,7 @@ func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) { | ||||
| 		if role == "mime" { | ||||
| 			room.BlueTeam.Mime = name | ||||
| 		} else if role == "guesser" { | ||||
| 			room.BlueTeam.Guessers = append(room.BlueTeam.Guessers, name) | ||||
| 			room.BlueTeam.Guessers = []string{name} | ||||
| 		} else { | ||||
| 			return nil, fmt.Errorf("uknown role: %s", role) | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder