@@ -28,7 +28,7 @@ Bank enums used to interact with the bank interface.
2828 ERSBankDynamicButtons = enum(PLACEHOLDERS, SEARCH, DEPOSIT_INVENTORY, DEPOSIT_WORN);
2929 ERSBankInteraction = enum(WITHDRAW, DEPOSIT);
3030
31- TRSItemBankPosition = record
31+ TBankPosition = record
3232 Tab: Integer;
3333 Scroll: Integer;
3434 Slot: TBox;
@@ -70,7 +70,7 @@ Record responsible to handle the bank interface.
7070
7171 Cache: record
7272 Quantity: Integer;
73- Items: TStringMap<TRSItemBankPosition >;
73+ Items: TStringMap<TBankPosition >;
7474 end;
7575
7676 {%codetools off}
664664{%codetools on}
665665
666666(*
667- ## Bank.FindItemTab
667+ ## Bank.FindTab
668668```pascal
669- function TRSBank.FindItemTab (const item: TRSItem; const openTab: Boolean = True): Integer;
669+ function TRSBank.FindTab (const item: TRSItem; const openTab: Boolean = True): Integer;
670670```
671671Find the bank tab of `item`.
672672
@@ -676,10 +676,10 @@ A known limitation of this is that if several items match the sprite of the item
676676
677677Example:
678678```pascal
679- WriteLn Bank.FindItemTab ('Molten glass');
679+ WriteLn Bank.FindTab ('Molten glass');
680680```
681681*)
682- function TRSBank.FindItemTab (const item: TRSItem): Integer;
682+ function TRSBank.FindTab (const item: TRSItem): Integer;
683683var
684684 bounds: TBox;
685685begin
@@ -696,9 +696,9 @@ begin
696696end;
697697
698698(*
699- ## Bank.FindItemScroll
699+ ## Bank.FindScroll
700700```pascal
701- function TRSBank.FindItemScroll (const item: TRSItem): Integer;
701+ function TRSBank.FindScroll (const item: TRSItem): Integer;
702702```
703703Find the scroll position of the bank where `item` is visible..
704704
@@ -708,10 +708,10 @@ A known limitation of this is that if several items match the sprite of the item
708708
709709Example:
710710```pascal
711- WriteLn Bank.FindItemScroll ('Molten glass');
711+ WriteLn Bank.FindScroll ('Molten glass');
712712```
713713*)
714- function TRSBank.FindItemScroll (const item: TRSItem): Integer;
714+ function TRSBank.FindScroll (const item: TRSItem): Integer;
715715var
716716 next: Integer;
717717 down: Boolean;
749749(*
750750## Bank._InteractionHelper
751751```pascal
752- function TRSBank._InteractionHelper(mode: ERSBankInteraction; slot: TBox; amount: Integer; useQuantityButton: Boolean): Boolean;
752+ function TRSBank._InteractionHelper(const mode: ERSBankInteraction; const slot: TBox; const amount: Integer; const useQuantityButton: Boolean): Boolean;
753753```
754754Internal helper method to handle both withdrawing and depositing.
755755
@@ -760,7 +760,7 @@ if Bank.Items.Find('Abyssal whip', slot) the
760760```
761761*)
762762{%codetools off}
763- function TRSBank._InteractionHelper(mode: ERSBankInteraction; slot: TBox; amount: Integer; useQuantityButton: Boolean): Boolean;
763+ function TRSBank._InteractionHelper(const mode: ERSBankInteraction; const slot: TBox; const amount: Integer; const useQuantityButton: Boolean): Boolean;
764764var
765765 quantity: ERSBankQuantity;
766766 amountStr, modeStr: String;
@@ -804,15 +804,15 @@ end;
804804(*
805805## Bank.Find
806806```pascal
807- function TRSBank.Find(item: TRSItem; out data: TRSItemBankPosition ; attempts: Int32 = 3): Boolean;
807+ function TRSBank.Find(const item: TRSItem; out data: TBankPosition ; attempts: Int32 = 3): Boolean;
808808```
809809Attempts to find `item` in the back by whatever means necessary.
810810This will search and scroll the bank until the item is found.
811811By default attempts up to 3 times.
812812
813813Item position data is returned via `data`.
814814*)
815- function TRSBank.Find(item: TRSItem; out data: TRSItemBankPosition ; attempts: Int32 = 3): Boolean;
815+ function TRSBank.Find(const item: TRSItem; out data: TBankPosition ; attempts: Int32 = 3): Boolean;
816816begin
817817 if attempts = 0 then Exit(False);
818818
@@ -827,12 +827,12 @@ begin
827827 end;
828828
829829 if Self.WaitSearchOpen(600) then
830- if not Self.CloseSearch() then Exit(Self.FindItem (item, data, Dec(attempts))); //unknown state, reset search
830+ if not Self.CloseSearch() then Exit(Self.Find (item, data, Dec(attempts))); //unknown state, reset search
831831 end;
832832
833- data.Tab := Self.FindItemTab (item);
833+ data.Tab := Self.FindTab (item);
834834 if data.Tab = -1 then
835- Exit(Self.FindItem (item, data, Dec(attempts)));
835+ Exit(Self.Find (item, data, Dec(attempts)));
836836 Self.OpenTab(data.Tab);
837837
838838 if Self.Items.Find(item, data.Slot) then
@@ -842,18 +842,28 @@ begin
842842 Exit(True);
843843 end;
844844
845- data.Scroll := Self.FindItemScroll (item);
845+ data.Scroll := Self.FindScroll (item);
846846 if data.Scroll = -1 then
847- Exit(Self.FindItem (item, data, Dec(attempts)));
847+ Exit(Self.Find (item, data, Dec(attempts)));
848848
849849 if not Self.Items.Find(item, data.Slot) then
850- Exit(Self.FindItem (item, data, Dec(attempts)));
850+ Exit(Self.Find (item, data, Dec(attempts)));
851851
852852 Result := True;
853853 Self.Cache.Items.Value[item] := data;
854854end;
855855
856856
857+ function TRSBank.Withdraw(const item: TRSBankItem; const useCache: Boolean = True): Boolean;
858+ var
859+ data: TBankPosition;
860+ begin
861+ if Self.Cache.Items.Exists(item.Item) then
862+ data := Self.Cache.Items.Value[item.Item]
863+ else if not Self.Find(item.Item, data) then Exit;
864+
865+ Result := Self._InteractionHelper(ERSBankInteraction.WITHDRAW, data.Slot, item.Quantity, True);
866+ end;
857867
858868procedure TRSBank.Draw(img: TImage);
859869var
0 commit comments