Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set initial game count #635

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/template/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ game:
minGoldPickupThreshold: 500000 # If total gold amount is less than this, bot will pick up and sell magic+ items
clearTPArea: true # Will clear the TP area before clicking it
difficulty: hell # Allowed values: normal, nightmare, hell
initialGameCount: 1 # Initial game number
randomizeRuns: true # Will randomize the order of the runs each game
# Just add the runs you want to do and they will be executed respecting the order, unless randomizeRuns is set to true
# Available runs: countess, andariel, ancient_tunnels, summoner, mephisto, council, eldritch, pindleskin, nihlathak,
Expand Down
3 changes: 3 additions & 0 deletions internal/bot/single_supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ func (s *SinglePlayerSupervisor) HandleOutOfGameFlow() error {
utils.Sleep(1000)
}

// Set PublicGameCounter to the default InitialGameCount
s.bot.ctx.CharacterCfg.Game.PublicGameCounter = s.bot.ctx.CharacterCfg.Game.InitialGameCount

if _, err := s.bot.ctx.Manager.CreateOnlineGame(s.bot.ctx.CharacterCfg.Game.PublicGameCounter); err != nil {
s.bot.ctx.CharacterCfg.Game.PublicGameCounter++
return fmt.Errorf("failed to create an online game")
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type CharacterCfg struct {
Runs []Run `yaml:"runs"`
CreateLobbyGames bool `yaml:"createLobbyGames"`
PublicGameCounter int `yaml:"-"`
InitialGameCount int `yaml:"initialGameCount"`
Pindleskin struct {
SkipOnImmunities []stat.Resist `yaml:"skipOnImmunities"`
} `yaml:"pindleskin"`
Expand Down
2 changes: 1 addition & 1 deletion internal/game/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (gm *Manager) CreateOnlineGame(gameCounter int) (string, error) {
// Click the game name textbox, delete text and type new game name
gm.hid.Click(LeftButton, 1000, 116)
gm.clearGameNameOrPasswordField()
gameName := config.Characters[gm.supervisorName].Companion.GameNameTemplate + fmt.Sprintf("%d", gameCounter)
gameName := config.Characters[gm.supervisorName].Companion.GameNameTemplate + fmt.Sprintf("%02d", gameCounter)
for _, ch := range gameName {
gm.hid.PressKey(gm.hid.GetASCIICode(fmt.Sprintf("%c", ch)))
}
Expand Down
1 change: 1 addition & 0 deletions internal/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ func (s *HttpServer) characterSettings(w http.ResponseWriter, r *http.Request) {
cfg.Game.UseCainIdentify = r.Form.Has("useCainIdentify")
cfg.Game.Difficulty = difficulty.Difficulty(r.Form.Get("gameDifficulty"))
cfg.Game.RandomizeRuns = r.Form.Has("gameRandomizeRuns")
cfg.Game.InitialGameCount, _ = strconv.Atoi(r.Form.Get("gameInitialGameCount"))

// Runs specific config
enabledRuns := make([]config.Run, 0)
Expand Down
8 changes: 8 additions & 0 deletions internal/server/templates/character_settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@
<input type="checkbox" name="createLobbyGames" {{ if .Config.Game.CreateLobbyGames }}checked{{ end }}/>
Create Lobby Games
</label><br>
<fieldset class="grid">
<label>
Game Number
<input type="number" name="gameInitialGameCount" placeholder="{{ .Config.Game.InitialGameCount }}"
value="{{ .Config.Game.InitialGameCount }}"/>
</label>
<div></div>
</fieldset>
<fieldset class="grid">
<label>
Game name pattern
Expand Down