-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
131 lines (124 loc) · 3.37 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
import (
"artifacts/api"
"errors"
"os"
"sync"
)
func main() {
// process flags
//itemPtr := flag.String("item", "", "provide item code that you wish to craft")
////fightMonsterPtr := flag.String("monster", "", "provide the monster you wish to fight")
//flag.Parse()
// set up app dependencies
token, ok := os.LookupEnv("API_TOKEN")
if !ok {
panic(errors.New("API_TOKEN ENV VAR not found"))
}
service, err := api.NewSvc(token)
if err != nil {
panic(err)
}
//if err := service.RecycleItems("Kristi"); err != nil {
// panic(err)
//}
wg := sync.WaitGroup{}
for _, character := range service.GetAllCharacters() {
wg.Add(1)
go func(character *api.Character) {
defer wg.Done()
for _, invItem := range character.Inventory {
if invItem.Code == "" {
continue
}
if err := service.DepositBank(character.Name, invItem); err != nil {
panic(err)
}
service.GetCharacterByName(character.Name).WaitForCooldown()
}
}(character)
}
wg.Wait()
// wg2 := sync.WaitGroup{}
// for _, character := range service.GetAllCharacters() {
// wg2.Add(1)
// if character.Name == "Kristi" {
// go func(characterName string) {
// defer wg2.Done()
// for service.GetCharacterByName(characterName).JewelrycraftingLevel < 10 {
// item, err := service.CraftItem(characterName, "copper_ring", 1)
// if err != nil {
// panic(err)
// }
// invSlot := api.InventorySlot{
// Code: item.Code,
// Quantity: 1,
// }
// if err := service.DepositBank(characterName, invSlot); err != nil {
// panic(err)
// }
// service.GetCharacterByName(characterName).WaitForCooldown()
// }
// if err := service.GatherLoop(characterName, "iron_ore"); err != nil {
// panic(err)
// }
// }(character.Name)
// continue
// }
// go func(characterName string) {
// defer wg2.Done()
// if err := service.GatherLoop(characterName, "iron_ore"); err != nil {
// panic(err)
// }
// //
// //if service.GetCharacterByName(characterName).HelmetSlot == "" {
// // if err := service.Equip(characterName, *item); err != nil {
// // panic(err)
// // }
// //} else {
// // if err := service.RecycleItems(characterName); err != nil {
// // panic(err)
// // }
// // if err := service.DepositAllItems(characterName); err != nil {
// // panic(err)
// // }
// //}
// }(character.Name)
// }
// wg2.Wait()
//}
wg2 := sync.WaitGroup{}
for _, character := range service.GetAllCharacters() {
wg2.Add(1)
if character.Name == "Kristi" {
go func(characterName string) {
defer wg2.Done()
if err := service.FightForCrafting(characterName, "cowhide", nil); err != nil {
panic(err)
}
}(character.Name)
continue
}
go func(characterName string) {
defer wg2.Done()
for service.GetCharacterByName(characterName).WoodcuttingLevel < 10 {
if _, err := service.CraftItem(characterName, "ash_plank", 5); err != nil {
panic(err)
}
}
//if service.GetCharacterByName(characterName).HelmetSlot == "" {
// if err := service.Equip(characterName, *item); err != nil {
// panic(err)
// }
//} else {
// if err := service.RecycleItems(characterName); err != nil {
// panic(err)
// }
// if err := service.DepositAllItems(characterName); err != nil {
// panic(err)
// }
//}
}(character.Name)
}
wg2.Wait()
}