Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes and enhancements #352

Merged
merged 26 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a24a94d
Fixed export to PDF when Tattoos are present on kiho sheet.
simonakey May 27, 2021
ad25c17
Fudge to allow tattoos to all
simonakey Jun 12, 2021
103ea11
Fix to non wrapping text on weapons sheet
simonakey Jun 12, 2021
0288097
Fix to Kiho to all characters to display
simonakey Jun 12, 2021
21016b2
Added Flat bonus to character sheet
simonakey Nov 6, 2021
0768a94
Fix requirement to allow later versions of a data pack
simonakey Nov 7, 2021
ecd1a24
Add bushi technique sheet if you are a ninja
simonakey Nov 7, 2021
d500ad9
local fixes
simonakey Dec 14, 2021
22b28a1
Fixed advancing in multiple insight ranks
simonakey Jan 15, 2022
3aa8a15
Merge branch 'OpenNingia:master' into master
simonakey Feb 6, 2022
bacf384
Merge branch 'OpenNingia:master' into master
simonakey Feb 7, 2022
96bdd41
Merge branch 'OpenNingia:master' into master
simonakey Feb 8, 2022
55499e5
Merge branch 'OpenNingia:master' into master
simonakey Feb 13, 2022
ced46f4
Fix to allow pdf export when Tattoo's on character sheet.
simonakey Feb 13, 2022
2b0ca7e
Merge branch 'master' of https://github.com/simonakey/l5r-character-m…
simonakey Feb 13, 2022
b1f82fb
Allow flat bonus to Attack rolls when using Modifiers
simonakey Feb 13, 2022
ccd643c
Advance single technique at a time when potential insight rank 2 or m…
simonakey Feb 13, 2022
05c48ed
Print kiho (monk sheet) for characters that can have Kiho.
simonakey Feb 14, 2022
2e1689e
Fix to add extra weapon pages when more than 10 weapons.
simonakey Feb 14, 2022
e37bfe9
Fix to correctly display skills when more than one pdf sheet of skills.
simonakey Feb 14, 2022
b0dc27f
Allow more than 9 techniques and sort them correctly.
simonakey Feb 14, 2022
96af987
Merge branch 'OpenNingia:master' into master
simonakey Feb 19, 2022
8d42e01
Revert Changes.
simonakey Feb 19, 2022
0cd7f00
Merge branch 'master' of https://github.com/simonakey/l5r-character-m…
simonakey Feb 19, 2022
e02e633
Merge branch 'master' of git://github.com/OpenNingia/l5r-character-ma…
simonakey Feb 19, 2022
55a4de0
Merge branch 'OpenNingia-master'
simonakey Feb 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions l5r/api/character/rankadv.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,19 @@ def advance_rank():
from l5r.models.advancements.rank import Rank
adv = Rank()
# the insight rank
adv.rank = api.character.insight_rank()
adv.rank = api.character.insight_rank(strict=True) + 1
# this is the current school for this rank
adv.school = api.character.schools.get_current()
# this is the current school_rank for this school
adv.school_rank = api.character.schools.get_school_rank(adv.school) + 1

# no cost advancing in the same rank
adv.cost = 0
# description
adv.desc = api.tr("Insight Rank {0}. School: {1} rank {2} ").format(
adv.rank,
api.data.schools.get(adv.school).name,
api.character.schools.get_school_rank(adv.school) + 1
adv.school_rank
)

# get 3 spells each rank other than the first
Expand Down Expand Up @@ -121,16 +124,19 @@ def leave_path():
from l5r.models.advancements.rank import Rank
adv = Rank()
# the insight rank
adv.rank = api.character.insight_rank()
adv.rank = api.character.insight_rank(strict=True) + 1
# this is the current school for this rank
adv.school = former_school_.school
# this is the current school rank for this school
adv.school_rank = api.character.schools.get_school_rank(adv.school) + 1

# no cost advancing in the same rank
adv.cost = 0
# description
adv.desc = api.tr("Insight Rank {0}. School: {1} rank {2} ").format(
adv.rank,
api.data.schools.get(adv.school).name,
api.character.schools.get_school_rank(adv.school) + 1
adv.school_rank
)

# get 3 spells each rank other than the first
Expand All @@ -155,14 +161,17 @@ def join_new(school_id):
from l5r.models.advancements.rank import Rank
adv = Rank()
# the insight rank
adv.rank = api.character.insight_rank()
adv.rank = api.character.insight_rank(strict=True)
if api.character.insight_rank(strict=True) != api.character.insight_rank():
adv.rank +=1

# this is the current school for this rank
adv.school = school_id
# this is the current school rank for this school
adv.school_rank = api.character.schools.get_school_rank(adv.school)

# no cost advancing in the same rank
adv.cost = 0
# description

