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 <string>
14
#include "
TreasureWriter.h
"
15
16
#define W(x, n) { if (item->x) { stringbuffer_append_printf(buf, "%s" n "\n", indentItems.c_str(), item->x); } }
17
18
static
void
writeItem
(
const
treasure
*
item
,
const
std::string &indent,
StringBuffer
*
buf
) {
19
std::string indentItems(indent);
20
indentItems +=
"\t"
;
21
if
(
item
->item) {
22
stringbuffer_append_printf
(
buf
,
"%sarch %s\n"
, indentItems.c_str(),
item
->item->name);
23
}
24
W
(
artifact
,
"artifact %s"
);
25
W
(
name
,
"list %s"
);
26
W
(list_magic_value,
"list_magic_value %d"
);
27
W
(list_magic_adjustment,
"list_magic_adjustment %d"
);
28
indentItems +=
"\t"
;
29
W
(change_arch.name,
"change_name %s"
);
30
W
(change_arch.title,
"change_title %s"
);
31
W
(change_arch.slaying,
"change_slaying %s"
);
32
if
(
item
->chance != 100) {
33
stringbuffer_append_printf
(
buf
,
"%schance %d\n"
, indentItems.c_str(),
item
->chance);
34
}
35
W
(nrof,
"nrof %d"
);
36
W
(magic,
"magic %d"
);
37
if
(
item
->next_yes) {
38
stringbuffer_append_printf
(
buf
,
"%syes\n"
, indentItems.c_str());
39
writeItem
(
item
->next_yes, indentItems +
"\t"
,
buf
);
40
}
41
if
(
item
->next_no) {
42
stringbuffer_append_printf
(
buf
,
"%sno\n"
, indentItems.c_str());
43
writeItem
(
item
->next_no, indentItems +
"\t"
,
buf
);
44
}
45
if
(
item
->next) {
46
stringbuffer_append_string
(
buf
,
"more\n"
);
47
writeItem
(
item
->next, indent,
buf
);
48
}
else
{
49
stringbuffer_append_printf
(
buf
,
"%send\n"
, indent.c_str());
50
}
51
}
52
53
void
TreasureWriter::write
(
const
treasurelist
*
list
,
StringBuffer
*
buf
) {
54
if
(
list
->total_chance == 0) {
55
stringbuffer_append_string
(
buf
,
"treasure "
);
56
}
else
{
57
stringbuffer_append_string
(
buf
,
"treasureone "
);
58
}
59
stringbuffer_append_string
(
buf
,
list
->name);
60
stringbuffer_append_string
(
buf
,
"\n"
);
61
writeItem
(
list
->items, std::string(),
buf
);
62
}
writeItem
static void writeItem(const treasure *item, const std::string &indent, StringBuffer *buf)
Definition:
TreasureWriter.cpp:18
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition:
stringbuffer.cpp:138
guildoracle.list
list
Definition:
guildoracle.py:87
buf
StringBuffer * buf
Definition:
readable.cpp:1565
treasurelist
Definition:
treasure.h:85
W
#define W(x, n)
Definition:
TreasureWriter.cpp:16
TreasureWriter::write
virtual void write(const treasurelist *list, StringBuffer *buf)
Definition:
TreasureWriter.cpp:53
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition:
stringbuffer.cpp:95
StringBuffer
Definition:
stringbuffer.cpp:25
item
Definition:
item.py:1
TreasureWriter.h
treasure
Definition:
treasure.h:63
artifact
Definition:
artifact.h:14
give.name
name
Definition:
give.py:27
crossfire-crossfire-server
common
assets
TreasureWriter.cpp
Generated by
1.8.17