bottle.c-Dateireferenz

#include <properties.h>
#include <language.h>
Include-Abhängigkeitsdiagramm für bottle.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define PL   this_player()
#define GULP   20
#define NO
#define FULL(what, amount)   (what*_MaxCapacity/amount)
#define PART(what, amount)   (what*amount/_MaxCapacity)
#define AVER(x, y, amount)   ((FULL(x, amount)+y)/2)

Funktionen

public LiquidContDescr (Cname, Cids, Cshort, Clong, Cweight, Ccapa, NoClose, Clabel)
public PourLiquid (Famount, where)
public AllowDrinking (no)
public QueryContents ()
public QueryContainer ()
public LiquidContDescr (Cname, Cids, Cshort, Clong, Cweight, Capa, NoClose, Clabel)
public AddLiquid (Famount, Fname, Fdescr, Fprice, Fheal, Fstrength, Fsoak)
 create ()
 init ()
 DoDrink (arg)
 DoPour (arg)
 DoOpen (str)
 DoClose (str)
 DoLookInside (str)

Variablen

inherit std thing
private string _Fname
private string _Fdescr
private int _Fprice
private int _Fheal
private int _Fstrength
private int _Fsoak
private int _MaxCapacity
private int _Capacity
private int _NoDrinking
private int _open
private int _NoClose

Makro-Dokumentation

#define AVER ( x,
y,
amount   )     ((FULL(x, amount)+y)/2)

Definiert in Zeile 68 der Datei bottle.c.

Wird benutzt von AddLiquid().

#define FULL ( what,
amount   )     (what*_MaxCapacity/amount)

Definiert in Zeile 66 der Datei bottle.c.

Wird benutzt von AddLiquid().

#define GULP   20

Definiert in Zeile 60 der Datei bottle.c.

Wird benutzt von DoDrink() und PourLiquid().

#define NO
Wert:
({"hundert", "neunzig", "achtzig", "siebzig",\
                          "sechzig", "fuenfzig", "vierzig", "dreissig",\
                          "zwanzig", "zehn"})

Definiert in Zeile 62 der Datei bottle.c.

Wird benutzt von DoLookInside().

#define PART ( what,
amount   )     (what*amount/_MaxCapacity)

Definiert in Zeile 67 der Datei bottle.c.

Wird benutzt von AddLiquid() und PourLiquid().

#define PL   this_player()

Dokumentation der Funktionen

public AddLiquid ( Famount  ,
Fname  ,
Fdescr  ,
Fprice  ,
Fheal  ,
Fstrength  ,
Fsoak   
)

Definiert in Zeile 90 der Datei bottle.c.

Benutzt _Capacity, _Fdescr, _Fheal, _Fname, _Fprice, _Fsoak, _Fstrength, _MaxCapacity, AVER, FULL, P_VALUE, PART und SetProp().

00091 {
00092   if(_Capacity && Famount)
00093   {
00094     if(Famount<=_Capacity) _Capacity -= Famount;
00095     else { Famount = _Capacity; _Capacity = 0; } 
00096     if(!_Fname || _Fname == Fname) { _Fname = Fname; _Fdescr = Fdescr; }
00097     else { _Fdescr = "Eine Mixtur aus "+_Fname+" und "+Fname; 
00098            _Fname = _Fname+":"+Fname; }
00099     if(_Fprice) _Fprice = AVER(Fprice, _Fprice, Famount);
00100     else _Fprice = FULL(Fprice, Famount);
00101     if(_Fheal) _Fheal = AVER(Fheal, _Fheal, Famount);
00102     else _Fheal = FULL(Fheal, Famount);
00103     if(_Fstrength) _Fstrength = AVER(Fstrength, Fstrength, Famount);
00104     else _Fstrength = FULL(Fstrength, Famount);
00105     if(_Fsoak) _Fsoak = AVER(Fsoak, _Fsoak, Famount);
00106     else _Fsoak = FULL(Fsoak, Famount);
00107     SetProp(P_VALUE, PART(_Fprice, (_MaxCapacity-_Capacity)));
00108   }
00109   return Famount;
00110 }   

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

public AllowDrinking ( no   ) 

Definiert in Zeile 144 der Datei bottle.c.

Benutzt _NoDrinking.

00144 { return _NoDrinking = no; }

create (  ) 

Definiert in Zeile 151 der Datei bottle.c.

Benutzt AddId(), create(), FEMALE, P_GENDER, P_LONG, P_NAME, P_SHORT, P_WEIGHT und SetProp().

