From 87f14b13db50d9216c71a389b5ce4274bb564d59 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 19 Mar 2018 00:06:03 -0300 Subject: Renew the Monster WikiGenerator --- wiki/wikigen.py | 187 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 142 insertions(+), 45 deletions(-) (limited to 'wiki') diff --git a/wiki/wikigen.py b/wiki/wikigen.py index b4c48d6..f76a726 100755 --- a/wiki/wikigen.py +++ b/wiki/wikigen.py @@ -55,55 +55,90 @@ def showFooter(): -def writeMob(wikib, tmb): - wikib.write("|"+ - tmb[0]+"|"+ - tmb[1]+"|"+ - tmb[2]+"|"+ - tmb[3]+"|"+ - tmb[4]+"|"+ - tmb[5]+"|"+ - tmb[6]+"|"+ - tmb[7]+"|\n" - ) +class Mob: + def __init__(self): + # Basic + self.id="0" + #self.aegis="UnknownMonster" # SpriteName is not used anywhere, we are using its ID + self.name="Unknown Monster Name" + self.view="1" + + # Defensive + self.mobpt="0" # Mob Points “Level” + self.hp="0" + self.xp="0" + self.jp="0" + self.st="" + + # Offensive + self.atk="[0, 0]" + self.range="0" + self.move="0" + self.delay="0" + self.drops=[] + +AggMobs=[] +NrmMobs=[] + +def MobAlloc(ab): + if "agr" in ab.st.lower(): + AggMobs.append(ab) + else: + NrmMobs.append(ab) def testMobs(): print("Generating Mob Wiki...") src=open("../../server-data/db/re/mob_db.conf", "r") wikib.write("# Monster Database\n") - wikib.write("|ID|Name|hp|xp|def|atk|delay|modes|\n") - # 0 1 2 3 4 5 6 7 - #tm_entry=False # TODO: Drop list - tmb=['--','----','--','--','---','---','-----','-----'] - # 0 1 2 3 4 5 6 7 + start=False + dropper=False + for a in src: if a == "{\n": - writeMob(wikib, tmb) - tmb=['','','','','','', '', ''] - # 0 1 2 3 4 5 6 7 - if " Id:" in a: - tmb[0]=stp(a) - if " Name:" in a: - tmb[1]=stp(a) - if " Hp:" in a: - tmb[2]=stp(a) - if " Exp:" in a: - tmb[3]=stp(a) - if " Def:" in a: - tmb[4]=stp(a) - if " Attack:" in a: - tmb[5]=stp(a) - if " AttackDelay:" in a: - tmb[6]=stp(a) - if " Looter: true" in a: - tmb[7]+="Lot," - if " Assist: true" in a: - tmb[7]+="Ass," - if " Aggressive: true" in a: - tmb[7]+="Agr," + if start: + MobAlloc(x) + else: + start=True + x=Mob() + if " Id:" in a: + x.id=stp(a) + elif " Name:" in a: + x.name=stp(a) + elif " Hp:" in a: + x.hp=stp(a) + elif " Level:" in a: + x.mobpt=stp(a) + elif " Exp:" in a: + x.xp=stp(a) + elif " JExp:" in a: + x.jp=stp(a) + elif " Attack:" in a: + x.atk=stp(a) + elif " AttackRange:" in a: + x.range=stp(a) + elif " MoveSpeed:" in a: + x.move=stp(a) + elif " ViewRange:" in a: + x.view=stp(a) + elif " AttackDelay:" in a: + x.delay=stp(a) + elif " Looter: true" in a: + x.st+="Lot," + elif " Assist: true" in a: + x.st+="Ass," + elif " Aggressive: true" in a: + x.st+="Agr," + elif 'Drops: ' in a: + dropper=True + elif dropper and '}' in a: + dropper=False + elif dropper: + x.drops.append(stp(a)) # Write last entry - writeMob(wikib, tmb) + MobAlloc(x) + + writeMob() wikib.write('\n\n|Mode|Desc|\n|----|----|\n') wikib.write('|Lot|Looter|\n') @@ -113,15 +148,77 @@ def testMobs(): src.close() def stp(x): - return x.replace('\n', '').replace('|', '').replace('(int, defaults to ', '').replace(')', '').replace('basic experience', '').replace('"','').replace(" ","").replace('(string', '').replace('Name: ','').replace('AttackDelay', 'ms') - - - - + return x.replace('\n', '').replace('|', '').replace('(int, defaults to ', '').replace(')', '').replace('basic experience', '').replace('"','').replace(" ","").replace('(string', '').replace('Name: ','').replace('AttackDelay: ', '').replace('MoveSpeed: ', '').replace('AttackRange: ', '').replace('ViewRange: ','') + + +def writeMob(): + wikib.write("\ ++ [Aggressive Monsters](#aggressive-monsters)\n\ ++ [Other Monsters](#other-monsters)\n\n\ + ") + + wikib.write("## Aggressive Monsters\n\n") + + wikib.write("\n") + wikib.write("\n") + for i in AggMobs: + wikib.write('\n" + ) + wikib.write("
IDNameHPAtkDelayView RangeMisc InfoRewardsDrops
' + + i.id +""+ + i.name +"HP: "+ + i.hp +"Atk: "+ + i.atk +""+ + i.delay +" msView: "+ + i.view +""+ + mbdt('misc', mb_rdmisc(i)) +""+ + mbdt('Exp\'s', mb_rdrw(i)) +""+ + mbdt('drops', mb_rddrop(i)) +"
\n") + wikib.write("\n[(↑) Return to top](#items)\n\n") + + + wikib.write("## Normal Monsters\n\n") + + wikib.write("\n") + wikib.write("\n") + for i in NrmMobs: + wikib.write('\n" + ) + wikib.write("
IDNameHPAtkDelayMisc InfoRewardsDrops
' + + i.id +""+ + i.name +"HP: "+ + i.hp +"Atk: "+ + i.atk +""+ + i.delay +" ms"+ + mbdt('misc', mb_rdmisc(i)) +""+ + mbdt('Exp\'s', mb_rdrw(i)) +""+ + mbdt('drops', mb_rddrop(i)) +"
\n") + wikib.write("\n[(↑) Return to top](#items)\n\n") +def mbdt(summary, content): + return "
\ +"+summary+"\ +
"+content+"
" +def mb_rdmisc(mb): + buff="" + buff+="Modes: %s\n" % (mb.st) + buff+="Attack Range: %s\n" % (mb.range) + buff+="Move speed: %s ms\n" % (mb.move) + return buff +def mb_rdrw(mb): + buff="" + buff+="MobPoints: %s\n" % (mb.mobpt) + buff+="%s\n" % (mb.xp) + buff+="%s\n" % (mb.jp) + return buff +def mb_rddrop(mb): + buff="" + for ax in mb.drops: + buff+=ax+'\n' + return buff class It: -- cgit v1.2.3-70-g09d2