Skip to content

Commit d556f26

Browse files
committed
fix: parsing error, oops
- also more GE
1 parent 7abb5eb commit d556f26

File tree

3 files changed

+152
-2
lines changed

3 files changed

+152
-2
lines changed

osrs/interfaces/mainscreen/grandexchange/grandexchange.simba

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ end.
9898
ItemBox, ItemNameBox, ValueBox, StatusBox: TBox;
9999
end;
100100

101+
TRSGrandExchangeSlotArray = array of TRSGrandExchangeSlot;
102+
101103
procedure TRSGrandExchangeSlot._Setup(bounds: TBox);
102104
begin
103105
Self.Bounds := bounds;
@@ -279,6 +281,49 @@ begin
279281
Result := EGEOfferStatus.NONE;
280282
end;
281283

284+
(*
285+
## TRSGrandExchangeSlot.Open
286+
```pascal
287+
function TRSGrandExchangeSlot.Open(): Boolean;
288+
```
289+
Attempts to open the {ref}`GrandExchangeOffer` status screen of an existing
290+
offer.
291+
292+
Example:
293+
```pascal
294+
WriteLn GrandExchange.Slots[1].Open();
295+
```
296+
*)
297+
function TRSGrandExchangeSlot.Open(): Boolean; forward;
298+
299+
(*
300+
## TRSGrandExchangeSlot.Buy
301+
```pascal
302+
function TRSGrandExchangeSlot.Buy(): Boolean;
303+
```
304+
Attempts to open the {ref}`GrandExchangeOffer` screen with the buy button.
305+
306+
Example:
307+
```pascal
308+
WriteLn GrandExchange.Slots[2].Buy();
309+
```
310+
*)
311+
function TRSGrandExchangeSlot.Buy(): Boolean; forward;
312+
313+
(*
314+
## TRSGrandExchangeSlot.Sell
315+
```pascal
316+
function TRSGrandExchangeSlot.Sell(): Boolean;
317+
```
318+
Attempts to open the {ref}`GrandExchangeOffer` screen with the sell button.
319+
320+
Example:
321+
```pascal
322+
WriteLn GrandExchange.Slots[2].Sell();
323+
```
324+
*)
325+
function TRSGrandExchangeSlot.Sell(): Boolean; forward;
326+
282327

283328
type
284329
(*
@@ -392,9 +437,115 @@ begin
392437
Result := Self.Title.Close(escapeProbability);
393438
end;
394439

440+
441+
(*
442+
## GrandExchange.GetEmptySlots
443+
```pascal
444+
function TRSGrandExchange.GetEmptySlots(): TRSGrandExchangeSlotArray;
445+
```
446+
Returns a `TRSGrandExchangeSlotArray` of the empty slots available.
447+
448+
Example:
449+
```pascal
450+
{$I WaspLib/osrs.simba}
451+
var
452+
img: TImage;
453+
slot: TRSGrandExchangeSlot;
454+
begin
455+
img := Target.GetImage();
456+
img.DrawColor := $00FFFF;
457+
for slot in GrandExchange.GetEmptySlots() do
458+
img.DrawBox(slot.Bounds);
459+
img.Show();
460+
end.
461+
```
462+
```{figure} ../../images/ge_emptyslots.png
463+
```
464+
*)
465+
function TRSGrandExchange.GetEmptySlots(): TRSGrandExchangeSlotArray;
466+
var
467+
i: Integer;
468+
begin
469+
for i := 0 to 7 do
470+
if Self.Slots[i].GetType() = EGESlotType.EMPTY then
471+
Result += Self.Slots[i];
472+
end;
473+
474+
(*
475+
## GrandExchange.IndexOfEmptySlot
476+
```pascal
477+
function TRSGrandExchange.IndexOfEmptySlot(): Integer;
478+
```
479+
Returns the index of the first empty slot available.
480+
481+
Example:
482+
```pascal
483+
WriteLn GrandExchange.IndexOfEmptySlot();
484+
```
485+
*)
486+
function TRSGrandExchange.IndexOfEmptySlot(): Integer;
487+
begin
488+
for Result := 0 to 7 do
489+
if Self.Slots[Result].GetType() = EGESlotType.EMPTY then
490+
Exit;
491+
Result := -1;
492+
end;
493+
494+
(*
495+
## GrandExchange.GetEmptySlot
496+
```pascal
497+
function TRSGrandExchange.GetEmptySlot(): TRSGrandExchangeSlot;
498+
```
499+
Returns a `TRSGrandExchangeSlot` that is empty.
500+
501+
Example:
502+
```pascal
503+
{$I WaspLib/osrs.simba}
504+
begin
505+
ShowOnTarget(GrandExchange.GetEmptySlot().Bounds);
506+
end.
507+
```
508+
```{figure} ../../images/ge_emptyslot.png
509+
```
510+
*)
511+
function TRSGrandExchange.GetEmptySlot(): TRSGrandExchangeSlot;
512+
var
513+
slot: Integer;
514+
begin
515+
slot := Self.IndexOfEmptySlot();
516+
if slot > -1 then
517+
Result := Self.Slots[slot];
518+
end;
519+
520+
395521
var
396522
(*
397523
## GrandExchange variable
398524
Global {ref}`TRSGrandExchange` variable.
399525
*)
400526
GrandExchange: TRSGrandExchange;
527+
528+
function TRSGrandExchangeSlot.Open(): Boolean;
529+
begin
530+
if Self.GetType() = EGESlotType.EMPTY then Exit;
531+
Mouse.Click(Self.Bounds, EMouseButton.LEFT);
532+
Result := SleepUntil(not GrandExchange.IsOpen(), 200, 2000);
533+
end;
534+
535+
function TRSGrandExchangeSlot.Buy(): Boolean;
536+
begin
537+
if Self.GetType() <> EGESlotType.EMPTY then
538+
Exit;
539+
Mouse.Click(Self.BuyButton, EMouseButton.LEFT);
540+
Result := SleepUntil(not GrandExchange.IsOpen(), 200, 2000);
541+
end;
542+
543+
function TRSGrandExchangeSlot.Sell(): Boolean;
544+
begin
545+
if Self.GetType() <> EGESlotType.EMPTY then
546+
Exit;
547+
Mouse.Click(Self.SellButton, EMouseButton.LEFT);
548+
Result := SleepUntil(not GrandExchange.IsOpen(), 200, 2000);
549+
end;
550+
551+

osrs/interfaces/mainscreen/grandexchange/grandexchange_history.simba

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fully interact with it is split into multiple files and records:
1212
- {ref}`GrandExchangeChat`, the chat interface of the grand exchange when you are setting up a buy offer.
1313
- {ref}`GrandExchangeOffer`, the screen of the grand exchange where you view or setup a new offer.
1414
*)
15-
*)
1615

1716
{$DEFINE WL_GRANDEXCHANGE_HISTORY_INCLUDED}
1817
{$INCLUDE_ONCE WaspLib/osrs.simba}

wasplib-docs

0 commit comments

Comments
 (0)