1 ## This file is part of Crapvine.
3 ## Copyright (C) 2007 Andrew Sayman <lorien420@myrealbox.com>
5 ## Crapvine is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or
8 ## (at your option) any later version.
10 ## Crapvine is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from grapevine_xml
import Attributed
, AttributedListModel
20 from attribute
import AttributeBuilder
21 from xml
.sax
.saxutils
import escape
23 class Vampire(Attributed
):
24 required_attrs
= ['name']
25 text_attrs
= ['nature', 'demeanor', 'clan', 'sect', 'coterie', 'sire', 'title', 'path', 'aura', 'aurabonus', 'status', 'narrator', 'player', 'id' ]
26 number_as_text_attrs
= ['generation', 'blood', 'tempblood', 'willpower', 'tempwillpower', 'conscience', 'tempconscience', 'selfcontrol', 'tempselfcontrol', 'courage', 'tempcourage', 'pathtraits', 'temppathtraits', 'physicalmax']
27 date_attrs
= ['startdate', 'lastmodified']
29 defaults
= { 'npc' : False }
30 linked_defaults
= { 'tempconscience' : 'conscience', 'tempselfcontrol' : 'selfcontrol', 'tempwillpower' : 'willpower', 'tempblood': 'blood', 'tempcourage': 'courage', 'temppathtraits' : 'pathtraits' }
32 text_children
= ['notes', 'biography']
34 attr_menu_map
= {'nature' : 'Archetypes', 'demeanor' : 'Archetypes', 'title' : 'Title, Vampire', 'status' : 'Status, Character' }
38 self
.experience
= None
40 def add_traitlist(self
, traitlist
):
41 self
.traitlists
.append(traitlist
)
43 def add_experience(self
, exp
):
46 def get_xml(self
, indent
= ''):
47 ret
= '%s<vampire %s>%s' % (indent
, self
.get_attrs_xml(), "\n")
48 local_indent
= '%s ' % (indent
)
50 ret
+= self
.experience
.get_xml(local_indent
)
52 ret
+= "\n".join([traitlist
.get_xml(local_indent
) for traitlist
in self
.traitlists
])
54 for child_name
in self
.text_children
:
55 if self
[child_name
] != '':
57 lines
= ['<%s>' % (child_name
), ' <![CDATA[%s]]>' % (escape(self
[child_name
])), '</%s>' % (child_name
)]
58 ret
+= "\n".join(['%s%s' % (local_indent
, inny
) for inny
in lines
])
59 ret
+= '%s%s</vampire>' % ("\n", indent
)