Crossfire Server, Trunk
TreasureWriter.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "TreasureWriter.h"
14 
15 #define W(x, n) { if (item->x) { stringbuffer_append_printf(buf, n "\n", item->x); } }
16 
17 static void writeItem(const treasure *item, StringBuffer *buf) {
18  if (item->item) {
19  stringbuffer_append_printf(buf, "arch %s\n", item->item->name);
20  }
21  W(name, "list %s");
22  W(change_arch.name, "change_name %s");
23  W(change_arch.title, "change_title %s");
24  W(change_arch.slaying, "change_slaying %s");
25  if (item->chance != 100) {
26  stringbuffer_append_printf(buf, "chance %d\n", item->chance);
27  }
28  W(nrof, "nrof %d");
29  W(magic, "magic %d");
30  if (item->next_yes) {
32  writeItem(item->next_yes, buf);
33  }
34  if (item->next_no) {
36  writeItem(item->next_no, buf);
37  }
38  if (item->next) {
40  writeItem(item->next, buf);
41  } else {
43  }
44 }
45 
47  if (list->total_chance == 0) {
48  stringbuffer_append_string(buf, "treasure ");
49  } else {
50  stringbuffer_append_string(buf, "treasureone ");
51  }
54  writeItem(list->items, buf);
55 }
guildoracle.list
list
Definition: guildoracle.py:87
treasurestruct
Definition: treasure.h:63
writeItem
static void writeItem(const treasure *item, StringBuffer *buf)
Definition: TreasureWriter.cpp:17
W
#define W(x, n)
Definition: TreasureWriter.cpp:15
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.c:95
TreasureWriter::write
virtual void write(const treasurelist *list, StringBuffer *buf)
Definition: TreasureWriter.cpp:46
StringBuffer
Definition: stringbuffer.c:25
item
Definition: item.py:1
buf
StringBuffer * buf
Definition: readable.c:1610
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.c:138
TreasureWriter.h
treasureliststruct
Definition: treasure.h:82
give.name
name
Definition: give.py:27