Skip to content

Commit 3c6619a

Browse files
committed
fix: read notes
- Bank._InteractionHelper shouldn't really fail on custom quantities anymore and custom quantities get cached - MainScreen.IsUpText now gets the match percentage printed with `{$DEFINE WL_DEBUG_UPTEXT}`
1 parent 72bc442 commit 3c6619a

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

osrs/interfaces/mainscreen/bank.simba

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ Record responsible to handle the {ref}`Bank` interface.
7676
Title: TRSInterfaceTitle;
7777
Scroll: TRSScrollBar;
7878

79-
CachedQuantity: Integer;
80-
8179
Incenerator, PotionStorage, SlotsArea: TBox;
8280

8381
Tabs, SlotBoxes: TBoxArray;
@@ -943,7 +941,7 @@ if Bank.Items.Find('Abyssal whip', slot) the
943941
function TRSBank._InteractionHelper(mode: ERSBankInteraction; slot: TBox; amount: Integer; useQuantityButton: Boolean): Boolean;
944942
var
945943
quantity: ERSItemQuantity;
946-
amountStr, modeStr: String;
944+
amountStr, modeStr, upText: String;
947945
begin
948946
amountStr := ToString(amount);
949947
quantity := ERSItemQuantity.Integer2Quantity(amount);
@@ -955,7 +953,8 @@ begin
955953

956954
if useQuantityButton then
957955
begin
958-
if not Self.SetQuantity(quantity) then Exit;
956+
if not Self.SetQuantity(quantity) then
957+
Exit;
959958

960959
Mouse.Move(slot);
961960
if quantity <> ERSItemQuantity.CUSTOM then
@@ -964,14 +963,34 @@ begin
964963
Exit(True);
965964
end;
966965

967-
if MainScreen.IsUpText(modeStr + amountStr) then
966+
if Self._Cache.Quantity = amount then
967+
begin
968+
Mouse.Click(EMouseButton.LEFT);
969+
Exit(True);
970+
end;
971+
972+
upText := MainScreen.UpText;
973+
if not upText.Contains(modeStr) then
974+
Exit;
975+
976+
upText := upText.Between(modeStr, ' ');
977+
978+
if upText = amountStr then
968979
begin
980+
Self._Cache.Quantity := amount;
969981
Mouse.Click(EMouseButton.LEFT);
970982
Exit(True);
971983
end;
972984

973-
if not ChooseOption.Select(modeStr + 'X') then Exit;
974-
Exit(Chat.AnswerQuery('Enter amount', amountStr, RandomLeft(1400, 2400)));
985+
if not ChooseOption.Select(modeStr + 'X') then
986+
Exit;
987+
if Chat.AnswerQuery('Enter amount', amountStr, RandomLeft(1400, 2400)) then
988+
begin
989+
Self._Cache.Quantity := amount;
990+
Exit(True);
991+
end
992+
else
993+
Exit;
975994
end;
976995

977996
Mouse.Move(slot);

osrs/interfaces/mainscreen/mainscreen.simba

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ function TRSMainScreen.IsUpText(strings: TStringArray; caseSensitive: Boolean =
180180
var
181181
upText, str, tmp: String;
182182
i: Integer;
183+
match: Double;
183184
begin
184185
if caseSensitive then
185186
upText := Self.UpText
@@ -194,8 +195,14 @@ function TRSMainScreen.IsUpText(strings: TStringArray; caseSensitive: Boolean =
194195
for i := 1 to Length(upText)-Length(str) do
195196
begin
196197
tmp := Copy(upText, i, Length(str));
197-
if str.Similarity(tmp) >= similarity then
198+
match := str.Similarity(tmp);
199+
if match >= similarity then
200+
begin
201+
{$IFDEF WL_DEBUG_UPTEXT}
202+
WriteLn GetDebugLn('MainScreen', 'IsUpText Similarity: ' + ToStr(match));
203+
{$ENDIF}
198204
Exit(True);
205+
end;
199206
end;
200207
end;
201208
end;

0 commit comments

Comments
 (0)