Quote:
Originally Posted by beverson I've been really hoping that some XML magician would figure out how to make the character sheet look like the ones WotC used for the pregens previously. I was disturbed and mildly annoyed that the latest batch of pregens they posted were in the less attractive Character Builder format.
I thought the "general consensus" was that the old pregen format was great and lots of people would love to have the Builder make sheets like that - was I wrong, or is it just not possible yet? |
I suggest to parse the .dnd4e files with php DOM. You can fetch datas and then reassemble the information as you like... For example I reaggregate the characters stats like this:
HTML Code:
<character id="1" name="Icaro Nero" owner="Alessio" flags="0">
<level xp100="56">7</level>
<deathST>3</deathST>
<status>0</status>
<ability name="str">20</ability>
<ability name="con">13</ability>
<ability name="dex">11</ability>
<ability name="int">11</ability>
<ability name="wis">18</ability>
<ability name="cha">15</ability>
<hp tmp="0" hp100="100" color="0064C8">69</hp>
<hs tot="11" sw="0">3</hs>
<defense name="ac">23</defense>
<defense name="for">22</defense>
<defense name="rfx">17</defense>
<defense name="wll">21</defense>
<initiative>3</initiative>
<speed>5</speed>
<skill name="acr">1</skill>
<skill name="arc">3</skill>
<skill name="atl">6</skill>
<skill name="blu">5</skill>
<skill name="dip">10</skill>
<skill name="dun">7</skill>
<skill name="end">2</skill>
<skill name="hea">7</skill>
<skill name="his">8</skill>
<skill name="ins">12</skill>
<skill name="int">10</skill>
<skill name="nat">7</skill>
<skill name="per">7</skill>
<skill name="rel">8</skill>
<skill name="ste">1</skill>
<skill name="str">5</skill>
<skill name="thi">1</skill>
<ap used="0">1</ap>
<power id="MELEE_BASIC_ATTACK" used="0" usage="at-will" action="Standard Action">Melee basic attack</power>
<power id="RANGED_BASIC_ATTACK" used="0" usage="at-will" action="Standard Action">Ranged basic attack</power>
<power id="833" used="0" usage="at-will" action="Standard Action">Bolstering strike</power>
<power id="805" used="0" usage="at-will" action="Minor Action">Divine challenge</power>
<power id="1566" used="0" usage="at-will" action="Minor Action">Lay on hands</power>
<power id="836" used="0" usage="at-will" action="Standard Action">Enfeebling strike</power>
<power id="1567" used="0" usage="at-will" action="Standard Action">Holy strike</power>
<power id="1746" used="0" usage="encounter" action="Minor Action">Divine mettle</power>
<power id="1747" used="0" usage="encounter" action="Minor Action">Divine strength</power>
<power id="3069" used="0" usage="encounter" action="Minor Action">Oath of enmity</power>
<power id="684" used="0" usage="encounter" action="Standard Action">Fearsome smite</power>
<power id="1568" used="0" usage="encounter" action="Standard Action">Invigorating smite</power>
<power id="3609" used="0" usage="encounter" action="Minor Action">Righteous rage of tempus</power>
<power id="1445" used="0" usage="encounter" action="Standard Action">Divine reverence</power>
<power id="2258" used="0" usage="daily" action="Standard Action">Paladin's judgment</power>
<power id="1255" used="0" usage="daily" action="Standard Action">Sacred circle</power>
<power id="1267" used="1" usage="daily" action="Standard Action">Martyr's retribution</power>
<power id="1279" used="1" usage="daily" action="Minor Action">Wrath of the gods</power>
<powers wll="7" enc="7" day="2" itm="1" />
<cash rs="0" ad="0" pp="0" gp="2391" sp="0" cp="0" />
<stored rs="" ad="" pp="" gp="" sp="" cp="" />
</character>
Then just save the new .xml file with the right .xslt to transform.
I found everything i needed on the php documentation. Anyway i'll post the function i use to access the .dnd4e file (hope this might help):
NB: looks like the forum is eating the variables... So I'll post the script replacing $ con £. REVERT IT TO MAKE THE SCRIPT RUN...!!! Code:
// XPATH FUNCTION
function getNodes(£myDoc,£myStr) {
£myPath=new DOMXPath(£myDoc);
£myPath->registerNamespace('dnd4e','http://www.wizards.com/default.asp?x=dnd/');
£myResult=array();
£myNodes=£myPath->query(£myStr);
foreach(£myNodes as £node){
array_push(£myResult,£node);
}
return £myResult;
}
// MAIN SCRIPT
£iOS="<?xml version="1.0" encoding="UTF-8"?>"; // The output XML
£iOS.="<?xml-stylesheet type="text/xsl" href="style.xslt"?>"; // Link the XSLT file
£iOS.="<party>";
£iXML=new DOMDocument();
£iCharacter=array(/* SUPPOSE TO HAVE A LIST OF YOUR CHARACTERS' IDs HERE... */)
foreach(£iCharacter as £cid){
£iXML->load("path/to/character{£cid}.dnd4e"); // Suppose you saved the character builder's file like character0.dnd4e, character1.dnd4e, and so on...
// Now you just need to target the right tag on the .dnd4e file...
// For example choose the Stat tag
£iNodes=getNodes(,"/D20Character/CharacterSheet/StatBlock/Stat");
foreach(£iNodes as £node){
switch(strtolower(£node->getAttribute('name'))){
case 'strength':
£iOS.="<ability name="str">".£node->getAttribute('value')."</ability>";
break;
case 'constitution':
£iOS.="<ability name="con">".£node->getAttribute('value')."</ability>;
break;
case 'dexterity':
£iOS.="<ability name="dex">".£node->getAttribute('value')."</ability>;
break;
case 'intelligence':
£iOS.="<ability name="int">".£node->getAttribute('value')."</ability>;
break;
case 'wisdom':
£iOS.="<ability name="wis">".£node->getAttribute('value')."</ability>;
break;
case 'charisma':
£iOS.="<ability name="cha">".£node->getAttribute('value')."</ability>;
break;
//and so on for every Stat tag you would like to read...
}
// Redo for other nodes to fetch informations from other tags (like powers)
}
}
£iOS.="</party>";
header('content-type: text/xml');
print £iOS;