school_rank = api.character.schools.get_school_rank(adv.school)

# get 3 spells each rank other than the first
if api.data.schools.is_shugenja(school_id) and adv.rank > 1:
Expand All @@ -172,7 +181,7 @@ def join_new(school_id):
# replaces current school
adv.replaced = api.character.schools.get_current()
else:
school_rank += 1
adv.school_rank += 1

# get 2 kiho each rank
# alternate path doesn't get the bonus
Expand All @@ -190,11 +199,12 @@ def join_new(school_id):
adv.deficiencies_to_choose.append(school_.deficiency)
else:
adv.deficiencies.append(school_.deficiency)


# description
adv.desc = api.tr("Insight Rank {0}. School: {1} rank {2} ").format(
adv.rank,
school_.name,
school_rank
adv.school_rank
)

return api.character.append_advancement(adv)
Expand Down
2 changes: 1 addition & 1 deletion l5r/api/character/schools.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_tech_by_rank(rank):
if not school_:
return None

return query(school_.techs).where(lambda x: x.rank == rank).select(a_('id')).first_or_default(None)
return query(school_.techs).where(lambda x: x.rank == (rank_[0].school_rank)).select(a_('id')).first_or_default(None)


def get_school_rank(sid):
Expand Down
4 changes: 3 additions & 1 deletion l5r/api/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def calculate_mod_attack_roll(pc, weap):
atk_r, atk_k = calculate_base_attack_roll(pc, weap)
r_mod = 0
k_mod = 0
flat_bonus = 0

# any roll bonuses
anyr = pc.get_modifiers('anyr')
Expand All @@ -245,8 +246,9 @@ def calculate_mod_attack_roll(pc, weap):
if x.active and x.dtl == weap.name:
r_mod += x.value[0]
k_mod += x.value[1]
flat_bonus += x.value[2]

return atk_r + r_mod, atk_k + k_mod
return atk_r + r_mod, atk_k + k_mod, flat_bonus


def calculate_base_damage_roll(pc, weap):
Expand Down
51 changes: 24 additions & 27 deletions l5r/exporters/fdfexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ def export_body(self, io):

fields = {}

# schools, bushi and samurai monk
# schools, bushi, samurai monk and ninja
schools = []
for s in api.character.schools.get_all():
if api.data.schools.is_bushi(s) or api.data.schools.is_samurai_monk(s):
if api.data.schools.is_bushi(s) or api.data.schools.is_samurai_monk(s) or api.data.schools.is_ninja(s):
schools.append(s)

count = min(2, len(schools))
Expand Down Expand Up @@ -514,14 +514,18 @@ def export_body(self, io):
break
ring = api.data.get_ring(kiho.element)
fields['KIHO_NM.%d' % (i + 1)] = kiho.name
fields['KIHO_MASTERY.%d' % (i + 1)] = str(kiho.mastery)
fields['KIHO_ELEM.%d' %
(i + 1)] = ring.text
fields['KIHO_TYPE.%d' % (i + 1)] = kiho.type
lines = self.split_in_parts(kiho.desc) or []
lc = min(6, len(lines))
for j in range(0, lc):
fields['KIHO_EFFECT.%d.%d' % (i + 1, j)] = lines[j]
if not kiho.type=="tattoo":
fields['KIHO_MASTERY.%d' % (i + 1)] = str(kiho.mastery)
fields['KIHO_ELEM.%d' % (i + 1)] = ring.text
else:
fields['KIHO_MASTERY.%d' % (i + 1)] = ""
fields['KIHO_ELEM.%d' % (i + 1)] = ""


# EXPORT FIELDS
for k in fields:
Expand Down Expand Up @@ -562,19 +566,19 @@ def split_in_parts(self, text, max_lines=6):

class FDFExporterWeapons(FDFExporter):

def __init__(self):
def __init__(self, offset=0):
super(FDFExporterWeapons, self).__init__()

self.weapons_offset = offset
self.weapons_per_page = 10

def export_body(self, io):
m = self.model
f = self.form
fields = {}
# WEAPONS

count = min(10, len(m.get_weapons()))
j = 0

