-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kyle Jackson
committed
Aug 8, 2024
1 parent
15a5f74
commit e774aab
Showing
27 changed files
with
1,139 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM golang:1.22.5-alpine3.20 | ||
|
||
WORKDIR /go/src/fishing | ||
|
||
COPY . /go/src/fishing | ||
|
||
RUN go get ./... | ||
RUN go build ./cmd/fishing | ||
|
||
ENTRYPOINT ["./fishing"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM golang:1.22.5-alpine3.20 | ||
|
||
WORKDIR /go/src/sync | ||
|
||
COPY . /go/src/sync | ||
|
||
RUN go get ./... | ||
RUN go build ./cmd/sync | ||
|
||
ENTRYPOINT ["./sync"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/database" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/routes" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/utils" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func main() { | ||
utils.LoggerInit() | ||
database.Init() | ||
router := routes.Init() | ||
routes.GenerateItemRoutes(router) | ||
routes.GenerateTaskRoutes(router) | ||
err := router.Run(":9000") | ||
if err != nil { | ||
utils.Logger.Fatal("failed to start gin server", zap.Error(err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/artifacts" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/controllers" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/models" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/utils" | ||
"go.uber.org/zap" | ||
"os" | ||
"time" | ||
) | ||
|
||
func main() { | ||
utils.LoggerInit() | ||
artifacts.Init() | ||
for { | ||
var ( | ||
x int | ||
y int | ||
) | ||
fishingResource, ok := os.LookupEnv("FISHING_RESOURCE") | ||
if !ok { | ||
c, err := artifacts.Client.GetCharacter(*artifacts.Client.CharacterName) | ||
if err != nil { | ||
utils.Logger.Error("failed to get character information", zap.Error(err)) | ||
continue | ||
} | ||
if c.Data.FishingLevel < models.ShrimpLevel { | ||
x = models.GudgeonX | ||
y = models.GudgeonY | ||
} else if c.Data.MiningLevel < models.TroutLevel { | ||
x = models.ShrimpX | ||
y = models.ShrimpY | ||
} else if c.Data.MiningLevel < models.BassLevel { | ||
x = models.TroutX | ||
y = models.TroutY | ||
} else { | ||
x = models.BassX | ||
y = models.BassY | ||
} | ||
} else { | ||
switch fishingResource { | ||
case models.Gudgeon: | ||
x = models.GudgeonX | ||
y = models.GudgeonY | ||
case models.Shrimp: | ||
x = models.ShrimpX | ||
y = models.ShrimpY | ||
case models.Trout: | ||
x = models.TroutX | ||
y = models.TroutY | ||
case models.Bass: | ||
x = models.BassX | ||
y = models.BassY | ||
default: | ||
x = models.GudgeonX | ||
y = models.GudgeonY | ||
} | ||
} | ||
c, err := artifacts.Client.GetCharacter(*artifacts.Client.CharacterName) | ||
if err != nil { | ||
utils.Logger.Error("failed to get character information", zap.Error(err)) | ||
continue | ||
} | ||
if c.Data.X != x || c.Data.Y != y { | ||
fmt.Printf("moving character to x=%d y=%d\n", x, y) | ||
resp, err := artifacts.Client.ActionMove(*artifacts.Client.CharacterName, models.ActionMove{ | ||
X: x, | ||
Y: y, | ||
}) | ||
if err != nil { | ||
utils.Logger.Error("failed to move character", zap.Error(err)) | ||
continue | ||
} | ||
time.Sleep(utils.CalculateTimeDifference(resp.Data.Cooldown.StartedAt, resp.Data.Cooldown.Expiration)) | ||
} | ||
resp, err := artifacts.Client.ActionGathering(*artifacts.Client.CharacterName) | ||
if errors.Is(err, utils.ErrCharacterInventoryFull) { | ||
bankX, bankY := artifacts.Client.FindBuilding(models.Bank) | ||
resp, err := artifacts.Client.ActionMove(*artifacts.Client.CharacterName, models.ActionMove{ | ||
X: bankX, | ||
Y: bankY, | ||
}) | ||
if err != nil { | ||
utils.Logger.Error("failed to move character", zap.Error(err)) | ||
continue | ||
} | ||
fmt.Printf("moving character to bank (x=%d y=%d)\n", bankX, bankY) | ||
time.Sleep(utils.CalculateTimeDifference(resp.Data.Cooldown.StartedAt, resp.Data.Cooldown.Expiration)) | ||
c, err := artifacts.Client.GetCharacter(*artifacts.Client.CharacterName) | ||
if err != nil { | ||
utils.Logger.Error("failed to get character information", zap.Error(err)) | ||
continue | ||
} | ||
controllers.DepositAllInventory(c.Data.Inventory) | ||
resp, err = artifacts.Client.ActionMove(*artifacts.Client.CharacterName, models.ActionMove{ | ||
X: x, | ||
Y: y, | ||
}) | ||
if err != nil { | ||
utils.Logger.Error("failed to move character", zap.Error(err)) | ||
continue | ||
} | ||
time.Sleep(utils.CalculateTimeDifference(resp.Data.Cooldown.StartedAt, resp.Data.Cooldown.Expiration)) | ||
} else if err == nil { | ||
fmt.Printf("%s collected %v\n", *artifacts.Client.CharacterName, resp.Data.Details.Items) | ||
time.Sleep(utils.CalculateTimeDifference(resp.Data.Cooldown.StartedAt, resp.Data.Cooldown.Expiration)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/artifacts" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/database" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/models" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/utils" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func main() { | ||
utils.LoggerInit() | ||
artifacts.Init() | ||
database.Init() | ||
ItemTypes := []string{ | ||
"consumable", | ||
"body_armor", | ||
"weapon", | ||
"resource", | ||
"leg_armor", | ||
"helmet", | ||
"boots", | ||
"shield", | ||
"amulet", | ||
"ring", | ||
} | ||
for _, itemType := range ItemTypes { | ||
err := database.Client.DeleteItems(itemType) | ||
if err != nil { | ||
utils.Logger.Error("Failed to delete item type", zap.String("type", itemType), zap.Error(err)) | ||
} | ||
var items []interface{} | ||
resp, err := artifacts.Client.GetItems(models.GetAllItemsQueryParameters{ | ||
Type: itemType, | ||
Size: 100, | ||
}) | ||
if err != nil { | ||
utils.Logger.Error("failed to get items", zap.Error(err)) | ||
} | ||
for _, item := range resp.Data { | ||
items = append(items, item) | ||
} | ||
err = database.Client.CreateItems(items) | ||
if err != nil { | ||
utils.Logger.Error("failed to create items", zap.Error(err)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.