From af136a9f6ee286a1a7ea7d44ba8d1e0b0bc400b4 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 15 Nov 2012 16:14:48 +0100 Subject: [PATCH 1/6] Add boots/helmet/gloves. (Cloaks are not that easy) --- plugins/priceid-buy.pl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/priceid-buy.pl b/plugins/priceid-buy.pl index 79b8b44..9a22a23 100644 --- a/plugins/priceid-buy.pl +++ b/plugins/priceid-buy.pl @@ -69,6 +69,23 @@ 'teleportation'], 500 => ['death', 'wishing'], }, + 'boots' => { + 10 => ['elven', 'kicking'], + 30 => ['fumble', 'levitation'], + 50 => ['jumping', 'speed', 'water walking'], + }, + 'helmet' => { + 10 => ['plain'], + 50 => ['brilliance', 'opp.align', 'telepathy'], + }, + 'gloves' => { + 8 => ['leather'], + 50 => ['dexterity', 'fumbling', 'power'], + }, + 'cloak' => { + 50 => ['displacement', 'protection'], + 50 => ['invisibility', 'magic resistance'], + }, ); our $shirt = 0; @@ -132,7 +149,7 @@ sub calc_base "\e\e#name\ny$letter$buc\n"; }; -make_tab qr/^(?:You have a little trouble lifting )?(.) - (an?|\d+) (?:blessed |uncursed |cursed )?(.*?) ?(scroll|potion|wand|ring|spellbook)s? (?:(?:called |labeled )(.*?) ?)?\(unpaid, (\d+) zorkmids?\)\./ +make_tab qr/^(?:You have a little trouble lifting )?(.) - (an?|\d+) (?:blessed |uncursed |cursed )?(?:pair of )?(.*?) ?(scroll|potion|wand|ring|spellbook|boots|helmet|gloves)s? (?:(?:called |labeled )(.*?) ?)?\(unpaid, (\d+) zorkmids?\)\./ => sub { my ($letter, $count, $appearance, $type, $existing, $cost) From 1dd613d0b1372d2af92b514211e4725aed4c71bc Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 15 Nov 2012 23:50:51 +0100 Subject: [PATCH 2/6] Do price identification on selling. Includes optional auto-naming. --- plugins/priceid-sell.pl | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 plugins/priceid-sell.pl diff --git a/plugins/priceid-sell.pl b/plugins/priceid-sell.pl new file mode 100644 index 0000000..577dc13 --- /dev/null +++ b/plugins/priceid-sell.pl @@ -0,0 +1,67 @@ +# Does price-identification when selling + +# Options: +# $sell_id_tab=1 - makes TAB name the item (not very tested yet) +# $sell_id_uniq=1 - makes TAB pickup and drop the item again +# iff the price quote is not unique. + +include "priceid-buy"; + +our ($sell_id_tab,$sell_id_uniq); + +sub getslot { + if (alphakeys(-2) eq "d"){ + return alphakeys(-1); + }; + if (alphakeys(-3) eq "d" && alphakeys(-1) eq " "){ + return alphakeys(-2); + }; + return "-"; +} + + +sub do_sell_id { + my ($amount,$appearance,$type)=@_; + my $slot=getslot(); + + my %obj=%{$price_table{$type}}; + + my (@prices,@possibilities); + for my $price (keys %obj){ + my $sale=int ($price /2); + $sale = int ($price/3) if ($role eq 'Tou' && $xlvl <= 15) || $shirt; + if ($amount == $sale){ + push @prices,$price; + push @possibilities, @{$obj{$price}}; + }; + $sale=int($sale*3/4 +0.5); # round up + if ($amount == $sale){ + push @prices,$price; + push @possibilities, @{$obj{$price}}; + }; + }; + my $cost=join"/",@prices; + $cost=~ s/00//g if ($type eq "spellbook"); + my $name; + if (@possibilities <= 3){ + $name =join '/', @possibilities; + } else { + $name = $cost; + }; + + my $txt="SELL-ID: $type($appearance) $name"; + if ($sell_id_tab && $slot =~ /^[a-zA-Z]$/){ + if(@prices == 2 && $sell_id_uniq){ + $tab="\e,\ed${slot} "; + $txt.=" [TAB to try again]"; + }else{ + $tab="\e,\e#name\nn${slot}${appearance} ${name}\n"; + $txt.=" [TAB to name it]"; + }; + } + annotate($txt); +}; + +each_match qr/offers (\d+) gold pieces for your (\w+) (spellbook|potion|ring|wand)\. +Sell it\?/ => sub { do_sell_id($1,$2,$3) }; + +each_match qr/offers (\d+) gold pieces for your (scroll) labeled (.*?)\. +Sell it\?/ => sub { do_sell_id($1,$3,$2) }; From 89c23c8daa373f9030528c93cbb777b5390472ee Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 16 Nov 2012 00:36:17 +0100 Subject: [PATCH 3/6] Enhance $topline in case long messages spill into the second line. --- interhack.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interhack.pl b/interhack.pl index 4881f7e..91cabe2 100644 --- a/interhack.pl +++ b/interhack.pl @@ -950,6 +950,14 @@ sub print_ih_ttyrec } $topline = $vt->row_plaintext(1); + if ($vt->row_plaintext(2) =~ /--More--\s*$/){ + $topline=~s/ *$/ /; + $topline.=$vt->row_plaintext(2); + $topline=~s/--More--\s*$//; + }elsif ($vt->row_plaintext(2) =~ /\[ynaq\] \([yn]\)\s*$/){ + $topline=~s/ *$/ /; + $topline.=$vt->row_plaintext(2); + }; study $topline; unless ($stop_sing_pass) From 6f54ccf3a8788066a9442a534844f5ed3b601369 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 16 Nov 2012 02:07:24 +0100 Subject: [PATCH 4/6] Fix copy&paste-o for cloaks. (They don't yet work anyway) --- plugins/priceid-buy.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/priceid-buy.pl b/plugins/priceid-buy.pl index 9a22a23..c2a3b7f 100644 --- a/plugins/priceid-buy.pl +++ b/plugins/priceid-buy.pl @@ -84,7 +84,7 @@ }, 'cloak' => { 50 => ['displacement', 'protection'], - 50 => ['invisibility', 'magic resistance'], + 60 => ['invisibility', 'magic resistance'], }, ); From 325547aca39b0ef8dad5f584539f03bd3b171c0d Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 16 Nov 2012 02:11:46 +0100 Subject: [PATCH 5/6] Add $short_names functionality --- plugins/priceid-sell.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/priceid-sell.pl b/plugins/priceid-sell.pl index 577dc13..171f841 100644 --- a/plugins/priceid-sell.pl +++ b/plugins/priceid-sell.pl @@ -32,12 +32,12 @@ sub do_sell_id { $sale = int ($price/3) if ($role eq 'Tou' && $xlvl <= 15) || $shirt; if ($amount == $sale){ push @prices,$price; - push @possibilities, @{$obj{$price}}; + push @possibilities, @{$short_names{$type}{$price}||$obj{$price}}; }; $sale=int($sale*3/4 +0.5); # round up if ($amount == $sale){ push @prices,$price; - push @possibilities, @{$obj{$price}}; + push @possibilities, @{$short_names{$type}{$price}||$obj{$price}}; }; }; my $cost=join"/",@prices; From e88ff760b74af27494bd30123a68d0a0b4cae4ef Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 16 Nov 2012 02:16:44 +0100 Subject: [PATCH 6/6] Make tab functionality say exactly what it sends by default. --- plugins/priceid-sell.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/priceid-sell.pl b/plugins/priceid-sell.pl index 171f841..ae0bec9 100644 --- a/plugins/priceid-sell.pl +++ b/plugins/priceid-sell.pl @@ -58,6 +58,11 @@ sub do_sell_id { $tab="\e,\e#name\nn${slot}${appearance} ${name}\n"; $txt.=" [TAB to name it]"; }; + if(!$sell_id_tab_nice){ + $txt="Press tab to send the string: $tab"; + $txt =~ s/\n/\\n/g; + $txt =~ s/\e/\\e/g; + }; } annotate($txt); };