for weap in m.get_weapons()[0:count]:
# WEAPONS
for j, weap in enumerate(m.get_weapons()[self.weapons_offset : self.weapons_offset + self.weapons_per_page + 1]):
weap.base_atk = api.rules.format_rtk_t(
api.rules.calculate_base_attack_roll(m, weap))
weap.max_atk = api.rules.format_rtk_t(
Expand All @@ -596,13 +600,11 @@ def export_body(self, io):
else:
fields['WEAPON.DMG.%d' % j] = weap.base_dmg
fields['WEAPON.NOTES.%d' % j] = weap.desc
j += 1


# EXPORT FIELDS
for k in fields:
self.export_field(k, fields[k], io)


class FDFExporterCourtier(FDFExporter):

def __init__(self):
Expand Down Expand Up @@ -655,22 +657,17 @@ def export_body(self, io):

# SKILLS
skills = f.sk_view_model.items
if self.skill_offset > 0:
skills = skills[self.skill_offset:]

sorted_skills = sorted(
skills, key=lambda x: (not x.is_school, -x.rank, x.name))
for i, sk in enumerate(sorted_skills):
j = i + 1
if i >= self.skills_per_page:
break

fields['SKILL_IS_SCHOOL.%d' % j] = sk.is_school
fields['SKILL_NAME.%d' % j] = sk.name
fields['SKILL_RANK.%d' % j] = sk.rank
fields['SKILL_TRAIT.%d' % j] = sk.trait
fields['SKILL_ROLL.%d' % j] = sk.mod_roll
fields['SKILL_EMPH_MA.%d' % j] = ', '.join(sk.emph)
for i, sk in enumerate(sorted_skills[self.skill_offset : self.skill_offset + self.skills_per_page + 1], start=1):

fields['SKILL_IS_SCHOOL.%d' % i] = sk.is_school
fields['SKILL_NAME.%d' % i] = sk.name
fields['SKILL_RANK.%d' % i] = sk.rank
fields['SKILL_TRAIT.%d' % i] = sk.trait
fields['SKILL_ROLL.%d' % i] = sk.mod_roll
fields['SKILL_EMPH_MA.%d' % i] = ', '.join(sk.emph)

# EXPORT FIELDS
for k in fields:
Expand Down
23 changes: 19 additions & 4 deletions l5r/l5rcmcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,27 @@ def export_as_pdf(self, export_file):
is_shugenja = api.character.is_shugenja()
is_bushi = api.character.is_bushi()
is_courtier = api.character.is_courtier()
is_ninja = api.character.is_ninja()
spell_offset = 0
spell_count = len(api.character.spells.get_all())
kihos = api.character.powers.get_all_kiho()
kiho_count = min(12, len(kihos))

# SHUGENJA/BUSHI/MONK SHEET
if is_shugenja:
self.write_pdf(
'sheet_shugenja.pdf', exporters.FDFExporterShugenja())
elif is_bushi or is_samurai_monk:
if kiho_count > 0:
self.write_pdf('sheet_monk.pdf', exporters.FDFExporterMonk())
elif is_bushi:
self.write_pdf('sheet_bushi.pdf', exporters.FDFExporterBushi())
elif is_samurai_monk or is_ninja:
self.write_pdf('sheet_bushi.pdf', exporters.FDFExporterBushi())
if kiho_count > 0:
self.write_pdf('sheet_monk.pdf', exporters.FDFExporterMonk())
elif is_monk:
self.write_pdf('sheet_monk.pdf', exporters.FDFExporterMonk())
if is_courtier:
elif is_courtier:
self.write_pdf(
'sheet_courtier.pdf', exporters.FDFExporterCourtier())

Expand Down Expand Up @@ -266,8 +275,14 @@ def export_as_pdf(self, export_file):
skill_count -= _exporter.skills_per_page

# WEAPONS
if len(self.pc.weapons) > 2:
self.write_pdf('sheet_weapons.pdf', exporters.FDFExporterWeapons())
weapons_count = len(self.pc.weapons)
weapons_offset = 0
if weapons_count > 2:
while weapons_count > 0:
_exporter = exporters.FDFExporterWeapons(weapons_offset)
self.write_pdf('sheet_weapons.pdf', _exporter)
weapons_offset += _exporter.weapons_per_page
weapons_count -= _exporter.weapons_per_page

self.commit_pdf_export(export_file)

Expand Down
13 changes: 4 additions & 9 deletions l5r/models/techviewmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,13 @@ def clean(self):
def update_from_model(self, model):
self.clean()

#for r in api.character.rankadv.get_all():
# tech_ = api.character.schools.get_tech_by_rank(r.rank)
# if tech_:
# self.add_item(tech_, r.rank)

for i in range(1, 10):
tech_ = api.character.schools.get_tech_by_rank(i)
for r in api.character.rankadv.get_all():
tech_ = api.character.schools.get_tech_by_rank(r.rank)
if tech_:
self.add_item(tech_, i)
self.add_item(tech_, r.rank)
OpenNingia marked this conversation as resolved.
Show resolved Hide resolved

# sort by rank
self.items.sort()
self.items.sort(key=lambda x: int(x.rank))

def adjust_tech_rank(self, model, tech_id):
paths = [x for x in model.schools if x.is_path and tech_id in x.techs]
Expand Down
Binary file modified l5r/share/l5rcm/sheet_weapons.pdf
Binary file not shown.