00152 {
00153   if (!clonep(this_object())) return;
00154   ::create();
00155 
00156   SetProp(P_NAME, "Flasche");
00157   AddId("flasche");
00158   SetProp(P_SHORT, "Eine Flasche");
00159   SetProp(P_LONG, "Du siehst nichts besonderes an oder in der Flasche.\n");
00160   SetProp(P_GENDER, FEMALE);
00161   SetProp(P_WEIGHT,100);
00162 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

DoClose ( str   ) 

Definiert in Zeile 301 der Datei bottle.c.

Benutzt _NoClose, _open, name, PL und WEN.

00302 {
00303   if(id(str) && !_NoClose)
00304   {
00305     if(!_open) return write(capitalize(name(0,1))+" ist schon zu.\n") || 1;
00306     write("Du machst "+name(WEN, 1)+" zu.\n");
00307     say(PL->name()+" schliesst "+name(WEN)+".\n");
00308     _open = 0;
00309     return 1;
00310   }
00311 }

DoDrink ( arg   ) 

Definiert in Zeile 180 der Datei bottle.c.

Benutzt _Capacity, _MaxCapacity, _NoDrinking, _open, all, cnt, GULP, name, PL, PourLiquid(), WEM und WEN.

00181 {
00182   string howmuch, trash, str;
00183   int all, cnt;
00184 
00185   if(!_NoDrinking && arg && sscanf(arg, "%saus %s", str, trash)==2 && id(trash))
00186   {
00187     if(!_open) return write(capitalize(name(0,1))+" ist aber noch zu.\n") || 1;
00188     if(_Capacity==_MaxCapacity)
00189     {
00190       write("Du setzt "+name(WEN, 1)+" an und merkst, dass nichts mehr darin "
00191            +"ist.\n");
00192       say(PL->name()+" setzt "+name(WEN)+" an und merkt, dass nichts mehr darin"
00193          +" ist.\n");
00194       return 1;
00195     }
00196     if(sscanf(str, "alles%s", trash) == 1)
00197     {
00198       all = _Capacity;
00199       while(PourLiquid(GULP, PL));
00200       if(_Capacity==all) return write("Du schaffst es nicht zu trinken.\n");
00201       if(_MaxCapacity>_Capacity)
00202         write("Du hast nur einen Teil zu trinken geschafft.\n");
00203       else
00204       {
00205         write("Du trinkst alles bis zum letzten Rest aus "+name(WEM, 1)+".\n");
00206         say(PL->name()+" trinkt alles bis zum letzten Rest aus "
00207            +name(WEM)+".\n");
00208       }
00209       return 1;
00210     }
00211     if(str==" " || (str=="schluck" || sscanf(str, "schluck%s", trash)) == 1) 
00212       if(PourLiquid(GULP, PL))
00213       {
00214         write("Du trinkst einen Schluck aus "+name(WEM, 1)+".\n");
00215         say(PL->name()+" trinkt einen Schluck aus "+name(WEM)+".\n");
00216         return 1;
00217       }
00218       else return write("Du schaffst es nicht zu trinken.\n") || 1;
00219     else
00220     {
00221       if(sscanf(str, "%s schluck%s", howmuch, trash)>=1) 
00222       switch(howmuch)
00223       {
00224         case "1":
00225         case "ein":
00226         case "einen": { cnt = 1; howmuch = "einen"; break; }
00227         case "2":
00228         case "zwei" : { cnt = 2; break; }
00229         case "3":
00230         case "drei" : { cnt = 3; break; }
00231         case "4":
00232         case "vier" : { cnt = 4; break; }
00233         case "5":
00234         case "fuenf": { cnt = 5; break; }
00235         case "6":
00236         case "sechs": { cnt = 6; break; }
00237         case "7":
00238         case "sieben":{ cnt = 7; break; }
00239         case "8":
00240         case "acht" : { cnt = 8; break; }
00241         case "9":
00242         case "neun" : { cnt = 9; break; }
00243         case "10":
00244         case "zehn" : { cnt = 10; break; }
00245         default: cnt = 0;
00246       }
00247       if(!cnt) { cnt = 1; howmuch = "einen"; }
00248       while(cnt-- && all=PourLiquid(GULP, PL));
00249       if(cnt>0 && all==_MaxCapacity) 
00250         write("Sooo viele Schluecke waren gar nicht in "+name(WEM, 1)+".\n");
00251       else write("Du trinkst ein paar Schluck aus "+name(WEM, 1)+".\n");
00252       say(PL->name()+" trinkt aus "+name(WEM)+".\n");
00253       return 1;
00254     }
00255   }
00256 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

DoLookInside ( str   ) 

Definiert in Zeile 313 der Datei bottle.c.

Benutzt _Capacity, _Fdescr, _MaxCapacity, _open, name, NO und WEM.

00314 {
00315   string trash;
00316 
00317   if(str && sscanf(str, "in %s", trash)==1 && id(trash))
00318   {
00319     if(!_open) return write(capitalize(name(0,1))+" ist aber noch zu.\n") || 1;
00320     if(_Capacity==_MaxCapacity)
00321       return write("Es ist nichts in "+name(WEM, 1)+".\n") || 1;
00322     write(capitalize(name(0,1))
00323          +" ist zu "+NO[_Capacity*10/_MaxCapacity]+" Prozent voll mit "
00324          +_Fdescr+".\n");
00325     return 1;
00326   }
00327 }

DoOpen ( str   ) 

Definiert in Zeile 289 der Datei bottle.c.

Benutzt _NoClose, _open, name, PL und WEN.

00290 {
00291   if(id(str) && !_NoClose)
00292   {
00293     if(_open) return write(capitalize(name(0,1))+" ist schon offen.\n") || 1;
00294     write("Du oeffnest "+name(WEN, 1)+".\n");
00295     say(PL->name()+" oeffnet "+name(WEN)+".\n");
00296     _open = 1;
00297     return 1;
00298   }
00299 }

DoPour ( arg   ) 

Definiert in Zeile 258 der Datei bottle.c.

Benutzt _Capacity, _Fname, _MaxCapacity, _open, dest(), name, PL, PourLiquid(), WEM und WEN.

00259 {
00260   object dest;
00261   string where, str;
00262 
00263   if(arg && sscanf(arg, "%saus %s", str, where)==2 && id(where))
00264   {
00265     if(!_open) return write(capitalize(name(0,1))+" ist aber noch zu.\n") || 1;
00266     if(_Capacity==_MaxCapacity)
00267       return write("Es ist nichts in "+name(WEM, 1)+".\n") || 1;
00268     if(sscanf(str, "alles%s", where)==1) 
00269     {
00270       PourLiquid(_MaxCapacity);
00271       write("Du schuettest alles aus "+name(WEM, 1)+".\n");
00272       say(PL->name()+" schuettet alles aus "+name(WEM)+".\n");
00273       return _Capacity;
00274     }
00275     if(sscanf(str, "in %s", where)==1)
00276     {
00277       if(!dest = present(where)) dest = present(where, environment(PL));
00278       if(dest && !query_once_interactive(dest) &&
00279          PourLiquid(_MaxCapacity-_Capacity, dest))
00280       {
00281         write("Du fuellst "+dest->name(WEN, 1)+" mit "+_Fname+" ab.\n");
00282         say(PL->name()+" fuellt "+dest->name(WEN)+" mit "+_Fname+" ab.\n");
00283         return _Capacity;
00284       }
00285     }
00286   }
00287 } 

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

init (  ) 

Definiert in Zeile 164 der Datei bottle.c.

Benutzt init().

00165 {
00166   ::init();
00167   
00168   add_action("DoDrink", "trinke");
00169   add_action("DoDrink", "trink");
00170   add_action("DoPour", "schuette");
00171   add_action("DoPour", "schuett");
00172   add_action("DoPour", "fuelle");
00173   add_action("DoPour", "fuell");
00174   add_action("DoOpen", "oeffne");
00175   add_action("DoClose", "schliesse");
00176   add_action("DoLookInside", "schaue");
00177   add_action("DoLookInside", "schau");
00178 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

public LiquidContDescr ( Cname  ,
Cids  ,
Cshort  ,
Clong  ,
Cweight  ,
Capa  ,
NoClose  ,
Clabel   
)

Definiert in Zeile 76 der Datei bottle.c.

Benutzt _Capacity, _MaxCapacity, _NoClose, _open, P_IDS, P_LONG, P_NAME, P_READ_MSG, P_SHORT, P_WEIGHT und SetProp().

00078 {
00079   SetProp(P_NAME, Cname);
00080   SetProp(P_SHORT, Cshort);
00081   SetProp(P_LONG, Clong);
00082   SetProp(P_READ_MSG, Clabel);
00083   SetProp(P_WEIGHT, Cweight);
00084   SetProp(P_IDS, Cids);
00085   _MaxCapacity = Capa;
00086   _Capacity = Capa;
00087   if(_NoClose = NoClose) _open = 1;
00088 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

public LiquidContDescr ( Cname  ,
Cids  ,
Cshort  ,
Clong  ,
Cweight  ,
Ccapa  ,
NoClose  ,
Clabel   
)
public PourLiquid ( Famount  ,
where   
)

Definiert in Zeile 112 der Datei bottle.c.

Benutzt _Capacity, _Fdescr, _Fheal, _Fname, _Fprice, _Fsoak, _Fstrength, _MaxCapacity, GULP, P_VALUE, PART und SetProp().

Wird benutzt von DoDrink() und DoPour().

00113 {
00114   int pour, rest, oldc;
00115 
00116   oldc = _Capacity;
00117   if(objectp(where) && where->QueryContainer())
00118   {
00119     pour = Famount;
00120     while(pour &&
00121           (rest=where->AddLiquid(GULP, _Fname, _Fdescr, 
00122                                  PART(_Fprice, Famount),
00123                                  PART(_Fheal, Famount),
00124                                  PART(_Fstrength, Famount),
00125                                  PART(_Fsoak, Famount)))==GULP)
00126       pour -= GULP;
00127     Famount -= rest;
00128   }
00129   else
00130     if(objectp(where) && living(where))
00131     {
00132       if(Famount>_MaxCapacity-_Capacity) Famount = _MaxCapacity-_Capacity;
00133       if(PART(_Fsoak, Famount) && !where->drink_soft(PART(_Fsoak, Famount)))
00134         return; 
00135       if(!where->drink_alcohol(PART(_Fstrength, Famount)))
00136         return; 
00137       where->heal_self(PART(_Fheal, Famount));
00138     }
00139   _Capacity += Famount;
00140   SetProp(P_VALUE, PART(_Fprice, (_MaxCapacity-_Capacity)));
00141   return oldc != _Capacity;
00142 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

public QueryContainer (  ) 

Definiert in Zeile 148 der Datei bottle.c.

00148 { return 1; }

public QueryContents (  ) 

Definiert in Zeile 146 der Datei bottle.c.

Benutzt _Capacity, _Fname und _MaxCapacity.

00146 { return ({ _MaxCapacity-_Capacity, _Fname }); }


Variablen-Dokumentation

private int _Capacity

Definiert in Zeile 72 der Datei bottle.c.

Wird benutzt von AddLiquid(), DoDrink(), DoLookInside(), DoPour(), LiquidContDescr(), PourLiquid() und QueryContents().

private string _Fdescr

Definiert in Zeile 70 der Datei bottle.c.

Wird benutzt von AddLiquid(), DoLookInside() und PourLiquid().

private int _Fheal

Definiert in Zeile 71 der Datei bottle.c.

Wird benutzt von AddLiquid() und PourLiquid().

private string _Fname

Definiert in Zeile 70 der Datei bottle.c.

Wird benutzt von AddLiquid(), DoPour(), PourLiquid() und QueryContents().

private int _Fprice

Definiert in Zeile 71 der Datei bottle.c.

Wird benutzt von AddLiquid() und PourLiquid().

private int _Fsoak

Definiert in Zeile 71 der Datei bottle.c.

Wird benutzt von AddLiquid() und PourLiquid().

private int _Fstrength

Definiert in Zeile 71 der Datei bottle.c.

Wird benutzt von AddLiquid() und PourLiquid().

private int _MaxCapacity

Definiert in Zeile 72 der Datei bottle.c.

Wird benutzt von AddLiquid(), DoDrink(), DoLookInside(), DoPour(), LiquidContDescr(), PourLiquid() und QueryContents().

private int _NoClose

Definiert in Zeile 73 der Datei bottle.c.

Wird benutzt von DoClose(), DoOpen() und LiquidContDescr().

private int _NoDrinking

Definiert in Zeile 72 der Datei bottle.c.

Wird benutzt von AllowDrinking() und DoDrink().

private int _open

Definiert in Zeile 73 der Datei bottle.c.

Wird benutzt von DoClose(), DoDrink(), DoLookInside(), DoOpen(), DoPour() und LiquidContDescr().

inherit std thing

Definiert in Zeile 8 der Datei bottle.c.

Erzeugt am Thu Jun 3 14:39:33 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3