yksehtniycul
|
don't play with me 'cause you're playing with fire |
I have the CSV export fully parsed:
Input:
DIGITAL DEVIL DATABASE www.digitaldevildb.com "Personae Database for Megami Ibunroku Persona ""Be Your True Mind"" and Revelations: Persona" Some Useful Online Links:,,,,,,,,,URLs: Revelations: Persona to English and in-game names in romaji:,,,,,,,,,http://www.sumarucity.com/megami/wiki/index.php?title=Persona_Name_Changes Megami Ibunroku personae names in katakana by level:,,,,,,,,,http://fool-est.hp.infoseek.co.jp/persona/ibunroku/data/lv_persona.html Revelations: Persona personae stats:,,,,,,,,,http://www.gamefaqs.com/console/psx/file/198277/4086 Editing Guidelines: "- Columns marked with asterisks, ie. *, are required to be filled. This probably only applies in the first column." "- Table beginning rows are yellow, legends are grey, information is white, and notes are purple." "- Synonym rows start with the dollar sign, ie. $, personae rows begin with a number, the persona's level, and persona descriptions begin with an exclamation point, ie. !" "- Never use commas, ie. (,) for now... as commas make processing the .csv file considerably more complicated." Synonyms Table Alphabetically Sorted by Revelations Titles *,Revelations,,English Translation,,,,Megami,,,,functions,,,,,reserved,,,,,notes $,Hell Book,,Book of the Dead,,,,閻魔帳,,,,item,,,,,,,,,,A recipe item. 閻魔帳 is a book used by Yama to judge the dead; and can also humorously mean a class grades ledger -- the teacher assuming the role of Yama in this play on words. Personae Table Sorted According to Persona Level *,Names,,,Tarot,,Growth,Non-,Items,,Stats,,,,,,,Skills,,,,,,,Affinity Lv,English,Megami,Revelations,Arcana,SP,Pattern,Compat,Recipe,Return,STR,VIT,TEC,AGL,LUC,MAG,INT,Lv1,Lv2,Lv3,Lv4,Lv5,Lv6,Lv7,Weak,Resist,Immune,Reflect,Drain,Type 4,Yama ,ヤマ,Trickster,5 Heiro.,3,大器晩成B型,降魔,Hell Book,パララマストーン,15,17,12,15,7,55,55,Duel Sword; DEF up; Spirit norm; Holyer; STR up,,,,,,,,Magic,,,,Holylight; Exorcism !,All we know about Yama here... *,Names,,,Tarot,,Growth,Non-,Items,,Stats,,,,,,,Skills,,,,,,,Affinity Lv,English,Megami,Revelations,Arcana,SP,Pattern,Compat,Recipe,Return,STR,VIT,TEC,AGL,LUC,MAG,INT,Lv1,Lv2,Lv3,Lv4,Lv5,Lv6,Lv7,Weak,Resist,Immune,Reflect,Drain,Type 4,Pixie,ピクシー,Pixie,6 Lovers,2,ピクシー専用型,地震,,LUKインセンス,5,10,7,16,18,42,63,Cure; Wind; Happy Dance; Flash; Star Punch; Bolt,,,,,,,Physical,,,Wind,,Elemental; Air !,All we know about Pixie here...
Output:
php test ok! preview ok! importing... found 23 rows... 26 Synonyms imported... ITEM Book of the Dead 閻魔帳 / Hell Book A recipe item. 閻魔帳 is a book used by Yama to judge the dead; and can also humorously mean a class grades ledger -- the teacher assuming the role of Yama in this play on words. generated! TYPE unknown 大器晩成B型 / missing generated! TYPE unknown 降魔 / missing generated! ITEM unknown パララマストーン / missing generated! SKILL unknown 知りない / Duel Sword generated! SKILL unknown 知りない / DEF up generated! SKILL unknown 知りない / Spirit norm generated! SKILL unknown 知りない / Holyer generated! SKILL unknown 知りない / STR up generated! TYPE unknown 知りない / Magic generated! TYPE unknown 知りない / Holylight generated! TYPE unknown 知りない / Exorcism generated! PERSONA Yama ヤマ / Trickster generated! TYPE unknown ピクシー専用型 / missing generated! TYPE unknown 地震 / missing generated! ITEM unknown LUKインセンス / missing generated! SKILL unknown 知りない / Cure generated! TYPE unknown 知りない / Wind generated! generated! SKILL unknown 知りない / Happy Dance generated! SKILL unknown 知りない / Flash generated! SKILL unknown 知りない / Star Punch generated! SKILL unknown 知りない / Bolt generated! TYPE unknown 知りない / Physical generated! TYPE unknown 知りない / Elemental generated! TYPE unknown 知りない / Air generated! PERSONA Pixie ピクシー / Pixie generated! 2 Personae imported... Hierophant Yama ヤマ / Trickster All we know about Yama here... 大器晩成B型; 降魔; Book of the Dead; パララマストーン 15STR 17VIT 12TEC 15AGL 7LUC 55MAG 55INT STR up, Holyer, Spirit norm, DEF up, Duel Sword; unknown(0); Magic; unknown(0); unknown(0); unknown(0); Holylight Exorcism Lovers Pixie ピクシー / Pixie All we know about Pixie here... ピクシー専用型; 地震; unknown(0); LUKインセンス 5STR 10VIT 7TEC 16AGL 18LUC 42MAG 63INT Bolt, Star Punch, Flash, Happy Dance, Wind, Cure; Physical; unknown(0); unknown(0); Wind; unknown(0); Elemental Air
Source code:
/* we begin in php mode */
echo 'php test ok!<br>';
if(!$_POST['d3-preview']) return;
echo 'preview ok!<br>';
$importing = &$_POST['import-input'];
if(!$importing ) return; else echo 'importing...<br>'; //, $importing, '<br><br>';
define("UNKNOWN",0); define("PERSONA",1); define("DEMON",2); define("SKILL",3); define("ITEM",4); define("TYPE",5);
class Synonym { var $name = 'unknown'; var $mip_name = '知りない'; var $rev_name = 'missing'; var $function = 0; var $notes = NULL; var $more = 0; }
$Synonyms = array();
$Synonym[0] = new Synonym; //Null Synonym
$Lookups = array(0=>0,""=>0,"unknown"=>0,"知りない"=>0);
$s = 0; //Synonym counter
function Lookup($f,$Name,$MIP=NULL,$Rev=NULL,$Notes="generated!") { if(!$Name&&!$MIP&&!$Rev) return 0; //hack?
if(is_null($MIP)&&!is_null($Name)) { $Name = ltrim($Name); if($Name[0]>'z') //... { $MIP = $Name; $Name = NULL; //hack: assuming Japanese } } if(is_null($Rev)&&!is_null($Name)) { $Rev = $Name; $Name = NULL; //hack: assuming Revelations }
if(is_string($f)) { switch(strtolower(trim($f))) { default: $f = UNKNOWN; case "persona": $f = PERSONA; break; case "demon": $f = DEMON; break; case "skill": $f = SKILL; break; case "item": $f = ITEM; break; case "type": $f = TYPE; break; } } else if($f>5) $f = UNKNOWN; //hack
global $Synonyms, $Lookups, $s; $S = NULL; $out = $Lookups[$Name]; if(is_null($out)) //add synonym { if(!$S) $S = $Synonyms[$out=++$s] = new Synonym(); $Lookups[$S->name=trim($Name)] = $s; } else if($out) $S = $Synonyms[$out]; $mip = $Lookups[$MIP?$MIP:NULL]; if(is_null($mip)) //add synonym { if(!$S) $S = $Synonyms[$out=++$s] = new Synonym(); $Lookups[$S->mip_name=trim($MIP)] = $s; } else if($mip) { if(!$S) $S = $Synonyms[$out=$mip]; $S->mip_name = trim($MIP); //danger: overwriting } $rev = $Lookups[$Rev?$Rev:NULL]; if(is_null($rev)) //add synonym { if(!$S) $S = $Synonyms[$out=++$s] = new Synonym(); $Lookups[$S->rev_name=trim($Rev)] = $s; } else if($rev) { if(!$S) $S = $Synonyms[$out=$rev]; $S->rev_name = trim($Rev); //danger: overwriting } if(!$S) return $out; //out probably zero $S->function = $f; //danger: overwriting if($Notes) if(!$S->notes) $S->notes = $Notes; else $S->notes.=" ".$Notes; return $out; }
class Persona { var $synonym = 0;
var $lvl = 0; var $name = 'unknown'; var $mip_name = '知りない'; var $rev_name = 'missing'; var $arcana = 22; //lookup var $sp = 0; var $pattern = 0; //lookup var $compat = NULL; //lookup array var $recipe = NULL; //lookup array var $return = 0; //lookup var $str = 0; var $vit = 0; var $tec = 0; var $agl = 0; var $luc = 0; var $mag = 0; var $int = 0; var $skills = NULL; //lookup array var $weak = NULL; //lookup array var $resist = NULL; //lookup array var $immune = NULL; //lookup array var $reflect = NULL; //lookup array var $drain = NULL; //lookup array var $typeA = 0; //lookup var $typeB = 0; //lookup var $story = ""; }
$Personae = array();
$Personae[0] = new Persona; //Null Persona
$lines = explode("\r\n",$importing); //hack??
$rows = sizeof($lines);
echo 'found ', $rows, ' rows... <br>';
for($r=0,$p=0;$r<$rows;$r++) { $row = &$lines[$r];
$mode = $row[0];
if($mode=='$') //a synonym line { $in = explode(",",$row); $cols = sizeof($stats); Lookup($in[11],$in[3],$in[7],$in[1],$in[21]); } else if($mode>='0'&&$mode<='9') //a persona line { //printf("%04d %s <br>",$r,$row);
$P = $Personae[++$p] = new Persona(); $stats = explode(",",$row); $cols = sizeof($stats); for($c=0;$c<$cols;$c++) switch($c) { case 0: $P->lvl = (integer)$stats[0]; break; case 1: $P->name = trim($stats[1]); break; case 2: $P->mip_name = trim($stats[2]); break; case 3: $P->rev_name = trim($stats[3]); break; case 4: $P->arcana = (integer)$stats[4]; break; case 5: $P->sp = (integer)$stats[5]; break; case 6: $P->pattern = Lookup(TYPE,$stats[6]); break; case 7: $P->compat = array(); { $list = explode(";",$stats[7]); $n = sizeof($list); for($i=0;$i<$n;$i++) $P->compat[] = Lookup(TYPE,$list[$i]); break; } case 8: $P->recipe = array(); { $list = explode(";",$stats[8]); $n = sizeof($list); if($n) $P->recipe[0] = Lookup(ITEM,$list[0]); for($i=1;$i<$n;$i++) $P->recipe[] = Lookup(DEMON,$list[$i]); break; } case 9: $P->return = Lookup(ITEM,$stats[9]); break; case 10: $P->str = $stats[10]; break; case 11: $P->vit = $stats[11]; break; case 12: $P->tec = $stats[12]; break; case 13: $P->agl = $stats[13]; break; case 14: $P->luc = $stats[14]; break; case 15: $P->mag = $stats[15]; break; case 16: $P->int = $stats[16]; break; case 17: $P->skills = array(); { $skills = explode(";",$stats[17]); for($i=0,$n = sizeof($skills);$i<$n;$i++) $P->skills[] = Lookup(SKILL,$skills[$i]); break; } case 18: case 19: case 20: case 21: case 22: case 23: { if($stats[$c]&&$stats[$c][0]) $P->skills[] = Lookup(SKILL,$stats[$c]); break; } case 24: $P->weak = array(); { $types = explode(";",$stats[24]); for($i=0,$n = sizeof($types);$i<$n;$i++) $P->weak[] = Lookup(TYPE,$types[$i]); break; } case 25: $P->resist = array(); { $types = explode(";",$stats[25]); for($i=0,$n = sizeof($types);$i<$n;$i++) $P->resist[] = Lookup(TYPE,$types[$i]); break; } case 26: $P->immune = array(); { $types = explode(";",$stats[26]); for($i=0,$n = sizeof($types);$i<$n;$i++) $P->immune[] = Lookup(TYPE,$types[$i]); break; } case 27: $P->reflect = array(); { $types = explode(";",$stats[27]); for($i=0,$n = sizeof($types);$i<$n;$i++) $P->reflect[] = Lookup(TYPE,$types[$i]); break; } case 28: $P->drain = array(); { $types = explode(";",$stats[28]); for($i=0,$n = sizeof($types);$i<$n;$i++) $P->drain[] = Lookup(TYPE,$types[$i]); break; } case 29: { $types = explode(";",$stats[29]); if(sizeof($types)<2) continue; $P->typeA = Lookup(TYPE,$types[0]); $P->typeB = Lookup(TYPE,$types[1]); break; } default: $c = $cols; //finish } $P->synonym = Lookup(PERSONA,$P->name,$P->mip_name,$P->rev_name); } else if($mode=='!') //a description line { if(!$p) continue; //no Persona exist yet
for($i=1;$row[$i]&&$row[$i]!=',';$i++); if($row[$i]) $Personae[$p]->story.=substr($row,++$i); } else continue; }
echo $s, ' Synonyms imported... <br>';
$Functions = array ( "UNKNOWN","PERSONA", "DEMON", "SKILL", "ITEM", "TYPE" );
for($i=1;$i<=$s;$i++) { $S = $Synonyms[$i];
echo $Functions[$S->function<6?$S->function:0], ' '; echo $S->name, '<br>', $S->mip_name, ' / ', $S->rev_name, '<br> ', $S->notes,'<br>'; }
echo $p, ' Personae imported... <br>';
$Tarot = array ( "0", "The ", "Fool", "I", "The ", "Magician", "II", "The High", "Priestess", "III", "The ", "Empress", "IV", "The ", "Emperor", "V", "The ", "Hierophant", "VI", "The ", "Lovers", "VII", "The ", "Chariot", "VIII", "The ", "Strength", "IX", "The ", "Hermit", "X", "The Wheel of", "Fortune", "XI", "", "Justice", "XII", "The ", "Hanged Man", "XIII", "", "Death", "XIV", "", "Temperance", "XV", "The ", "Devil", "XVI", "The ", "Tower", "XVII", "The ", "Star", "XVIII", "The ", "Moon", "XIX", "The ", "Sun", "XX", "", "Judgment", "XXI", "The ", "World", "?", "The", "Null" );
function Synonym($s) { global $Synonyms, $Lookups; $S = $Synonyms[$s]; if($Lookups[$S->name]) return $S->name; if($Lookups[$S->mip_name]) return $S->mip_name; if($Lookups[$S->rev_name]) return $S->rev_name; return 'unknown('. $s .')'; }
for($i=1;$i<=$p;$i++) { $P = $Personae[$i];
echo $Tarot[$P->arcana%23*3+2], ' ', $P->name, '<br>', $P->mip_name, ' / ', $P->rev_name, '<br> ', $P->story,'<br>'; echo Synonym($P->pattern), '; '; for($ii=sizeof($P->compat);$ii;$ii--) echo Synonym($P->compat[$ii-1]), $ii>1?', ':'; '; for($ii=sizeof($P->recipe);$ii;$ii--) echo Synonym($P->recipe[$ii-1]), $ii>1?', ':'; '; echo Synonym($P->return), '<br>'; echo $P->str, 'STR ', $P->vit, 'VIT ', $P->tec, 'TEC ', $P->agl, 'AGL ', $P->luc, 'LUC ', $P->mag, 'MAG ', $P->int, 'INT <br>'; for($ii=sizeof($P->skills);$ii;$ii--) echo Synonym($P->skills[$ii-1]), $ii>1?', ':';<br>'; for($ii=sizeof($P->weak);$ii;$ii--) echo Synonym($P->weak[$ii-1]), $ii>1?', ':'; '; for($ii=sizeof($P->resist);$ii;$ii--) echo Synonym($P->resist[$ii-1]), $ii>1?', ':'; '; for($ii=sizeof($P->immune);$ii;$ii--) echo Synonym($P->immune[$ii-1]), $ii>1?', ':'; '; for($ii=sizeof($P->reflect);$ii;$ii--) echo Synonym($P->reflect[$ii-1]), $ii>1?', ':'; '; for($ii=sizeof($P->drain);$ii;$ii--) echo Synonym($P->drain[$ii-1]), $ii>1?', ':';<br>'; echo Synonym($P->typeA), ' ', Synonym($P->typeB), '<br>'; }
/* we should end in php mode */
« Last Edit: November 30, 2008, 05:20:52 PM by yksehtniycul »
|
Logged yksehtniycul has 2094 Posts (+0/-0 Karma) |
|
|