Simba Code:
Program ScrollsProfits;
Const
ScrollType = 'Ambush';
Function GetScrollProfit(Scroll:string):String;
Var
Words:String;
Index, Index1:Integer;
begin
Words := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
Index := PosEx('>', Words, PosEx('color:', Words, Pos(Scroll, Words))+6);
Index1 := PosEx('<', Words, Index);
Result := ScrollType + ' Scroll Profit: ' + Copy(Words, Index+1, PosEx('<', Words, Index)-(Index+1)) + 'gp';
end;
Procedure DisplayAllScrolls; //Displays all scrolls, their required summoning levels, their corresponding pouches, and their profits/losses
Var
Page, Scroll, Level, Pouch, Profit:String;
Index, Index1, i:Integer;
begin
Writeln('|==============================================================|');
Writeln('| Scroll Level Pouch Profit |');
Writeln('|==============================================================|');
Page := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
For i := 0 to 41 Do
begin
Index := PosEx('name="', Page, Pos('Profit', Page)+(i*1230));
Index1 := PosEx('.p', Page, Index+10);
Scroll := Copy(Page, Index+6, Index1-(Index+6));
If Pos('Titan', Scroll) <> 0 Then
Scroll := 'Titan''s con. scroll';
Level := Copy(Page, PosEx('scroll</a> </td><td> ', Page, Index)+21, 2);
Pouch := Copy(Page, PosEx('name="', Page, Index+4)+6, PosEx('.p', Page, PosEx('name="', Page, Index+4)+6)-(PosEx('name="', Page, Index+4)+6));
Index1 := PosEx('<', Page, PosEx('color', Page, PosEx('name', Page, Index)));
Profit := Copy(Page, PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1, Index1-(PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1)) + 'gp';
Writeln(' ' + Scroll + ' ' + Level + ' ' + Pouch + ' ' + Profit);
end;
end;
Procedure DisplayPositiveProfitScrolls; //Displays scrolls' names, required levels, corresponding pouches, and profits if they can make a profit
Var
Page, Scroll, Level, Pouch, Profit, Comma:String;
Index, Index1, i:Integer;
begin
Writeln('|==============================================================|');
Writeln('| Scroll Level Pouch Profit |');
Writeln('|==============================================================|');
Page := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
Comma := ',';
For i := 0 to 41 Do
begin
Index := PosEx('name="', Page, Pos('Profit', Page)+(i*1230));
Index1 := PosEx('.p', Page, Index+10);
Scroll := Copy(Page, Index+6, Index1-(Index+6));
If Pos('Titan', Scroll) <> 0 Then
Scroll := 'Titan''s con. scroll';
Level := Copy(Page, PosEx('scroll</a> </td><td> ', Page, Index)+21, 2);
Pouch := Copy(Page, PosEx('name="', Page, Index+4)+6, PosEx('.p', Page, PosEx('name="', Page, Index+4)+6)-(PosEx('name="', Page, Index+4)+6));
Index1 := PosEx('<', Page, PosEx('color', Page, PosEx('name', Page, Index)));
Profit := Copy(Page, PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1, Index1-(PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1)) + 'gp';
If Pos('-', Profit) = 0 Then
begin
If Pos(Comma, Profit) > 0 Then
Delete(Profit, Pos(Comma, Profit), 1);
Writeln(' ' + Scroll + ' ' + Level + ' ' + Pouch + ' ' + Profit);
end;
end;
end;
begin
Writeln(GetScrollProfit(ScrollType));
DisplayAllScrolls;
DisplayPositiveProfitScrolls;
end.