#include <thing/commands.h>#include <thing/description.h>#include <defines.h>#include <properties.h>#include <rooms.h>#include <language.h>#include <moving.h>#include <routingd.h>#include <bank.h>#include <combat.h>
gehe zum Quellcode dieser Datei
Makrodefinitionen | |
| #define | NEED_PROTOTYPES |
Funktionen | |
| varargs void | AddFixedObject (string str, int val, mixed ids) |
| void | RemoveFixedObject (string filename) |
| static string | SetStorageRoom (string str) |
| string | QueryStorageRoom () |
| protected void | create () |
| protected void | create_super () |
| static mixed * | GetList () |
| static int | DoList (string query_fun) |
| static int | AlwaysTrue (mixed ob) |
| static mixed | IsWeapon (mixed ob) |
| static mixed | IsArmour (mixed ob) |
| static int | NoWeaponNoArmour (mixed ob) |
| public int | CheckForDestruct (object ob) |
| static int | list (string str) |
| static varargs int | QueryBuyValue (mixed ob, object client) |
| static void | UpdateCounter (object ob, int num) |
| mixed | FindInStore (mixed x) |
| static string | buy_obj (mixed ob, int short) |
| static void | really_buy (string str, int val, object ob1, mixed ob2) |
| static int | buy (string str) |
| static private void | give_money (int value) |
| static int | make_to_money (object ob, int value) |
| static void | ask_sell (string str, object ob, int val) |
| static string | sell_obj (object ob, int short) |
| static varargs int | sell (string str, int f) |
| static int | force_sell (string str) |
| static int | evaluate (string str) |
| static int | show_obj (string str) |
| static int | ObjectCount (object ob) |
| static varargs int | QueryValue (object ob, int value, object client) |
| void | reset () |
| varargs int | CheckFindRestrictions (object ob, mixed restr, closure qp) |
| int | EvalWeapon (object ob, closure qp) |
| varargs object | FindBestWeapon (mixed type, int maxmon, int maxw, int hands, int bestwc, mixed restr) |
| int | EvalArmour (object ob, closure qp) |
| varargs mapping | FindBestArmoursT (mixed type, int maxmon, int maxw, mapping bestac, mixed restr) |
| varargs object * | FindBestArmours (mixed type, int maxmon, int maxw, mapping bestac, mixed restr) |
Variablen | |
| inherit std | trading_price |
| nosave string | storage |
| nosave mapping | ob_anz |
| nosave string * | fixed_obj |
| nosave mapping | fixed_value |
| nosave mapping | fixed_ids |
| varargs void AddFixedObject | ( | string | str, | |
| int | val, | |||
| mixed | ids | |||
| ) |
Definiert in Zeile 33 der Datei shop.c.
Benutzt fixed_ids, fixed_obj, fixed_value, i, P_IDS und P_VALUE.
Wird benutzt von create().
00034 { 00035 int i; 00036 00037 // Achtung, bei solchen Objekten muss die Blueprint initialisiert werden! 00038 if (!str) return; 00039 if (!val) val=str->QueryProp(P_VALUE); 00040 if (!ids) { 00041 if (str->QueryProp("u_ids")) // units haben keine P_IDS 00042 ids=str->QueryProp("u_ids")[0]; 00043 else ids=str->QueryProp(P_IDS); 00044 } 00045 if (!pointerp(ids)) 00046 if (stringp(ids)) ids=({ids}); else ids=({}); 00047 00048 fixed_obj+=({str}); 00049 fixed_value[str]=val; 00050 for (i=sizeof(ids)-1;i>=0;i--) 00051 fixed_ids[ids[i]]=str; 00052 }

| static int AlwaysTrue | ( | mixed | ob | ) | [static] |
| static void ask_sell | ( | string | str, | |
| object | ob, | |||
| int | val | |||
| ) | [static] |
Definiert in Zeile 492 der Datei shop.c.
Benutzt break_string(), give_money(), make_to_money(), Name() und WER.
00494 { 00495 str=lower_case(str||""); 00496 if (str=="ja"||str=="j") 00497 give_money(make_to_money(ob,val)); 00498 else write(break_string("Ok, dann behalts!", 78, 00499 Name(WER, 1)+" sagt: ")); 00500 }

| static int buy | ( | string | str | ) | [static] |
Definiert in Zeile 320 der Datei shop.c.
Benutzt _add_money(), _notify_fail(), A_DEX, break_string(), buy_obj(), FindInStore(), input_to(), M_GET, M_NOCHECK, ME, Name(), ob(), P_AC, P_KEEPER, P_PARRY, P_RESTRICTIONS, P_WC, PARRY_NOT, PARRY_ONLY, PL, QueryBuyValue(), QueryProp(), UpdateCounter(), VALID_WEAPON_TYPE, WEN und WER.
00321 { 00322 int i, val, par, dex; 00323 mixed ob, res; 00324 string dummy; 00325 00326 if (!str) { 00327 write("Was willst Du kaufen?\n"); 00328 return 1; 00329 } 00330 00331 if (stringp(QueryProp(P_KEEPER)) && !present(QueryProp(P_KEEPER), ME)) { 00332 write("Es ist niemand da, der Dich bedienen koennte.\n"); 00333 return 1; 00334 } 00335 00336 _notify_fail(break_string("Das kann ich in meinem Lager nicht finden.",78, 00337 Name(WER)+" sagt: ")); 00338 00339 if (sscanf(str,"%d%s",i,dummy)>0 && i>0) { 00340 if (dummy==" ab") return 0; 00341 ob=FindInStore(i); 00342 } 00343 else ob=FindInStore(str); 00344 00345 if (!ob) return 0; 00346 00347 if (str = buy_obj(ob,0)) 00348 { 00349 write(break_string(str,78,Name(WER)+" sagt: ")); 00350 return 1; 00351 } 00352 00353 val = QueryBuyValue(ob,PL); 00354 00355 if (PL->QueryMoney() < val) 00356 { 00357 write(break_string(capitalize(ob->QueryPronoun(WER))+" wuerde "+val+ 00358 " Muenzen kosten, und Du hast nur "+PL->QueryMoney()+".",78, 00359 Name(WER)+" bedauert: ")); 00360 return 1; 00361 } 00362 00363 if ((res = ob->QueryProp(P_RESTRICTIONS)) && mappingp(res) && 00364 (res = call_other("/std/restriction_checker","check_restrictions",PL,res)) && 00365 stringp(res)) 00366 { 00367 _notify_fail(break_string("Du koenntest "+ob->name(WEN,2)+" nicht " 00368 "verwenden. Grund: "+res+"Moechtest Du "+ob->QueryPronoun(WEN)+ 00369 " dennoch kaufen? (ja/nein)",78,Name(WER)+" sagt: ")); 00370 00371 input_to("really_buy",0,val,PL,ob); 00372 return 0; 00373 } 00374 00375 par = (int)ob->QueryProp(P_PARRY); 00376 dex = (int)PL->QueryAttribute(A_DEX); 00377 00378 if ((((par < PARRY_ONLY) && ((dex + 8) * 10) < ob->QueryProp(P_WC)) || 00379 ((par > PARRY_NOT) && ((dex + 5) * 2) < ob->QueryProp(P_AC))) && 00380 VALID_WEAPON_TYPE(ob)) 00381 { 00382 _notify_fail(break_string("Du koenntest "+ob->name(WEN,2)+" nicht " 00383 "zuecken, da Deine Geschicklichkeit dafuer nicht ausreicht. Moechtest " 00384 "Du "+ob->QueryPronoun(WEN)+" dennoch kaufen? (ja/nein)",78, 00385 Name(WER)+" sagt: ")); 00386 00387 input_to("really_buy",0,val,PL,ob); 00388 return 0; 00389 } 00390 00391 PL->AddMoney(-val); 00392 _add_money(val); 00393 if (stringp(ob)) ob=clone_object(ob); // Staendig verfuegbares Objekt? 00394 if (ob->move(PL,M_GET)<=0){ 00395 write("Du kannst das nicht mehr tragen!\n"); 00396 ob->move(ME,M_NOCHECK); /* Now the object he bought lies on the floor */ 00397 } 00398 else write(break_string("Du kaufst "+ob->name(WEN, 1)+".", 78)); 00399 say(break_string(PL->Name(WER)+" kauft "+ob->name(WEN)+".", 78)); 00400 UpdateCounter(ob, -1); 00401 return 1; 00402 }

| static string buy_obj | ( | mixed | ob, | |
| int | short | |||
| ) | [static] |
| varargs int CheckFindRestrictions | ( | object | ob, | |
| mixed | restr, | |||
| closure | qp | |||
| ) |
Definiert in Zeile 758 der Datei shop.c.
Wird benutzt von FindBestArmoursT() und FindBestWeapon().

| public int CheckForDestruct | ( | object | ob | ) |
Definiert in Zeile 179 der Datei shop.c.
Benutzt IsArmour(), IsWeapon(), KEEP_ARMOUR_CLASS, P_AC, P_DAMAGED, P_DEFEND_FUNC, P_HIT_FUNC, P_NOBUY und P_WC.
Wird benutzt von make_to_money().
00180 { 00181 string str; 00182 /* 00183 * P_NOBUY - Objekte auf jeden Fall zerstoeren 00184 */ 00185 if(ob->QueryProp(P_NOBUY)) return 1; 00186 /* 00187 * Beschaedigte Objekte werden ebenfalls zerstoert 00188 */ 00189 if(ob->QueryProp(P_DAMAGED)) return 1; 00190 /* 00191 * Ruestungen wenn sie a) eine DefendFunc definiert haben oder 00192 * b) ueber der in KEEP_ARMOUR_CLASS definierten AC 00193 * liegen (siehe /sys/combat.h) 00194 */ 00195 if(str = IsArmour(ob)) 00196 { 00197 if(objectp(ob->QueryProp(P_DEFEND_FUNC))) return 1; 00198 if(ob->QueryProp(P_AC) >= KEEP_ARMOUR_CLASS[str]) return 1; 00199 return 0; 00200 } 00201 /* 00202 * Waffen wenn sie a) 1-haendig sind und eine WC > 120 besitzen oder 00203 * b) 2-haendig sind und eine WC > 150 besitzen oder aber 00204 * c) eine HitFunc definiert haben 00205 */ 00206 if(str = IsWeapon(ob)) 00207 { 00208 if(ob->QueryProp(P_NR_HANDS) > 1 && ob->QueryProp(P_WC) > 150) return 1; 00209 if(ob->QueryProp(P_NR_HANDS) < 2 && ob->QueryProp(P_WC) > 120) return 1; 00210 if(objectp(ob->QueryProp(P_HIT_FUNC))) return 1; 00211 return 0; 00212 } 00213 return 0; 00214 }


| protected void create | ( | ) |
Definiert in Zeile 76 der Datei shop.c.
Benutzt AddCmd(), AddFixedObject(), create(), fixed_ids, fixed_obj, fixed_value, MALE, ME, ob_anz, P_GENDER, P_NAME, P_ROOM_TYPE, QueryProp(), ROUTER, RT_SHOP, SetProp(), SetStorageRoom(), SetTradingData() und TARGET_SHOP.
00077 { 00078 object router; 00079 trading_price::create(); 00080 00081 SetProp( P_NAME, "Haendler" ); 00082 SetProp( P_GENDER, MALE ); 00083 SetProp( P_ROOM_TYPE, QueryProp(P_ROOM_TYPE) | RT_SHOP ); 00084 00085 AddCmd("zeige","list"); 00086 AddCmd(({"kauf","kaufe","bestell","bestelle"}),"buy"); 00087 AddCmd(({"verkauf","verkaufe","verk"}),"sell"); 00088 AddCmd(({"versetz","versetze"}),"force_sell"); 00089 AddCmd(({"schaetz","schaetze"}),"evaluate"); 00090 AddCmd(({"untersuche","unt"}), "show_obj"); 00091 00092 SetStorageRoom("d/gebirge/room/zstore"); 00093 SetTradingData(50000,300,3); 00094 00095 ob_anz=([]); 00096 fixed_obj=({});fixed_value=([]);fixed_ids=([]); 00097 00098 AddFixedObject("/obj/boerse", 80,({ "boerse","geldboerse"})); 00099 00100 if (!clonep(ME) && objectp(router=find_object(ROUTER))) 00101 router->RegisterTarget(TARGET_SHOP,object_name(ME)); 00102 }

| protected void create_super | ( | ) |
Definiert in Zeile 104 der Datei shop.c.
Benutzt set_next_reset().
00104 { 00105 set_next_reset(-1); 00106 }

| static int DoList | ( | string | query_fun | ) | [static] |
Definiert in Zeile 134 der Datei shop.c.
Wird benutzt von list().
00135 { 00136 int i, si, indent; 00137 mixed *output; 00138 string out; 00139 00140 output=GetList(); 00141 indent=0; 00142 if (!(si=sizeof(output))) { 00143 write("Im Moment sind wir leider VOELLIG ausverkauft!\n"); 00144 return 1; 00145 } 00146 out=""; 00147 for (i=0; i<si; i++) { 00148 if (call_other(ME, query_fun, output[i][1])) { 00149 indent=!indent; 00150 out+=sprintf("%3d. %s", i+1, output[i][0]); 00151 if (!indent) 00152 out+="\n"; 00153 else out+=" | "; 00154 } 00155 } 00156 if (indent) out+="\n"; 00157 PL->More(out); 00158 out=0; 00159 return 1; 00160 }


| int EvalArmour | ( | object | ob, | |
| closure | qp | |||
| ) |
Definiert in Zeile 810 der Datei shop.c.
Benutzt P_AC und P_EFFECTIVE_AC.
Wird benutzt von FindBestArmoursT().
00810 { 00811 int ac,val; 00812 00813 ac=funcall(qp,P_AC); 00814 val=funcall(qp,P_EFFECTIVE_AC); 00815 if (val>ac) ac=val; 00816 return ac; 00817 }

| static int evaluate | ( | string | str | ) | [static] |
Definiert in Zeile 647 der Datei shop.c.
Benutzt _notify_fail(), break_string(), deep_present(), ME, Name(), ob(), P_AMOUNT, P_KEEPER, P_PLURAL, P_VALUE, PL, QueryProp(), QuerySellValue(), sell_obj() und WER.
00648 { 00649 object ob; 00650 int val,rval; 00651 00652 if (!str) return 0; 00653 if(stringp(QueryProp(P_KEEPER)) && !present(QueryProp(P_KEEPER), ME)) { 00654 write("Es ist niemand da, der Dich bedienen koennte.\n"); 00655 return 1; 00656 } 00657 00658 ob=present(str, ME); 00659 if (!ob) ob=deep_present(str,PL); 00660 if (!ob) { 00661 write("Hm? "+capitalize(str)+"? Wovon redest Du?\n"); 00662 return 1; 00663 } 00664 if (living(ob)) { 00665 _notify_fail("Nanu, seit wann werden hier Lebewesen verkauft?\n"); 00666 return 0; 00667 } 00668 if (str=sell_obj(ob, 0)) { 00669 write(break_string(str, 78, Name(WER)+" sagt: ")); 00670 return 1; 00671 } 00672 rval=ob->QueryProp(P_VALUE); 00673 if (rval) { 00674 val=QuerySellValue(ob, PL); 00675 if (rval==val) { 00676 write("Naja, ich denke, " +val+ " Muenze"+ 00677 (val==1 ? "" : "n") + 00678 " waere"+(ob->QueryProp(P_AMOUNT)>1?"n ":" ")+ 00679 (ob->QueryPronoun(WER))+" schon wert.\n"); 00680 } 00681 else if (val) { 00682 write("Oh, nach der aktuellen Marktlage kann ich nur "+val+" Muenze"+ 00683 (val==1?"":"n")+" bezahlen, obwohl " 00684 +(QueryProp(P_PLURAL) ? "sie" : "es") 00685 +" eigentlich "+rval+ 00686 " Muenze"+(rval==1?"":"n")+" wert ist.\n"); 00687 } 00688 else write("Ich bin vollkommen pleite. Tut mir leid.\n"); 00689 } 00690 else write("Das ist voellig wertlos.\n"); 00691 return 1; 00692 }

| int EvalWeapon | ( | object | ob, | |
| closure | qp | |||
| ) |
Definiert in Zeile 762 der Datei shop.c.
Benutzt P_EFFECTIVE_WC und P_WC.
Wird benutzt von FindBestWeapon().
00762 { 00763 int wc,val; 00764 00765 wc=funcall(qp,P_WC); 00766 val=funcall(qp,P_EFFECTIVE_WC); 00767 if (val>wc) wc=val; 00768 return wc; 00769 }

| varargs object* FindBestArmours | ( | mixed | type, | |
| int | maxmon, | |||
| int | maxw, | |||
| mapping | bestac, | |||
| mixed | restr | |||
| ) |
Definiert in Zeile 860 der Datei shop.c.
Benutzt FindBestArmoursT().
00861 { 00862 return m_values(FindBestArmoursT(type,maxmon,maxw,bestac,restr)); 00863 }

| varargs mapping FindBestArmoursT | ( | mixed | type, | |
| int | maxmon, | |||
| int | maxw, | |||
| mapping | bestac, | |||
| mixed | restr | |||
| ) |
Definiert in Zeile 819 der Datei shop.c.
Benutzt CheckFindRestrictions(), EvalArmour(), ob(), P_ARMOUR_TYPE, P_VALUE, P_WEIGHT, qp, QueryBuyFact(), storage und sum.
Wird benutzt von FindBestArmours().
00820 { 00821 object ob; 00822 string otype; 00823 int ac,val,sum,w,wsum; 00824 mapping bestob,bestval,bestw; 00825 closure qp; 00826 00827 if (!stringp(storage) || !objectp(ob=find_object(storage))) return ([]); 00828 if (!maxmon) maxmon=100000; 00829 if (!maxw) maxw=75000; 00830 if (val=QueryBuyFact()) maxmon=(maxmon*100)/val; 00831 if (type && !pointerp(type) && !mappingp(type)) type=({type}); 00832 if (!mappingp(bestac)) bestac=([]); 00833 bestob=([]);bestval=([]);bestw=([]); 00834 00835 for (ob=first_inventory(ob);ob;ob=next_inventory(ob)) { 00836 qp=symbol_function("QueryProp",ob); 00837 if (!otype=funcall(qp,P_ARMOUR_TYPE)) continue; 00838 if (type && member(type,otype)<0) continue; 00839 ac=EvalArmour(ob,qp); 00840 if (ac<bestac[otype]) continue; 00841 w=funcall(qp,P_WEIGHT); 00842 if (wsum-bestw[otype]+w>maxw) continue; 00843 val=funcall(qp,P_VALUE); 00844 if (sum-bestval[otype]+val>maxmon) continue; 00845 if (bestob[otype] && ac<=bestac[otype]) { 00846 if (val>bestval[otype]) continue; 00847 else if (val==bestval[otype] && w>bestw[otype]) continue; 00848 } 00849 if (CheckFindRestrictions(ob,restr,qp)) continue; 00850 sum=sum-bestval[otype]+val; 00851 wsum=wsum-bestw[otype]+w; 00852 bestob[otype]=ob; 00853 bestac[otype]=ac; 00854 bestval[otype]=val; 00855 bestw[otype]=w; 00856 } 00857 return bestob; 00858 }


| varargs object FindBestWeapon | ( | mixed | type, | |
| int | maxmon, | |||
| int | maxw, | |||
| int | hands, | |||
| int | bestwc, | |||
| mixed | restr | |||
| ) |
Definiert in Zeile 771 der Datei shop.c.
Benutzt CheckFindRestrictions(), EvalWeapon(), ob(), P_VALUE, P_WEAPON_TYPE, P_WEIGHT, qp, QueryBuyFact() und storage.
00772 { 00773 object bestob,ob; 00774 string otype; 00775 int wc,bestval,val,w,bestw; 00776 closure qp; 00777 00778 if (!stringp(storage) || !objectp(ob=find_object(storage))) return 0; 00779 if (!maxmon) maxmon=100000; 00780 if (!maxw) maxw=75000; 00781 if (!hands) hands=2; 00782 if (val=QueryBuyFact()) maxmon=(maxmon*100)/val; 00783 if (type && !pointerp(type) && !mappingp(type)) type=({type}); 00784 00785 for (ob=first_inventory(ob);ob;ob=next_inventory(ob)) { 00786 qp=symbol_function("QueryProp",ob); 00787 if (!otype=funcall(qp,P_WEAPON_TYPE)) continue; 00788 if (type && member(type,otype)<0) continue; 00789 wc=EvalWeapon(ob,qp); 00790 if (wc<bestwc) continue; 00791 if (funcall(qp,P_NR_HANDS)>hands) continue; 00792 w=funcall(qp,P_WEIGHT); 00793 if (w>maxw) continue; 00794 val=funcall(qp,P_VALUE); 00795 if (val>maxmon) continue; 00796 if (bestob && wc<=bestwc) { 00797 if (val>bestval) continue; 00798 else if (val==bestval && w>bestw) continue; 00799 } 00800 if (val>bestval && bestob && wc<=bestwc) continue; 00801 if (CheckFindRestrictions(ob,restr,qp)) continue; 00802 bestob=ob; 00803 bestwc=wc; 00804 bestval=val; 00805 bestw=w; 00806 } 00807 return bestob; 00808 }

| mixed FindInStore | ( | mixed | x | ) |
Definiert in Zeile 251 der Datei shop.c.
Benutzt fixed_ids, GetList(), list, ME und storage.
Wird benutzt von buy() und show_obj().
00252 { 00253 mixed *list; 00254 object store; 00255 string res; 00256 00257 if (intp(x)) { 00258 list = GetList(); 00259 if (x<1 || x>sizeof(list)) return 0; 00260 return list[x-1][1]; 00261 } 00262 if (stringp(x)) { 00263 if (res=fixed_ids[x]) return res; // Staendig verfuegbares Objekt 00264 call_other(storage, "_register_shop", ME); 00265 store=find_object(storage); 00266 if (!store) return 0; 00267 return present(x,store); 00268 } 00269 return 0; 00270 }


| static int force_sell | ( | string | str | ) | [static] |
| static mixed* GetList | ( | ) | [static] |
Definiert in Zeile 108 der Datei shop.c.
Benutzt fixed_obj, i, ME, output, PL, QueryBuyValue(), storage und store.
Wird benutzt von DoList() und FindInStore().
00109 { 00110 object store; 00111 int i,s; 00112 mixed *output, tmp, str; 00113 string comp; 00114 mapping tmp2; 00115 00116 output=({}); 00117 call_other(storage, "_register_shop", ME); 00118 if (!objectp(store=find_object(storage))) return output; 00119 tmp=fixed_obj+all_inventory(store); tmp2=([]); 00120 00121 for (i=sizeof(tmp)-1,s=1;i>=0;i--) { 00122 str=({({sprintf("%-25.25s%7.7d", (tmp[i]->short()||"???")[0..<3], 00123 QueryBuyValue(tmp[i], PL)), tmp[i]})}); 00124 comp=str[0][0][0..25]; 00125 if (!tmp2[comp]) { 00126 tmp2[comp]=s++; 00127 output+=str; 00128 } 00129 else output[tmp2[comp]-1][0] = str[0][0]; 00130 } 00131 return output; 00132 }


| static private void give_money | ( | int | value | ) | [static] |
Definiert in Zeile 404 der Datei shop.c.
Benutzt break_string(), M_MOVE_ALL, M_NOCHECK, ME, mon, Name(), P_AMOUNT, PL und WER.
Wird benutzt von ask_sell() und sell().
00406 { 00407 if (!value) return; 00408 write(break_string(Name(WER, 1)+" zahlt Dir "+value+" Goldstueck" 00409 +(value==1?".":"e."), 78)); 00410 if ((PL->AddMoney(value))<=0) { 00411 object mon; 00412 00413 write("Du kannst das Geld nicht mehr tragen!\n"); 00414 mon=clone_object("/obj/money"); 00415 mon->SetProp(P_AMOUNT,value); 00416 mon->move(ME,M_MOVE_ALL|M_NOCHECK); 00417 } 00418 }


| static mixed IsArmour | ( | mixed | ob | ) | [static] |
Definiert in Zeile 168 der Datei shop.c.
Benutzt P_ARMOUR_TYPE.
00169 { return ob->QueryProp(P_ARMOUR_TYPE); }
| static mixed IsWeapon | ( | mixed | ob | ) | [static] |
Definiert in Zeile 165 der Datei shop.c.
Benutzt P_WEAPON_TYPE.
Wird benutzt von CheckForDestruct().
00166 { return ob->QueryProp(P_WEAPON_TYPE); }

| static int list | ( | string | str | ) | [static] |
Definiert in Zeile 216 der Datei shop.c.
Benutzt _notify_fail() und DoList().
00217 { 00218 _notify_fail("Bitte 'zeige', 'zeige waffen', 'zeige ruestungen' oder\n'zeige verschiedenes' eingeben.\n"); 00219 if (!str) return DoList("AlwaysTrue"); 00220 if (!stringp(str)) return 0; 00221 if (strlen(str)<3) return 0; 00222 str=str[0..2]; 00223 if (str=="waf") return DoList("IsWeapon"); 00224 if (str=="ver") return DoList("NoWeaponNoArmour"); 00225 if (str=="rue") return DoList("IsArmour"); 00226 return 0; 00227 }

| static int make_to_money | ( | object | ob, | |
| int | value | |||
| ) | [static] |
Definiert in Zeile 420 der Datei shop.c.
Benutzt _add_money(), break_string(), CheckForDestruct(), destruct(), FEMALE, M_GET, M_PUT, ME_CANT_BE_DROPPED, Name(), P_CURRENT_MONEY, P_DAMAGED, P_GENDER, P_NODROP, P_SHOP_PERCENT_LEFT, PL, QueryProp(), storage, UpdateCounter(), WEM, WEN und WER.
Wird benutzt von ask_sell() und sell().
00423 { 00424 string str; 00425 int ret; 00426 00427 if (!objectp(ob) || environment(ob)==find_object(storage)) { 00428 write(break_string(Name(WER, 1)+" wundert sich ueber Dich.", 78)); 00429 return 0; 00430 } 00431 if (value>QueryProp(P_CURRENT_MONEY)) { 00432 write(break_string("Ich hab das Geld leider nicht mehr.", 78, 00433 Name(WER, 1)+" sagt: ")); 00434 return 0; 00435 } 00436 00437 if (CheckForDestruct(ob) > 0) // soll ob zerstoert werden? 00438 { 00439 ret = ob->move(storage,M_PUT|M_GET); 00440 00441 if (ret > 0) // Sonst werden auch Sachen zerstoert, die man nicht 00442 { // weglegen kann 00443 say(break_string(PL->Name()+" verkauft "+ob->name(WEN)+".", 78)); 00444 00445 if(ob->QueryProp(P_DAMAGED)) // Andere Meldung bei beschaedigten 00446 { // Objekten ... 00447 write(break_string(Name(WER,1)+" findet zwar keinen Gefallen an " 00448 +ob->name(WEM,1)+", nimmt "+ob->QueryPronoun(WEN)+" Dir zuliebe " 00449 "aber trotzdem.",78)); 00450 } 00451 else 00452 { 00453 write(break_string(Name(WER, 1)+" findet Gefallen an " 00454 +ob->name(WEM, 1) + " und legt "+ob->QueryPronoun(WEN) 00455 +" zu "+(QueryProp(P_GENDER)==FEMALE?"ihren":"seinen") 00456 +" Privatsachen.", 78)); 00457 } 00458 /* Er zahlt Dir "+value+" Muenze"+(value==1?"":"n")+" dafuer.", 78)); */ 00459 _add_money(-value); 00460 _add_money(value*QueryProp(P_SHOP_PERCENT_LEFT)/100); // Wegen Zerstoerung des Objektes 00461 UpdateCounter(ob,1); 00462 ob->remove(); 00463 if (ob) destruct(ob); 00464 return value; 00465 } 00466 else if (ret == ME_CANT_BE_DROPPED) { 00467 if ((str=ob->QueryProp(P_NODROP)) && stringp(str)) { 00468 write(str); 00469 return 0; 00470 } 00471 write(break_string("Du kannst "+ob->name(WEN,1)+" nicht verkaufen!", 78)); 00472 return 0; 00473 } 00474 else write(break_string(ob->Name(WER)+" interessiert mich nicht.", 78, 00475 Name(WER, 1)+" sagt: ")); 00476 } 00477 else if ((ret=(ob->move(storage,M_PUT|M_GET)))>0) { 00478 say(break_string(PL->Name(WER)+" verkauft "+ob->name(WEN)+".", 78)); 00479 _add_money(-value); 00480 UpdateCounter(ob,1); 00481 return value; 00482 } 00483 else if (ret == ME_CANT_BE_DROPPED) { 00484 if ((str=ob->QueryProp(P_NODROP)) && stringp(str)) 00485 write(str); 00486 else write(break_string("Du kannst "+ob->name(WEN,1)+" nicht verkaufen!", 78)); 00487 } 00488 else write(break_string("Du kannst "+ob->name(WEN,1)+" nicht verkaufen!", 78)); 00489 return 0; 00490 }


| static int NoWeaponNoArmour | ( | mixed | ob | ) | [static] |
Definiert in Zeile 171 der Datei shop.c.
Benutzt P_ARMOUR_TYPE und P_WEAPON_TYPE.
00172 { return (!ob->QueryProp(P_WEAPON_TYPE) && !ob->QueryProp(P_ARMOUR_TYPE)); }
| static int ObjectCount | ( | object | ob | ) | [static] |
| static varargs int QueryBuyValue | ( | mixed | ob, | |
| object | client | |||
| ) | [static] |
Definiert in Zeile 229 der Datei shop.c.
Benutzt fixed_value, QueryBuyFact() und QueryBuyValue().
00230 { 00231 if (objectp(ob)) 00232 return trading_price::QueryBuyValue(ob, client); 00233 return (fixed_value[ob]*QueryBuyFact(client))/100; 00234 }

| string QueryStorageRoom | ( | ) |
| static varargs int QueryValue | ( | object | ob, | |
| int | value, | |||
| object | client | |||
| ) | [static] |
Definiert in Zeile 726 der Datei shop.c.
Benutzt mymoney, P_CURRENT_MONEY, Query(), QueryProp() und QueryValue().
00727 { 00728 int new_value, mymoney; 00729 00730 if (!objectp(ob)) return 0; 00731 if (Query("laden::compat")) { 00732 new_value=(value>1000?1000:value); 00733 mymoney = QueryProp(P_CURRENT_MONEY); 00734 if (new_value>mymoney) 00735 return (mymoney>0?mymoney:0); 00736 else return new_value; 00737 } 00738 return ::QueryValue(ob, value, client); 00739 }

| static void really_buy | ( | string | str, | |
| int | val, | |||
| object | ob1, | |||
| mixed | ob2 | |||
| ) | [static] |
Definiert in Zeile 275 der Datei shop.c.
Benutzt _add_money(), _notify_fail(), break_string(), M_GET, M_NOCHECK, ME, Name(), PL, UpdateCounter(), WEN und WER.
00276 { 00277 object ob3; 00278 00279 _notify_fail(break_string("Gut, Du kannst es Dir ja jederzeit " 00280 "noch anders ueberlegen.",78,Name(WER)+" sagt: ")); 00281 00282 if(!str || !stringp(str) || str == "nein" || str == "n") 00283 { 00284 return; 00285 } 00286 if(str != "ja" && str != "j") 00287 { 00288 return; 00289 } 00290 00291 ob1->AddMoney(-val); 00292 _add_money(val); 00293 00294 if(stringp(ob2)) 00295 { 00296 ob3 = clone_object(ob2); // Staendig verfuegbares Objekt? 00297 } 00298 else 00299 { 00300 ob3 = ob2; // Ansonsten uebernehmen wir das Objekt. 00301 } 00302 00303 if (ob3->move(ob1,M_GET) <= 0) // Kann der Spieler das Objekt tragen? 00304 { 00305 write(break_string("Du kannst "+ob3->name(WEN,1)+" nicht mehr tragen. " 00306 "Ich lege "+ob3->QueryPronoun(WEN)+" hier auf den Boden.",78, 00307 Name(WER)+" sagt: ")); 00308 ob3->move(ME,M_NOCHECK); // Nein :-) 00309 } 00310 else 00311 { 00312 write(break_string("Du kaufst "+ob3->name(WEN,1)+".", 78)); 00313 } 00314 00315 say(break_string(PL->Name(WER)+" kauft "+ob3->name(WEN)+".",78)); 00316 UpdateCounter(ob3,-1); 00317 return; 00318 }

| void RemoveFixedObject | ( | string | filename | ) |
Definiert in Zeile 54 der Datei shop.c.
Benutzt fixed_ids, fixed_obj, fixed_value, i und m_delete().
00055 { 00056 int i; 00057 string *en; 00058 if(!filename || !sizeof(fixed_obj))return ; 00059 if(member(fixed_obj,filename)==-1)return ; 00060 fixed_obj -= ({ filename }); 00061 fixed_value = m_delete(fixed_value,filename); 00062 for(i=sizeof(en=m_indices(fixed_ids))-1;i>=0;i--) 00063 if(fixed_ids[en[i]] == filename) 00064 fixed_ids = m_delete(fixed_ids,en[i]); 00065 }

| void reset | ( | void | ) |
Definiert in Zeile 741 der Datei shop.c.
Benutzt keys, m_delete(), ob_anz und reset().
00742 { 00743 mixed *keys; 00744 int i; 00745 00746 trading_price::reset(); 00747 00748 if (!mappingp(ob_anz)) 00749 return; 00750 keys=m_indices(ob_anz); 00751 for (i=sizeof(keys)-1;i>=0;i--) { 00752 ob_anz[keys[i]]=ob_anz[keys[i]]*7/8; 00753 if (!ob_anz[keys[i]]) 00754 efun::m_delete(ob_anz,keys[i]); 00755 } 00756 }

| static varargs int sell | ( | string | str, | |
| int | f | |||
| ) | [static] |
Definiert in Zeile 520 der Datei shop.c.
Benutzt break_string(), give_money(), input_to(), make_to_money(), ME, name, Name(), notify_fail(), obs, P_DAMAGED, P_KEEP_ON_SELL, P_KEEPER, P_NODROP, P_PLURAL, P_VALUE, P_WIELDED, P_WORN, PL, PUT_GET_DROP, PUT_GET_TAKE, QueryProp(), QuerySellValue(), sell_obj(), storage, WEN und WER.
Wird benutzt von force_sell().
00521 { 00522 int i, val, oval, tmp; 00523 object *obs; 00524 00525 if (stringp(QueryProp(P_KEEPER)) && !present(QueryProp(P_KEEPER),ME)) { 00526 write("Es ist niemand da, der Dich bedienen koennte.\n"); 00527 return 1; 00528 } 00529 00530 if (!str) { 00531 notify_fail("Was moechtest Du denn verkaufen?\n"); 00532 return 0; 00533 } 00534 00535 /* Ergebnis von find_obs() sollte unifiziert werden, damit ein mehrfach 00536 gefundenes Objekt nicht mehrfach versucht wird zu verkaufen. 00537 Beispiel: Objekt hat P_NOBUY gesetzt und mehrere IDs gesetzt. Wenn 00538 ein Spieler es mit "verkaufe ID1 und ID2" versucht zu verkaufen, 00539 wuerde das einen Bug ausloesen. Derselbe Bug entsteht, wenn man mit 00540 "verkaufe ID1 und ID1" verkauft. */ 00541 obs = PL->find_obs(str, PUT_GET_DROP); 00542 /* Erst im Inventar schauen, dann im Environment. find_obs() ohne 2. 00543 Parameter macht das standardmaessig andersherum. 00544 TODO: Aenderung ueberpruefen, sobald das neue put_and_get.c 00545 eingebaut wurde. */ 00546 if ( !sizeof(obs) ) 00547 obs = PL->find_obs(str, PUT_GET_TAKE) || ({}); 00548 obs = m_indices(mkmapping(obs)); 00549 if (!i=sizeof(obs)) { 00550 notify_fail("Was moechtest Du denn verkaufen?\n"); 00551 return 0; 00552 } 00553 call_other(storage, "_register_shop", ME); 00554 if (i==1) { 00555 if (str=sell_obj(obs[0], 0)) { 00556 write(break_string(str, 78, Name(WER, 1)+" sagt: ")); 00557 return 1; 00558 } 00559 if ((oval=obs[0]->QueryProp(P_VALUE))<=0) { 00560 write(break_string(obs[0]->Name(WER) 00561 +(obs[0]->QueryProp(P_PLURAL) ? " haben" : " hat") 00562 +" keinen materiellen Wert, tut mir leid.", 78, 00563 Name(WER, 1)+" sagt: ")); 00564 return 1; 00565 } 00566 val=QuerySellValue(obs[0], PL); 00567 if (!val) { 00568 write(break_string("Ich bin absolut pleite. Tut mir aufrichtig leid.", 00569 78, Name(WER, 1)+" sagt: ")); 00570 return 1; 00571 } 00572 if (val==oval || f) { 00573 give_money(make_to_money(obs[0], val)); 00574 return 1; 00575 } 00576 if (str=obs[0]->QueryProp(P_NODROP)) { 00577 if (stringp(str)) 00578 write(str); 00579 else write(break_string("Du kannst "+obs[0]->name(WEN,1) 00580 +" nicht verkaufen!", 78)); 00581 return 1; 00582 } 00583 00584 if (obs[0]->QueryProp(P_DAMAGED)) // Bei beschaedigten Objekten gibt 00585 { // es auch hier eine andere Meldung 00586 write(break_string("Da "+obs[0]->name(WER)+" beschaedigt " 00587 +(obs[0]->QueryProp(P_PLURAL)?"sind":"ist")+", kann ich Dir " 00588 "nur "+val+" Muenze"+(val == 1?"":"n")+" dafuer bieten. Und " 00589 "damit mache ich noch Verlust! Nimmst Du mein Angebot an? " 00590 "(ja/nein)",78,Name(WER,1)+" sagt: ")); 00591 } 00592 else // Default 00593 { 00594 write(break_string(Name(WER, 1)+" sagt: " 00595 +"Nach der aktuellen Marktlage kann ich Dir dafuer nur " 00596 +val+" Muenze"+(val==1?"":"n")+" bieten, obwohl " 00597 +obs[0]->name(WER)+" eigentlich "+oval+" Muenze" 00598 +(oval==1?"":"n")+" wert waere. Willst Du " 00599 +(QueryProp(P_PLURAL) ? "sie" : "es") 00600 +" mir dafuer ueberlassen? (ja/nein)", 78)); 00601 } 00602 input_to("ask_sell",0,obs[0],val); 00603 return 1; 00604 } 00605 for (--i; i>=0 && get_eval_cost()>50000; i--) { 00606 if (oval=obs[i]->QueryProp(P_VALUE)) { 00607 if (obs[i]->QueryProp(P_KEEP_ON_SELL)==getuid(PL) 00608 || obs[i]->QueryProp(P_WORN) || obs[i]->QueryProp(P_WIELDED)) 00609 write(break_string(obs[i]->Name(WER)+": Du behaeltst " 00610 +obs[i]->name(WEN)+".", 78)); 00611 else if (str=sell_obj(obs[i], 1)) 00612 write(break_string(obs[i]->Name(WER)+": "+str, 78)); 00613 else { 00614 tmp=QuerySellValue(obs[i], PL); 00615 if (!tmp) { 00616 write(break_string( 00617 "Ich bin absolut pleite. Tut mir aufrichtig leid.", 78, 00618 Name(WER, 1)+" sagt: ")); 00619 break; 00620 } 00621 else if (!f && tmp*10<oval) 00622 write(break_string(obs[i]->Name(WER)+": "+Name(WER, 1) 00623 +" bietet Dir aber nur "+tmp+" Goldstueck" 00624 +(tmp>1 ? "e" : "")+" dafuer.", 78)); 00625 else { 00626 str=(obs[i]->Name(WER)); 00627 if (tmp=make_to_money(obs[i], tmp)) { 00628 write(break_string(str+": "+Name(WER, 1) 00629 +" gibt Dir dafuer "+tmp+" Goldstueck" 00630 +(tmp==1?".":"e."), 78)); 00631 val+=tmp; 00632 } 00633 } 00634 } 00635 } 00636 } 00637 if (!val) 00638 write(break_string("Hmmm, Du hast aber nicht besonders viel zu bieten...", 00639 78, Name(WER)+" sagt: ")); 00640 else give_money(val); 00641 return 1; 00642 }


| static string sell_obj | ( | object | ob, | |
| int | short | |||
| ) | [static] |
Definiert in Zeile 502 der Datei shop.c.
Benutzt BLUE_NAME, P_CURSED, P_NOSELL, WEN und WER.
Wird benutzt von evaluate() und sell().
00505 { mixed nosell; 00506 00507 if (BLUE_NAME(ob)=="/obj/money") 00508 return "Das waere ja wohl Unsinn, oder ...?"; 00509 if (nosell=ob->QueryProp(P_NOSELL)) 00510 { 00511 if (stringp(nosell)) 00512 return nosell; 00513 return ("Du kannst "+ob->name(WEN,1)+" nicht verkaufen!"); 00514 } 00515 if (ob->QueryProp(P_CURSED)) 00516 return (ob->Name(WER,1)+" ist mir irgendwie ungeheuer! Das kannst Du nicht verkaufen!"); 00517 return 0; 00518 }

| static string SetStorageRoom | ( | string | str | ) | [static] |
| static int show_obj | ( | string | str | ) | [static] |
Definiert in Zeile 694 der Datei shop.c.
Benutzt _notify_fail(), FindInStore(), ob(), PL, QueryBuyValue() und WER.
00695 { 00696 int i; 00697 string was; 00698 mixed ob; 00699 00700 if (!str) return 0; 00701 if (sscanf(str,"%s im laden",was)>0 || sscanf(str,"%s in laden",was)>0) { 00702 _notify_fail("Das kann ich im Lager nicht finden.\n"); 00703 ob=FindInStore(was); 00704 } else if (sscanf(str,"%d",i)>0 && i>0) { 00705 _notify_fail("Das kann ich im Lager nicht finden.\n"); 00706 ob=FindInStore(i); 00707 } 00708 if (!ob) return 0; 00709 write(ob->Name(WER)+":\n"+ob->long()+capitalize(ob->QueryPronoun()) 00710 +" kostet "+QueryBuyValue(ob,PL)+" Muenzen.\n"); 00711 return 1; 00712 }

| static void UpdateCounter | ( | object | ob, | |
| int | num | |||
| ) | [static] |
Definiert in Zeile 236 der Datei shop.c.
Benutzt BLUE_NAME, m_delete() und ob_anz.
00237 { 00238 string tmp; 00239 mixed a; 00240 00241 if (!num || !objectp(ob)) return; 00242 tmp=BLUE_NAME(ob); 00243 if (tmp[0..2]!="/d/" && tmp[0..8]!="/players/") tmp=ob->short()+tmp; 00244 a=ob_anz[tmp]+num; 00245 if (a<0) a=0; 00246 if (!a) 00247 efun::m_delete(ob_anz,tmp); 00248 else ob_anz[tmp]=a; 00249 }

| nosave mapping fixed_ids |
Definiert in Zeile 31 der Datei shop.c.
Wird benutzt von AddFixedObject(), create(), FindInStore() und RemoveFixedObject().
| nosave string* fixed_obj |
Definiert in Zeile 29 der Datei shop.c.
Wird benutzt von AddFixedObject(), create(), GetList() und RemoveFixedObject().
| nosave mapping fixed_value |
Definiert in Zeile 30 der Datei shop.c.
Wird benutzt von AddFixedObject(), create(), QueryBuyValue() und RemoveFixedObject().
| nosave mapping ob_anz |
Definiert in Zeile 26 der Datei shop.c.
Wird benutzt von create(), ObjectCount(), reset() und UpdateCounter().
| nosave string storage |
Definiert in Zeile 25 der Datei shop.c.
Wird benutzt von FindBestArmoursT(), FindBestWeapon(), FindInStore(), GetList(), make_to_money(), QueryStorageRoom(), sell() und SetStorageRoom().
| inherit std trading_price |
1.6.3