|
98 | 98 | ItemBox, ItemNameBox, ValueBox, StatusBox: TBox; |
99 | 99 | end; |
100 | 100 |
|
| 101 | + TRSGrandExchangeSlotArray = array of TRSGrandExchangeSlot; |
| 102 | + |
101 | 103 | procedure TRSGrandExchangeSlot._Setup(bounds: TBox); |
102 | 104 | begin |
103 | 105 | Self.Bounds := bounds; |
@@ -279,6 +281,49 @@ begin |
279 | 281 | Result := EGEOfferStatus.NONE; |
280 | 282 | end; |
281 | 283 |
|
| 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 | + |
282 | 327 |
|
283 | 328 | type |
284 | 329 | (* |
@@ -392,9 +437,115 @@ begin |
392 | 437 | Result := Self.Title.Close(escapeProbability); |
393 | 438 | end; |
394 | 439 |
|
| 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 | + |
395 | 521 | var |
396 | 522 | (* |
397 | 523 | ## GrandExchange variable |
398 | 524 | Global {ref}`TRSGrandExchange` variable. |
399 | 525 | *) |
400 | 526 | 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 | + |
0 commit comments