Skip to content

Commit

Permalink
Merge pull request #78 from Yutsuten/damage-fixes
Browse files Browse the repository at this point in the history
Fix some cases where damage value would be wrong
  • Loading branch information
Yutsuten authored Jun 3, 2020
2 parents df1b420 + c90f2af commit 8536a3b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lifedrain/deck_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def update(self):

def get_current_life(self):
"""Get the current deck's current life."""
deck_id = self._cur_deck_id
if deck_id not in self._bar_info:
self._add_deck(deck_id)
return self._bar_info[deck_id]['currentValue']
conf = self._deck_conf.get()
self._cur_deck_id = conf['id']
if conf['id'] not in self._bar_info:
self._add_deck(conf['id'])
return self._bar_info[conf['id']]['currentValue']

def set_deck_conf(self, conf):
"""Updates a deck's current settings and state.
Expand Down
21 changes: 18 additions & 3 deletions lifedrain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,18 @@ def _generate_form(self, form, layout):

@staticmethod
def _load_form_data(form, conf, life):
def update_damageinput_state():
damage_enabled = form.enableDamageInput.isChecked()
form.damageInput.setEnabled(damage_enabled)
form.damageInput.setValue(5)

form.maxLifeInput.setValue(conf['maxLife'])
form.recoverInput.setValue(conf['recover'])
damage = conf['damage']
form.enableDamageInput.setChecked(damage is not None)
form.damageInput.setValue(damage if damage else 5)
form.enableDamageInput.stateChanged.connect(update_damageinput_state)
form.damageInput.setValue(damage if damage is not None else 5)
form.damageInput.setEnabled(conf['damage'] is not None)
form.currentValueInput.setValue(life)

@staticmethod
Expand Down Expand Up @@ -346,13 +353,21 @@ def old_load_form_data(self, settings, current_life):
settings: The instance of the Deck Settings dialog.
current_life: The current amount of life.
"""
def update_damageinput_state():
damage_enabled = form.enableDamageInput.isChecked()
form.damageInput.setEnabled(damage_enabled)
form.damageInput.setValue(5)

conf = self._deck_conf.get()
form = settings.form

form.maxLifeInput.setValue(conf['maxLife'])
form.recoverInput.setValue(conf['recover'])
form.enableDamageInput.setChecked(conf['damage'] is not None)
form.damageInput.setValue(conf['damage'] or 5)
damage = conf['damage']
form.enableDamageInput.setChecked(damage is not None)
form.enableDamageInput.stateChanged.connect(update_damageinput_state)
form.damageInput.setValue(damage if damage is not None else 5)
form.damageInput.setEnabled(conf['damage'] is not None)
form.currentValueInput.setValue(current_life)

def old_save_form_data(self, settings, set_deck_conf):
Expand Down

0 comments on commit 8536a3b

Please sign in to comment.