[Home]History of DynamicDescription

TheSourcery | RecentChanges | Preferences | Index | RSS


Revision 6 . . (edit) October 22, 2005 7:32 am by JonLambert
Revision 1 . . October 22, 2005 5:58 am by JonLambert
  

Difference (from prior major revision) (minor diff)

Changed: 1c1,40
A simple mechanism to markup mud output

A mechanism to markup mud output




It looks a bit like HTML


You are in a [fairy]huge[/fairy] cavern. [day]Shafts of light descend from
an opening high in the cavern ceiling.[/day]...


This implementation does support ==, && (and), || (or) logic, though it's subtle.


[fairy][mage]Show to fairy mage[/mage][/fairy] --> (race == fairy && class == mage)

[fairy]Show to fairy[/fairy][elf]Show to elf[/elf] --> (race == fairy || race == elf)


...but not integral value tests or intergral comparison tests.


(age > 25)

(level == 1)


It can be easily extended to do things like that:


[dwarf][age 25+]Something for old dwarves[/age][/dwarf] --> (race == dwarf && age >= 25)

[level 1]Welcome newbie.[/level] --> (level == 1)

[detect hidden 50]something really secret[/detect hidden] --> (skill_check("detect hidden", 50) == true)

[evil]a view from the dark side[/evil] --> (alignment <= -350)


I think it's a good example of creating an interface that tries its damndest to not turn builders into coders. I suspect trying to convert them often makes them unhappy and disgruntled. I don't know if that's really true or not.

Ahh the power of regular expressions.

Changed: 88,91c127,130
int termwidth[] = {40,60,80};
string sex[] = {"male", "female"};
string race[] = {"human", "elf", "fairy"};
string tod[] = {"day", "night"};
int Termwidth[] = {40,60,80};
string Sex[] = {"male", "female"};
string Race[] = {"human", "elf", "fairy"};
string TOD[] = {"day", "night"};

Removed: 98,101d136
vector<int> Termwidth;
vector<string> Sex;
vector<string> Race;
vector<string> TOD;

Changed: 119c154
string show(string s, Player* p) {
string show(string s, Player& p) {

Removed: 121d155
sprintf(tws,"%d",p->tw);

Changed: 123,126c157,160
string pat;
for(vector<string>::iterator i = p->pf.begin(); i != p->pf.end(); i++) {
pat = "\\[" + *i + "\\](.*?)\\[\\/" + *i + "\\]";
RE(pat, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).GlobalReplace?("\\1",&str);

for(vector<string>::iterator i = p.pf.begin(); i != p.pf.end(); i++) {
RE("\\[" + *i + "\\](.*?)\\[\\/" + *i + "\\]",
RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).GlobalReplace?("\\1",&str);

Changed: 129,130c163,164
pat = "\\[" + *i + "\\].*?\\[\\/" + *i + "\\]";
RE(pat, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).GlobalReplace?("",&str);
RE("\\[" + *i + "\\].*?\\[\\/" + *i + "\\]",
RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).GlobalReplace?("",&str);

Changed: 134,137c168,170
pat = "\\S{" + string(tws) + "})(?=\\S)";
RE(pat).GlobalReplace?("\\1", &str);
pat = "(.{1," + string(tws) + "})(?:\\s+|$)";
RE(pat).GlobalReplace?("\\1\n", &str);
sprintf(tws,"%d",p.tw);
RE("\\S{" + string(tws) + "})(?=\\S)").GlobalReplace?("\\1", &str);
RE("(.{1," + string(tws) + "})(?:\\s+|$)").GlobalReplace?("\\1\n", &str);

Changed: 142,154c175,183
Termwidth.assign(termwidth, termwidth+3);
Sex.assign(sex, sex+2);
Race.assign(race, race+3);
TOD.assign(tod, tod+2);
Keywords.insert(Keywords.end(), Sex.begin(), Sex.end());
Keywords.insert(Keywords.end(), Race.begin(), Race.end());
Keywords.insert(Keywords.end(), TOD.begin(), TOD.end());
for(int i=0; i<5; i++) {
Player* p = new Player(
Sex[rand() % Sex.size()],
Race[rand() % Race.size()],
TOD[rand() % TOD.size()],
Termwidth[rand() % Termwidth.size()]
Keywords.insert(Keywords.end(), Sex, Sex+2);
Keywords.insert(Keywords.end(), Race, Race+3);
Keywords.insert(Keywords.end(), TOD, TOD+2);
for(int i=0; i<10; i++) {
Player p(
Sex[rand() % 2],
Race[rand() % 3],
TOD[rand() % 2],
Termwidth[rand() % 3]

Changed: 156,157c185,186
cout << "Sex:" << p->sex << " Race:" << p->race <<
" TOD:" << p->tod << " TW:" << p->tw << endl;
cout << "Sex:" << p.sex << " Race:" << p.race <<
" TOD:" << p.tod << " TW:" << p.tw << endl;

TheSourcery | RecentChanges | Preferences | Index | RSS
Search:
All material on this Wiki is the property of the contributing authors.
©2004-2006 by the contributing authors.
Ideas, requests, problems regarding this site? Send feedback.