changeset 298:3daaeb706478

Added purse-parser, which parses output of 'look at purse' and makes it nicer to look at, plus counts the total amount of money (in gold) in the purse.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 02 Mar 2006 00:21:41 +0000
parents e11831583981
children f807316cf9a5
files ggrtf-misc.tf
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ggrtf-misc.tf	Thu Mar 02 00:21:00 2006 +0000
+++ b/ggrtf-misc.tf	Thu Mar 02 00:21:41 2006 +0000
@@ -123,6 +123,47 @@
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Manglers/calculators for some generic containers
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+/def -i prmatchadd =\
+	/if (regmatch(strcat("([0-9]+) ",{1}),mcont_match))\
+		/set mcont_total=$[mcont_total + ({P1} * {2})]%;\
+		/let mptmp=@{BCwhite}$[prprettyvalstr({P1})]@{n} @{%{3}}%{1}@{n}%;\
+		/if (mcont_str!~"")\
+			/set mcont_str=%{mcont_str}, %{mptmp}%;\
+		/else \
+			/set mcont_str=%{mptmp}%;\
+		/endif%;\
+	/endif
+
+
+/def -i misc_cpurse =\
+	/set mcont_str=%;/set mcont_total=0%;\
+	/test prmatchadd("mithril",	500,	"BCgreen")%;\
+	/test prmatchadd("batium",	100,	"Cgreen")%;\
+	/test prmatchadd("anipium",	50,	"BCyellow")%;\
+	/test prmatchadd("platinum",	10,	"Cyellow")%;\
+	/test prmatchadd("gold",	1,	"Cwhite")%;\
+	/test prmatchadd("silver",	0.6,	"BCcyan")%;\
+	/test prmatchadd("bronze",	0.4,	"Ccyan")%;\
+	/test prmatchadd("copper",	0.2,	"BCmagenta")%;\
+	/test prmatchadd("tin",		0.1,	"Cmagenta")%;\
+	/test prmatchadd("zinc",	0.05,	"Cred")%;\
+	/test prmatchadd("mowgles",	0.01,	"BCred")%;\
+	/msw It contains %{mcont_str} (Total: @{BCwhite}$[prprettyvalstr(mcont_total)]@{n} in @{BCyellow}gold@{n})
+
+/def -i -ag -mregexp -t"^It contains ([a-z0-9 ,]+) coins\.$" misc_cpurse1 =\
+	/set mcont_match=%{P1}%;/misc_cpurse
+
+/def -i -ag -mregexp -t"^It contains ([a-z0-9 ,]+)$" misc_cpurse2 =\
+	/set mcont_st=1%;/set mcont_match=%{P1}
+
+/def -i -ag -E(mcont_st==1) -mregexp -t"^([a-z0-9 ,]+) coins\.$" misc_cpurse3 =\
+	/set mcont_st=0%;/set mcont_match=%{mcont_match} %{P1}%;/misc_cpurse
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Camping
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 /def -i -p9999 -aCgreen -mregexp -t"^You (stretch yourself and consider about camping|feel a bit tired|feel like camping a little)" camp_ready =\