-
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
1 parent
97d8ffd
commit cdd4121
Showing
7 changed files
with
196 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/viper" | ||
"log/slog" | ||
"time" | ||
|
||
"github.com/promiseofcake/artifactsmmo-engine/internal/actions" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
craftCode string | ||
craftQty int | ||
) | ||
|
||
// craftCmd represents the gather command | ||
var craftCmd = &cobra.Command{ | ||
Use: "craft", | ||
Short: "Start a craft loop in your current location", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
character := viper.GetViper().GetString("character") | ||
if character == "" { | ||
return fmt.Errorf("you must specify a character") | ||
} | ||
r := cmd.Context().Value(runnerKey).(*actions.Runner) | ||
for { | ||
slog.Info("about to craft", "code", craftCode, "quantity", craftQty) | ||
|
||
resp, err := r.Craft(cmd.Context(), character, craftCode, craftQty) | ||
if err != nil { | ||
slog.Error("failed to craft", "error", err.Error()) | ||
return fmt.Errorf("failed to craft: %w", err) | ||
} | ||
|
||
sec := resp.GetRemainingCooldown() | ||
slog.Info("craft results", | ||
"xp", resp.SkillInfo.Xp, | ||
"items", resp.SkillInfo.Items, | ||
"cooldown", sec, | ||
) | ||
time.Sleep(time.Duration(sec) * time.Second) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
craftCmd.Flags().StringVar(&craftCode, "code", "", "The code of your item to craft") | ||
craftCmd.Flags().IntVar(&craftQty, "qty", 0, "The quantity to craft") | ||
rootCmd.AddCommand(craftCmd) | ||
} |
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,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/viper" | ||
"log/slog" | ||
"time" | ||
|
||
"github.com/promiseofcake/artifactsmmo-engine/internal/actions" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var fightCmd = &cobra.Command{ | ||
Use: "fight", | ||
Short: "fight something", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
character := viper.GetViper().GetString("character") | ||
if character == "" { | ||
return fmt.Errorf("you must specify a character") | ||
} | ||
r := cmd.Context().Value(runnerKey).(*actions.Runner) | ||
for { | ||
slog.Info("about to fight") | ||
|
||
resp, err := r.Fight(cmd.Context(), character) | ||
if err != nil { | ||
slog.Error("failed to fight", "error", err.Error()) | ||
return fmt.Errorf("failed to fight: %w", err) | ||
} | ||
|
||
sec := resp.GetRemainingCooldown() | ||
slog.Info("fight results", | ||
"results", resp.FightResponse, | ||
"cooldown", sec, | ||
) | ||
time.Sleep(time.Duration(sec) * time.Second) | ||
return nil | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(fightCmd) | ||
} |
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,48 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/viper" | ||
"log/slog" | ||
"time" | ||
|
||
"github.com/promiseofcake/artifactsmmo-engine/internal/actions" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
x int | ||
y int | ||
) | ||
|
||
// craftCmd represents the gather command | ||
var moveCmd = &cobra.Command{ | ||
Use: "move", | ||
Short: "move position", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
character := viper.GetViper().GetString("character") | ||
if character == "" { | ||
return fmt.Errorf("you must specify a character") | ||
} | ||
r := cmd.Context().Value(runnerKey).(*actions.Runner) | ||
|
||
resp, err := r.Move(cmd.Context(), character, x, y) | ||
if err != nil { | ||
slog.Error("failed to move", "error", err.Error()) | ||
return fmt.Errorf("failed to move: %w", err) | ||
} | ||
|
||
sec := resp.GetRemainingCooldown() | ||
slog.Info("move results", | ||
"cooldown", sec, | ||
) | ||
time.Sleep(time.Duration(sec) * time.Second) | ||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
moveCmd.Flags().IntVar(&x, "x", 0, "The x position") | ||
moveCmd.Flags().IntVar(&y, "y", 0, "The y position") | ||
rootCmd.AddCommand(moveCmd) | ||
} |
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
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