Skip to content

Commit

Permalink
feat: adjustments for orders (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
promiseofcake authored Sep 16, 2024
1 parent 92af302 commit ef8ebd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion internal/actions/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/promiseofcake/artifactsmmo-go-client/client"

"github.com/promiseofcake/artifactsmmo-engine/internal/logging"
"github.com/promiseofcake/artifactsmmo-engine/internal/models"
)

Expand Down Expand Up @@ -271,9 +272,13 @@ func (r *Runner) GetResourcesBySkill(ctx context.Context, skill client.ResourceS
var resources models.Resources
for _, res := range resp.JSON200.Data {
locations, lErr := r.GetMapsByContentCode(ctx, res.Code)
if lErr != nil || len(locations) == 0 {
if lErr != nil {
return nil, fmt.Errorf("failed to find resource locations: %w", err)
}
if len(locations) == 0 {
logging.Get(ctx).Info("skipping resource locations: no locations found", "resource", res)
continue
}

resource := models.Resource{
Name: res.Name,
Expand Down
6 changes: 3 additions & 3 deletions internal/models/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ func (c Character) ChooseWeakestSkill() CharacterSkill {
{
Code: client.ResourceSchemaSkillWoodcutting,
CurrentLevel: c.WoodcuttingLevel,
MinLevel: math.Max(0, c.WoodcuttingLevel-10),
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.WoodcuttingLevel-10)}[c.WoodcuttingLevel == 35],
},
{
Code: client.ResourceSchemaSkillMining,
CurrentLevel: c.MiningLevel,
MinLevel: math.Max(0, c.MiningLevel-10),
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.MiningLevel-10)}[c.MiningLevel == 35],
},
{
Code: client.ResourceSchemaSkillFishing,
CurrentLevel: c.FishingLevel,
MinLevel: math.Max(0, c.FishingLevel-10),
MinLevel: map[bool]int{true: 20, false: math.Max(0, c.FishingLevel-10)}[c.FishingLevel == 35],
},
}

Expand Down

0 comments on commit ef8ebd7

Please sign in to comment.