forked from nt153133/LlamaLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MastPieceSupplyTester.cs
186 lines (150 loc) · 5.85 KB
/
MastPieceSupplyTester.cs
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Buddy.Coroutines;
using ff14bot;
using ff14bot.AClasses;
using ff14bot.Behavior;
using ff14bot.Enums;
using ff14bot.Helpers;
using ff14bot.Managers;
using Generate;
using LlamaLibrary.RemoteWindows;
using Newtonsoft.Json;
using TreeSharp;
//using UI_Checker;
namespace MasterPieceSupplyTest
{
public class MasterPieceSupplyTester : BotBase
{
private Composite _root;
public override string Name => "GCSupplyOrderLisbeth";
public override PulseFlags PulseFlags => PulseFlags.All;
public override bool IsAutonomous => true;
public override bool RequiresProfile => false;
public override Composite Root => _root;
public override bool WantButton { get; } = false;
private async Task<bool> Run()
{
//await PrintMasterPieceList();
await PrintGCSupplyList();
TreeRoot.Stop("Stop Requested");
return true;
}
public override void Start()
{
_root = new ActionRunCoroutine(r => Run());
}
public override void Stop()
{
_root = null;
}
public async Task<bool> PrintGCSupplyList()
{
if (!ContentsInfo.Instance.IsOpen)
{
}
if (!ContentsInfoDetail.Instance.IsOpen)
{
Logging.Write($"Trying to open window");
if (!ContentsInfo.Instance.IsOpen)
{
if (await ContentsInfo.Instance.Open())
ContentsInfo.Instance.OpenGCSupplyWindow();
}
await Coroutine.Wait(5000, () => ContentsInfoDetail.Instance.IsOpen);
if (!ContentsInfoDetail.Instance.IsOpen)
{
Logging.Write($"Nope failed opening GC Supply window");
return false;
}
}
if (!ContentsInfoDetail.Instance.IsOpen)
{
Logging.Write($"Nope failed");
return false;
}
List<LisbethOrder> outList = new List<LisbethOrder>();
int id = 0;
foreach (var item in ContentsInfoDetail.Instance.GetCraftingTurninItems())
{
Logging.Write($"{item.Key} Qty: {item.Value.Key} Class: {item.Value.Value}");
var order = new LisbethOrder(id, 1, (int) item.Key.Id, item.Value.Key, item.Value.Value);
outList.Add(order);
id++;
}
foreach (var item in ContentsInfoDetail.Instance.GetGatheringTurninItems())
{
Logging.Write($"{item.Key} Qty: {item.Value.Key} Class: {item.Value.Value}");
var order = new LisbethOrder(id, 1, (int) item.Key.Id, item.Value.Key, "Gather");
if (!item.Value.Value.Equals("Fisher"))
outList.Add(order);
id++;
}
ContentsInfoDetail.Instance.Close();
ContentsInfo.Instance.Close();
foreach (var order in outList)
{
Logging.Write($"{order}");
}
using (StreamWriter outputFile = new StreamWriter("GCSupply.json", false))
{
outputFile.Write(JsonConvert.SerializeObject(outList, Formatting.None));
}
return true;
}
public async Task<bool> PrintMasterPieceList()
{
Dictionary<ff14bot.Enums.ClassJobType, int> Classes = new Dictionary<ClassJobType, int>
{
{ClassJobType.Carpenter,0},
{ClassJobType.Blacksmith,1},
{ClassJobType.Armorer,2},
{ClassJobType.Goldsmith,3},
{ClassJobType.Leatherworker,4},
{ClassJobType.Weaver,5},
{ClassJobType.Alchemist,6},
{ClassJobType.Culinarian,7},
{ClassJobType.Miner,8},
{ClassJobType.Botanist,9},
{ClassJobType.Fisher,10},
};
if (!MasterPieceSupply.Instance.IsOpen)
{
Logging.Write($"Trying to open window");
AgentModule.ToggleAgentInterfaceById(95);
await Coroutine.Wait(5000, () => RaptureAtkUnitManager.GetWindowByName("ContentsInfo") != null);
await Coroutine.Sleep(500);
if (RaptureAtkUnitManager.GetWindowByName("ContentsInfo") == null)
{
Logging.Write($"Nope failed opening timer window");
return false;
}
await Coroutine.Sleep(500);
RaptureAtkUnitManager.GetWindowByName("ContentsInfo").SendAction(2, 3, 0xC, 3, 6);
await Coroutine.Wait(5000, () => MasterPieceSupply.Instance.IsOpen);
await Coroutine.Sleep(500);
}
if (!MasterPieceSupply.Instance.IsOpen)
{
Logging.Write($"Nope failed");
return false;
}
foreach (var job in Classes)
{
Logging.Write($"{job.Key}:");
MasterPieceSupply.Instance.ClassSelected = job.Value;
await Coroutine.Sleep(1000);
//Can also use MasterPieceSupply.GetTurninItems() if you don't wanted starred info
foreach (var item in MasterPieceSupply.Instance.GetTurninItemsStarred())
{
Logging.Write($"{item.Key} Starred: {item.Value}");
}
}
MasterPieceSupply.Instance.Close();
return true;
}
}
}