#include <properties.h>#include <language.h>#include <mail.h>#include "party.h"

gehe zum Quellcode dieser Datei
Makrodefinitionen | |
| #define | __PARTY_NEED_ROOMS__ |
| #define | ME this_object() |
| #define | TP this_player() |
Funktionen | |
| create () | |
| init () | |
| static string * | GetKeys () |
| static string | CountUp (string *strs) |
| static string | list_data (mapping dat) |
| static | uebersicht () |
| static | partyliste (string str) |
| static | fragen (str) |
| _query_long () | |
| static | make_bmail (str) |
| static | bestaetigen (str) |
| static int | zeige_protokoll (string str) |
| static | abmelden () |
| static | end_query () |
| static | next_question () |
| static | get_answer (string str) |
| static | anmelden () |
Variablen | |
| inherit std | thing |
| static mapping | newdata |
| static string | infotext |
| static string | moreinfo |
| static string * | binfo |
| int | bsz |
| _query_long | ( | ) |
Definiert in Zeile 232 der Datei brett.c.
Benutzt break_string(), CountUp(), GetKeys(), infotext, More(), ORGANISATOR und TP.
00232 { 00233 string s; 00234 00235 s="Dies hier ist ein Brett mit Infos zur naechsten MorgenGrauen-Party.\n" 00236 +"Genauere Informationen findest du in der MPA in der Rubrik 'party'.\n" 00237 +infotext 00238 +"Dir stehen folgende Befehle zur Verfuegung:\n" 00239 " anmelden, abmelden - beides klar\n" 00240 " frage brett nach <name> - Infos ueber den Spieler mit dem Namen name\n" 00241 " partyliste - zeigt alle Angemeldeten an\n" 00242 " partyliste <schluessel> - zeigt Daten unter dem Eintrag schluessel an\n"; 00243 if (objectp(TP) && getuid(TP)==ORGANISATOR) { 00244 s+=" bestaetige <name> - Bestaetigt Spieler Ankunft des Geldes\n"; 00245 s+=" protokoll - Zeigt das Protokoll der Eintragungen\n"; 00246 } 00247 00248 s+="Es gibt folgende Schluessel:\n"; 00249 s+=break_string(CountUp(sort_array(GetKeys(),#'<))+"\n",78); 00250 /* Aenderung: Vanion, 15.04.02 00251 Die Langbeschreibung ist in der Regel so lang, dass sie besser 00252 durch ein More geschickt wird. 00253 */ 00254 // Dabei sollte auch sichergestellt sein, dass this_player()!=0 ist. 00255 // Andernfalls scrollt's den ganzen Tag. 00256 if (this_player()) this_player()->More(s); 00257 return ""; 00258 /* return s; */ 00259 }

| static abmelden | ( | ) | [static] |
| static anmelden | ( | ) | [static] |
Definiert in Zeile 464 der Datei brett.c.
00464 { 00465 if (!query_once_interactive(TP)) return 0; 00466 00467 // 20.04.02 by Vanion 00468 // Gaeste sollen sich nicht mehr anmelden koennen 00469 if(getuid(TP)[0..3]=="gast") 00470 { 00471 notify_fail("Als Gast kannst Du Dich nicht zur Party anmelden.\n"); 00472 return 0; 00473 } 00474 if (!mappingp(newdata[TP]=PM->QueryUser(getuid(TP)))) 00475 newdata[TP]=([]); 00476 newdata[TP][KEY_QUERY_NUMBER]=0; 00477 if (newdata[TP][KEY_BESTAETIGUNG]!="ja") 00478 newdata[TP][KEY_BESTAETIGUNG]="nein"; 00479 if (!newdata[TP][KEY_DATUM]) 00480 newdata[TP][KEY_DATUM]=time(); 00481 next_question(); 00482 return 1; 00483 }
| static bestaetigen | ( | str | ) | [static] |
Definiert in Zeile 282 der Datei brett.c.
Benutzt dtime(), KEY_BESTAETIGUNG, make_bmail(), MSG_BCC, MSG_BODY, MSG_CC, MSG_DATE, MSG_FROM, MSG_ID, MSG_RECIPIENT, MSG_SENDER, MSG_SUBJECT, notify_fail(), ORGANISATOR, PM, text() und TP.
00282 { 00283 mixed *mail; 00284 string text; 00285 mapping dat; 00286 00287 if (getuid(TP)!=ORGANISATOR) 00288 return notify_fail("Das kann nur der Organisator.\n"),0; 00289 if (!str) 00290 return "Fuer welchen Spieler soll die Anmelding bestaetigt werden?\n",0; 00291 if (!mappingp(dat=PM->QueryUser(str))) 00292 return notify_fail("Der Spieler ist nicht angemeldet.\n"),0; 00293 00294 dat[KEY_BESTAETIGUNG]="ja"; 00295 PM->SetUser(str,dat); 00296 00297 text=make_bmail(str); 00298 if (text=="") { 00299 text="Hallo, "+capitalize(str)+"!\n\n"; 00300 text+="Dein Geld ist angekommen und Deine Anmeldung somit bestaetigt.\n"; 00301 text+=("\n "+capitalize(ORGANISATOR)+", Partyorganisator\n"); 00302 } 00303 00304 mail = allocate(9); 00305 mail[MSG_FROM] = ORGANISATOR; 00306 mail[MSG_SENDER] = "MorgenGrauen"; 00307 mail[MSG_RECIPIENT] = str; 00308 mail[MSG_CC]=0; 00309 mail[MSG_BCC]=0; 00310 mail[MSG_SUBJECT]="Bestaetigung der Partyanmeldung"; 00311 mail[MSG_DATE]=dtime(time()); 00312 mail[MSG_ID]="MorgenGrauen:"+time(); 00313 mail[MSG_BODY]=text; 00314 00315 "/secure/mailer"->DeliverMail(mail,1); 00316 00317 printf("Anmeldung von %s bestaetigt.\n",capitalize(str)); 00318 return 1; 00319 }

| static string CountUp | ( | string * | strs | ) | [static] |
Definiert in Zeile 82 der Datei brett.c.
Benutzt i.
Wird benutzt von _query_long(), andlist(), auswertung(), check_player(), CheckPlayerAttack(), CmdFilter(), CmdMonitor(), finger_single(), ginfo(), GoblinCmdWaaagh(), ignoriere(), IstSindMsg(), kkwho(), ListAwaited(), long(), MixedOut(), ParseAdverb(), put_objects(), QueryInfo() und score().
00082 { 00083 string res; 00084 int i; 00085 00086 res=""; 00087 for (i=sizeof(strs)-1;i>=0;i--) { 00088 res+=capitalize(strs[i]); 00089 if (i) res+=((i>1)?", ":" und "); 00090 } 00091 return res; 00092 }

| create | ( | ) |
Definiert in Zeile 36 der Datei brett.c.
Benutzt AddCmd(), AddId(), BESTAETIGFILE, binfo, bsz, create(), INFOFILE, infotext, ME, moreinfo, MOREINFOFILE, newdata, P_ARTICLE, P_NAME, P_NOGET, P_SHORT, P_WEIGHT und SetProp().
00036 { 00037 if (!clonep(ME)) return; 00038 ::create(); 00039 newdata=([]); 00040 if (!stringp(infotext=read_file(BESTAETIGFILE))) 00041 infotext=""; 00042 binfo=({"<alle>"})+regexplode(infotext,"<[^<>]*>");bsz=sizeof(binfo); 00043 if (!stringp(infotext=read_file(INFOFILE))) 00044 infotext=""; 00045 if (!stringp(moreinfo=read_file(MOREINFOFILE))) 00046 moreinfo=""; 00047 00048 SetProp(P_NAME,"Partybrett"); 00049 SetProp(P_SHORT,"Ein Partybrett"); 00050 SetProp(P_ARTICLE,1); 00051 SetProp(P_NOGET,"Stehenlassen!\n"); 00052 SetProp(P_WEIGHT,12345678); 00053 AddId( ({ "party\nbrett", "partybrett", "PartyBrett", "brett" }) ); 00054 seteuid(getuid(ME)); 00055 AddCmd("uebersicht","uebersicht"); 00056 AddCmd("anmelden","anmelden"); 00057 AddCmd("abmelden","abmelden"); 00058 AddCmd(({"frage","frag"}),"fragen"); 00059 AddCmd("partyliste","partyliste"); 00060 }

| static end_query | ( | ) | [static] |
Definiert in Zeile 335 der Datei brett.c.
Benutzt dtime(), infotext, KEY_BESTAETIGUNG, KEY_QUERY_NUMBER, list_data(), m_delete(), moreinfo, MSG_BCC, MSG_BODY, MSG_CC, MSG_DATE, MSG_FROM, MSG_ID, MSG_RECIPIENT, MSG_SENDER, MSG_SUBJECT, newdata, ORGANISATOR, PM, text(), TP und WER.
Wird benutzt von next_question().
00335 { 00336 mixed *mail; 00337 string text; 00338 mapping dat; 00339 00340 if (!mappingp(dat=newdata[TP])) dat=([]); 00341 efun::m_delete(newdata,TP); 00342 efun::m_delete(dat,KEY_QUERY_NUMBER); 00343 PM->SetUser(getuid(TP),dat); 00344 write("OK, angemeldet.\n"); 00345 00346 text="Hallo, "+TP->Name(WER)+"!\n\n"; 00347 text+=("Nachdem Du Dich zur Party angemeldet hast,\n"+ 00348 "hier noch einmal die wichtigsten Daten:\n"); 00349 text+=infotext; 00350 00351 if (stringp(moreinfo) && moreinfo!="") { 00352 text+="\nWeitere Informationen:\n"; 00353 text+=moreinfo; 00354 } 00355 00356 text+="\nFolgende Eintragungen hast Du vorgenommen:\n"; 00357 text+=list_data(dat); 00358 if (dat[KEY_BESTAETIGUNG]=="ja") 00359 text+="\nDein Geld ist bereits angekommen.\n"; 00360 text+="\n\Diese Mail wurde automatisch generiert.\n"; 00361 00362 00363 mail = allocate(9); 00364 mail[MSG_FROM] = ORGANISATOR; 00365 mail[MSG_SENDER] = "MorgenGrauen"; 00366 mail[MSG_RECIPIENT] = getuid(TP); 00367 mail[MSG_CC]=0; 00368 mail[MSG_BCC]=0; 00369 mail[MSG_SUBJECT]="Partyanmeldung"; 00370 mail[MSG_DATE]=dtime(time()); 00371 mail[MSG_ID]="MorgenGrauen:"+time(); 00372 mail[MSG_BODY]=text; 00373 00374 return "/secure/mailer"->DeliverMail(mail,1); 00375 }


| static fragen | ( | str | ) | [static] |
Definiert in Zeile 215 der Datei brett.c.
Benutzt list_data(), PM und TP.
00215 { 00216 mapping dat; 00217 string s,s2; 00218 00219 if (!str) return 0; 00220 if (!sscanf(str,"%s nach %s",s2,s)||s==""||(!id(s2)&&s2!="brett")) return 0; 00221 str=lower_case(s); 00222 if (!mappingp(dat=PM->QueryUser(str))) { 00223 write(capitalize(str)+" hat sich bisher nicht angemeldet.\n"); 00224 return 1; 00225 } 00226 s=list_data(dat); 00227 TP->More(s); 00228 return 1; 00229 00230 }

| static get_answer | ( | string | str | ) | [static] |
Definiert in Zeile 414 der Datei brett.c.
00414 { 00415 mapping dat,q; 00416 int num; 00417 mixed qs; 00418 string key,x; 00419 00420 if (!mappingp(dat=newdata[TP])) dat=([]); 00421 num=dat[KEY_QUERY_NUMBER]; 00422 qs=Fragen(); 00423 if (num>sizeof(qs)) 00424 return end_query(); 00425 q=qs[num];key=q[Q_KEY]; 00426 00427 // Default ermitteln 00428 if (!stringp(str) || str=="") 00429 if (!stringp(str=dat[key]) && !stringp(str=q[Q_DEFAULT])) { 00430 write("Du musst schon etwas eingeben...\n"); 00431 input_to("get_answer"); 00432 return; 00433 } 00434 00435 // Bei eingeschraenkten Antworten anpassen soweit moeglich: 00436 qs=q[Q_CHOICES]; 00437 if (q[Q_BOOLEAN] || qs) 00438 str=lower_case(str); 00439 if (q[Q_BOOLEAN]) { 00440 if (str=="j") str="ja"; 00441 if (str=="n") str="nein"; 00442 } 00443 00444 if (mappingp(qs) && qs[str]) 00445 write("--> "+capitalize(str)+" ("+qs[str]+")\n"); 00446 else 00447 write("--> "+capitalize(str)+"\n"); 00448 00449 // Einschraenkungen beruecksichtigen 00450 if ((q[Q_BOOLEAN] && member(({"ja","nein"}),str)<0) 00451 || (mappingp(qs) && !qs[str]) 00452 || (pointerp(qs) && member(qs,str)<0)) { 00453 write("Ungueltige Antwort.\n"); 00454 input_to("get_answer"); 00455 return; 00456 } 00457 00458 dat[key]=str; 00459 dat[KEY_QUERY_NUMBER]++; 00460 newdata[TP]=dat; 00461 next_question(); 00462 }
| static string* GetKeys | ( | ) | [static] |
Definiert in Zeile 70 der Datei brett.c.
Benutzt Fragen(), i, KEY_BESTAETIGUNG, keys und Q_KEY.
Wird benutzt von _query_long().
00070 { 00071 mapping *k; 00072 string *keys; 00073 int i,j; 00074 00075 k=Fragen();keys=({}); 00076 for (i=sizeof(k)-1;i>=0;i--) 00077 keys+=({k[i][Q_KEY]}); 00078 keys+=({KEY_BESTAETIGUNG}); 00079 return keys; 00080 }


| init | ( | ) |
Definiert in Zeile 62 der Datei brett.c.
Benutzt init(), ORGANISATOR und TP.
00062 { 00063 ::init(); 00064 if (getuid(TP)==ORGANISATOR) { 00065 add_action("bestaetigen","bestaetige"); 00066 add_action("zeige_protokoll", "protokoll"); 00067 } 00068 }

| static string list_data | ( | mapping | dat | ) | [static] |
Definiert in Zeile 94 der Datei brett.c.
Benutzt break_string(), dtime(), Fragen(), i, KEY_BESTAETIGUNG, KEY_DATUM, Q_CHOICES, Q_KEY, Q_TEXT, text() und x.
Wird benutzt von end_query() und fragen().
00094 { 00095 mixed *qs,x; 00096 string text,str,key; 00097 int i,sz; 00098 00099 qs=Fragen();sz=sizeof(qs);text=""; 00100 for (i=0;i<sz;i++) { 00101 key=qs[i][Q_KEY]; 00102 str=qs[i][Q_TEXT]+" "+capitalize(stringp(dat[key])?dat[key]:"(unbekannt)"); 00103 if (mappingp(x=qs[i][Q_CHOICES]) && stringp(x[dat[key]])) 00104 str+=(" ("+x[dat[key]]+")"); 00105 text+=break_string(str+"\n",78," ")[2..]; 00106 } 00107 text+="\n"; 00108 if (dat[KEY_DATUM]) 00109 text+=sprintf("Angemeldet am %s\n",dtime(dat[KEY_DATUM])); 00110 if (dat[KEY_BESTAETIGUNG]=="ja") 00111 text+="*** Anmeldung bestaetigt ***\n"; 00112 return text; 00113 }


| static make_bmail | ( | str | ) | [static] |
Definiert in Zeile 261 der Datei brett.c.
Benutzt binfo, bsz, old_explode(), PM und text().
Wird benutzt von bestaetigen().
00261 { 00262 mapping dat; 00263 string *parts,text,tag; 00264 int i; 00265 00266 text=""; 00267 if (!mappingp(dat=PM->QueryUser(str))) 00268 return text; 00269 for (i=0;i<bsz;i++) { 00270 tag=binfo[i++][1..<2]; 00271 if (i>=bsz) continue; 00272 if (tag=="mudname") 00273 text+=capitalize(str)+binfo[i]; 00274 else if (tag=="alle") 00275 text+=binfo[i]; 00276 else if ((sizeof(parts=old_explode(tag,":"))>=2) && dat[parts[0]]==parts[1]) 00277 text+=binfo[i]; 00278 } 00279 return text; 00280 }


| static next_question | ( | ) | [static] |
Definiert in Zeile 377 der Datei brett.c.
Benutzt end_query(), Fragen(), KEY_QUERY_NUMBER, newdata, Q_BOOLEAN, Q_CHOICES, Q_DEFAULT, Q_KEY, Q_TEXT, TP und x.
00377 { 00378 mapping dat,q; 00379 int num,i; 00380 mixed qs; 00381 string str,key,x; 00382 00383 if (!mappingp(dat=newdata[TP])) dat=([]); 00384 num=dat[KEY_QUERY_NUMBER]; 00385 qs=Fragen(); 00386 if (num>=sizeof(qs)) 00387 return end_query(); 00388 q=qs[num];key=q[Q_KEY];str=q[Q_TEXT]; 00389 if (q[Q_BOOLEAN]) 00390 str+=" (ja/nein)"; 00391 if (stringp(x=dat[key]) || stringp(x=q[Q_DEFAULT])) 00392 str+=sprintf(" [%s]",x); 00393 write(str+"\n"); 00394 00395 qs=q[Q_CHOICES];q=0; 00396 if (mappingp(qs)) { 00397 q=qs; 00398 qs=sort_array(m_indices(qs),#'>); 00399 } 00400 if (pointerp(qs)) { 00401 write("Moeglichkeiten:\n"); 00402 num=sizeof(qs); 00403 for (i=0;i<num;i++) { 00404 str=" "+capitalize(qs[i]); 00405 if (mappingp(q)) 00406 str+=") "+q[qs[i]]; 00407 write(str+"\n"); 00408 } 00409 } 00410 00411 input_to("get_answer"); 00412 }

| static partyliste | ( | string | str | ) | [static] |
Definiert in Zeile 156 der Datei brett.c.
00156 { 00157 mapping *qs,q,alldat; 00158 string *ind,ix,x,pre,text; 00159 int i; 00160 00161 if (!mappingp(alldat=PM->QueryData())) 00162 alldat=([]); 00163 ind=sort_array(m_indices(alldat),#'<); 00164 if (!str||str=="") { 00165 write("Bisher haben sich "+sizeof(ind)+" Mitspieler angemeldet.\n"); 00166 write(break_string(CountUp(ind)+"\n",78," ")); 00167 return 1; 00168 } 00169 if (member(GetKeys(),str)<0) 00170 return notify_fail("Ungueltiger Schluessel.\n"),0; 00171 00172 q=([Q_BOOLEAN:1]); 00173 if (str!=KEY_BESTAETIGUNG) { 00174 qs=Fragen(); 00175 for (i=sizeof(qs)-1;i>=0;i--) { 00176 q=qs[i]; 00177 if (str!=q[Q_KEY]) continue; 00178 break; 00179 } 00180 } 00181 00182 if (q[Q_BOOLEAN] || q[Q_CHOICES]) { 00183 q=(mappingp(q[Q_CHOICES])?(q[Q_CHOICES]):0); 00184 for (i=sizeof(ind)-1;i>=0;i--) { 00185 if (!stringp(ix=ind[i])) continue; 00186 if (!stringp(x=alldat[ix][str])) x=""; 00187 x=("("+x+") ")[0..9]; 00188 ind[i]=x+ix; 00189 } 00190 ind=sort_array(ind,#'<); 00191 } else 00192 q=0; 00193 00194 pre="";text=""; 00195 for (i=sizeof(ind)-1;i>=0;i--) { 00196 if (!stringp(ix=ind[i])) continue; 00197 if (ix[0..0]=="(") { 00198 if (ix[0..9]!=pre) { 00199 text+="------------\n"; 00200 pre=ix[0..9]; 00201 } 00202 ix=ix[10..]; 00203 } 00204 if (!mappingp(alldat[ix])) continue; 00205 x=alldat[ix][str]; 00206 if (mappingp(q)) x=q[x]; 00207 if (!stringp(x)) x=""; 00208 x=capitalize(ix+": ")[0..13]+capitalize(x)+"\n"; 00209 text+=break_string(x,78," ")[2..]; 00210 } 00211 TP->More(text); 00212 return 1; 00213 }

| static uebersicht | ( | ) | [static] |
Definiert in Zeile 115 der Datei brett.c.
Benutzt Fragen(), i, KEY_BESTAETIGUNG, PM, Q_BOOLEAN, Q_CHOICES und Q_KEY.
00115 { 00116 mapping alldat,dat,res; 00117 string *ind,*ind2,key,out; 00118 int i,j,sz2; 00119 mixed *qs; 00120 00121 qs=Fragen();res=([KEY_BESTAETIGUNG:([])]); 00122 for (i=sizeof(qs)-1;i>=0;i--) { 00123 if (!mappingp(dat=qs[i])) continue; 00124 if (!stringp(key=dat[Q_KEY])) continue; 00125 if (dat[Q_CHOICES] || dat[Q_BOOLEAN]) 00126 res[key]=([]); 00127 } 00128 ind2=m_indices(res);sz2=sizeof(ind2)-1; 00129 00130 if (!mappingp(alldat=PM->QueryData())) alldat=([]); 00131 ind=m_indices(alldat); 00132 for (i=sizeof(ind)-1;i>=0;i--) { 00133 dat=alldat[ind[i]]; 00134 for (j=sz2;j>=0;j--) { 00135 key=ind2[j]; 00136 res[key][dat[key]]++; 00137 } 00138 } 00139 00140 out=""; 00141 ind2=sort_array(ind2,#'<); 00142 for (i=sz2;i>=0;i--) { 00143 if (!stringp(key=ind2[i])) continue; 00144 if (!mappingp(dat=res[key])) continue; 00145 ind=sort_array(m_indices(dat),#'<); 00146 out+=sprintf("%-15s ",capitalize(key+":")); 00147 for (j=sizeof(ind)-1;j>=0;j--) 00148 out+=sprintf(" %4s: %3d%s",ind[j],dat[ind[j]],(j?" |":"")); 00149 out+="\n"; 00150 } 00151 00152 write(out); 00153 return 1; 00154 }

| static int zeige_protokoll | ( | string | str | ) | [static] |
Definiert in Zeile 321 der Datei brett.c.
Benutzt notify_fail().
00321 { 00322 notify_fail("Diese Funktion ist noch nicht eingebaut!\n"); 00323 00324 return 0; 00325 }

string* binfo [static] |
Definiert in Zeile 32 der Datei brett.c.
Wird benutzt von create() und make_bmail().
| int bsz |
Definiert in Zeile 33 der Datei brett.c.
Wird benutzt von create() und make_bmail().
string infotext [static] |
Definiert in Zeile 31 der Datei brett.c.
Wird benutzt von _query_long(), create() und end_query().
string moreinfo [static] |
Definiert in Zeile 31 der Datei brett.c.
Wird benutzt von create() und end_query().
mapping newdata [static] |
Definiert in Zeile 30 der Datei brett.c.
Wird benutzt von create(), end_query() und next_question().
1.6.3