Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Logg-y committed Apr 19, 2022
1 parent c8e9665 commit 3490dca
Show file tree
Hide file tree
Showing 22 changed files with 4,820 additions and 0 deletions.
144 changes: 144 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
output/*.dm
log.txt
magicgen/
magicgen.zip

# pycharm things
.idea/
outputs/

# Nuitka leftovers
*.exe
*.dll

blessgen*.zip
*.dbm
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.8"
112 changes: 112 additions & 0 deletions blesseffect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import re
import utils

EFFECTS_REQURING_MONTAG_DUMMIES = [564, 164]

class BlessEffect(object):
def __init__(self):
self.id = None
self.name = None
self.effects = {}
self.scales = {}
self.effect10buffs = 0
self.multipick = 0
self.alwaysactive = 0
self.path1 = 0
self.path2 = -1
self.path1level = 0
self.path2level = 0
self.descr = ""
def processstring(self, string):
out = string
while 1:
m = re.search("\\[EFFECT(\\d*)\\]", out)
if m is not None:
effectID = int(m.group(1))
effectMag = str(self.effects.get(effectID, "???"))
out = re.sub("\\[EFFECT\\d*\\]", effectMag, out, count=1)
continue

m = re.search("\\[EFFECTTIMES25_(\\d*)\\]", out)
if m is not None:
effectID = int(m.group(1))
if effectID in self.effects:
effectMag = str(self.effects.get(effectID)*25)
else:
effectMag = "???"
out = re.sub("\\[EFFECTTIMES25_\\d*\\]", effectMag, out, count=1)
continue

m = re.search("\\[EFFECTDIV10_(\\d*)\\]", out)
if m is not None:
effectID = int(m.group(1))
if effectID in self.effects:
effectMag = str(round(self.effects.get(effectID) / 10, 1))
else:
effectMag = "???"
out = re.sub("\\[EFFECTDIV10_\\d*\\]", effectMag, out, count=1)
continue

break
return out
def _prepareMonsterDummy(self, effectMag):

s = """
#newmonster {}
#copystats 284
#copyspr 284
#firstshape {}
#secondshape {}
#regeneration -999
#landdamage 100
#uwdamage 100
#drawsize -99
#woundfend 99
#hp 1
#amphibian
#mr 15
#itemslots 262143
#name "{}"
#descr "This unit has no purpose except to spawn in a unit of montag {}."
#end
"""
s = s.format(utils.START_UNIT_ID, effectMag, effectMag, f"Dummy Montag {effectMag}", effectMag)
utils.START_UNIT_ID += 1
return s
def output(self):
if len(self.name) < 31 and self.multipick:
self.name += "*"
out = f"#selectbless {utils.START_BLESS_ID}\n"
out += f"#clear\n"
if self.name is None:
self.name = f"Unnamed Bless {utils.START_BLESS_ID}"
out += f'#name "{self.processstring(self.name)}"' + "\n"
out += f'--#descr "{self.processstring(self.descr)}'
if self.alwaysactive:
out += " This effect does not require sacred units to be blessed."
out += '"'
out += "\n"
utils.START_BLESS_ID += 1
out += f"#path1 {self.path1}\n"
out += f"#path2 {self.path2}\n"
out += f"#path1level {self.path1level}\n"
out += f"#path2level {self.path2level}\n"
if self.effect10buffs > 0:
out += f"#effect10buffs {self.effect10buffs}\n"
if self.multipick:
out += "#multipick\n"
if self.alwaysactive:
out += "#alwaysactive\n"
for effect, effectMag in self.effects.items():
# This would work, if .dm commands were also valid in .dbm files
# potentially useful, but needs converting to write an accompanying .dm file
#if effect in EFFECTS_REQURING_MONTAG_DUMMIES and effectMag < 0:
# out = self._prepareMonsterDummy(effectMag) + out
# effectMag = utils.START_UNIT_ID - 1
out += f"#addeffect {effect} {effectMag} -- {utils.EFFECT_IDS_TO_LABELS.get(effect, 'Unknown Effect')}\n"
for scale, scaleMag in self.scales.items():
if scaleMag != 0:
out += f"#reqscale {scale} {int(scaleMag)}\n"
out += "#end\n\n"
return out
Loading

0 comments on commit 3490dca

Please sign in to comment.