Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function method problems
#3
at least you can refactor the __init__ as

    def __init__(self, classIndex):
        player_classes = {1:archerClass, 2:kingClass, 3:mageClass}
        player_class = playerClasses.get(classIndex)
        self.HitPoints = player_class.hP  
        self.Dmg = player_class.Dmg
        self.BlockChance = player_class.bChance
        self.BlockAmount =player_class.DmgbPercent
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
function method problems - by drchar - Dec-11-2018, 10:51 AM
RE: function method problems - by ichabod801 - Dec-11-2018, 02:30 PM
RE: function method problems - by buran - Dec-11-2018, 02:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  i want to use type= as a function/method keyword argument Skaperen 9 1,956 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  Building a method name in a function ffgth 9 3,302 Oct-19-2020, 01:21 PM
Last Post: buran
  function/method help myv5285 3 2,855 May-17-2020, 04:19 AM
Last Post: buran
  Money conversion - problems with lists and .format function fatherted99 1 1,843 Mar-12-2020, 06:29 PM
Last Post: ndc85430
  Accessing method as function object ClassicalSoul 2 2,047 Feb-14-2020, 09:31 PM
Last Post: wavic
  function vs method prateekshaw 2 2,222 Nov-14-2019, 07:00 PM
Last Post: DeaD_EyE
  Problems with a def function profeteus 4 2,402 Oct-20-2019, 06:50 PM
Last Post: ichabod801
  I'm trying to figure out whether this is a method or function call 357mag 2 2,468 Jul-04-2019, 01:43 AM
Last Post: ichabod801
  problems when running a signrawtransaction method wectri 1 2,274 Dec-04-2018, 04:53 PM
Last Post: Larz60+
  Understanding Method/Function robdhunter 2 2,669 Mar-10-2018, 11:57 PM
Last Post: robdhunter

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020