I'm making a Dungeons and Dragons style game in python, but I'm getting incorrect if returns
Question: I've worked out how to do most of this stuff in the past couple of days, but
that's all the experience i have, so this is probably simple. Anyway,
everything was going fine, until I tried to complicate a few formula's, or at
least change the values they used. Here is what I'm working with.

    
    
    class EnemyStats():
        def Ename(self):
            return #Not sure What i should put in these spots...
        def EBaseDodge(self):
            return 
        def EnemyEvasion(self):
            return 
        def ENickRange(self):
            return 
        def EBaseAttack(self):
            return 
        def EWeaponAttack(self):
            return 
        def EAttackRating(self):
            return 
        def EnemyDefense(self):
            return 
        def EAttackDamage(self):
            return 
        def Damage(self):
            return ((PAttackDamage-EnemyDefense)if (PAttackDamage-EnemyDefense>0) else 0);
        def EDamage(self):
            return ((EAttackDamage-PDefense) if ((EAttackDamage-PDefense)>0) else 0);
        def LightAttackDamage(self):
            return int(LightAttackDamage == (Damage * 0.72));
        def HeavyAttackDamage(self):
            return (Damage * 1.28);
        def LightNicked(self):
            return (LightAttackDamage/2);
        def HeavyNicked(self):
            return (HeavyAttackDamage/2);
        def Nicked(self):
            return (Damage/2)
    
        def Estats(self):
            Ename = raw_input('Target Enemy Name: ');
            EBaseDodge = int(raw_input('Enter Enemy Dodge: '));
            EnemyEvasion = int(raw_input('Enter Enemy Evasion: '));
            ENickRange = (EBaseDodge + EnemyEvasion);
            EBaseAttack = int(raw_input('Enter Enemy Base Attack: '));
            EWeaponAttack = int(raw_input('Enter Enemy Weapon Attack(If N/A, 0): '));
            EAttackRating = (EBaseAttack + EWeaponAttack);
            EnemyDefense = int(raw_input('Enter Enemy Defense: '));
            EAttackDamage = int(raw_input('Enter Enemy Attack Damage: '));
            Damage = ((PAttackDamage-EnemyDefense)if (PAttackDamage-EnemyDefense>0) else 0);
            EDamage = ((EAttackDamage-PDefense) if ((EAttackDamage-PDefense)>0) else 0);
            LightAttackDamage = (Damage * 0.72);
            HeavyAttackDamage = (Damage * 1.28);
            LightNicked = (LightAttackDamage/2);
            HeavyNicked = (HeavyAttackDamage/2);
            Nicked = (Damage/2)
    

And then it is referenced by this.

    
    
    def PLightAttackForm():#light attack
        print 'Light attack!';
        d = dice()
        lightbase = d.LightAttack()
        EE = EnemyStats()
        if lightbase <= EE.EBaseDodge:
            print 'You rolled', lightbase, ', Miss!', 0, 'Damage!'
        elif lightbase > EE.ENickRange:
            print 'You rolled', lightbase, ', Hit!', EE.LightAttackDamage, 'Damage!'
        elif lightbase < EE.ENickRange:
            print 'You rolled', lightbase, ', Nicked!', EE.LightNicked, 'Damage!'
        else:
            print lightbase
    

And Everything goes amazing, no errors, but i get this.

Light attack! You rolled 700 , Miss! 0 Damage! #Should be a Hit and damage

Normal Attack! You rolled 278 , Miss! 0 Damage! #should be hit and damage

Heavy Attack! You rolled 135 , Miss! 0 Damage!#should be a Nick and damage

I'm sure it's just something i don't really know, But if you could help me out
that would be amazing! Thank you!

Also, here is all the code i have written. Might have some redundancy... :D

    
    
    import random
    Name = raw_input("Enter Name: ")
    #EName===
    #EBaseDodge = int(raw_input("Enter Enemy Dodge: "))
    PBaseDodge = int(input('Enter Base Dodge: '))
    #EnemyEvasion = int(raw_input("Enter Enemy Evasion: "))
    PEvasion = int(input('Enter Evasion: '))
    #ENickRange = (EBaseDodge + EnemyEvasion)
    PNickRange = (PBaseDodge + PEvasion)
    PBaseAttack = int(raw_input("Enter Base Attack: "))
    #EBaseAttack===
    PWeaponAttack = int(raw_input("Enter Weapon Attack: "))
    #EWeaponAttack===
    PAttackRating = (PBaseAttack + PWeaponAttack)
    #EAttackRating = (EBaseAttack + EWeaponAttack)
    #EnemyDefense = int(raw_input("Enter Enemy Defense: "))
    PDefense = int(input('Enter Defense: '))
    PAttackDamage = int(raw_input("Enter Attack Damage: "))
    #EAttackDamage===
    #Damage = (PAttackDamage-EnemyDefense)
    #EDamage = (EAttackDamage-PDefense)
    #LightAttackDamage = (Damage * 0.72)
    #HeavyAttackDamage = (Damage * 1.28)
    #LightNicked = (LightAttackDamage/2)
    #HeavyNicked = (HeavyAttackDamage/2)
    #Nicked = Damage/2
    
    
    class dice():
            def NormalAttack(self):
                return random.randint(1, PAttackRating);
            def LightAttack(self):
                return random.randint(1, (int(PAttackRating*1.25)));
            def HeavyAttack(self):
                return random.randint(1, (int(PAttackRating*0.75)));
    
    
    #def att():
    #   d = dice()
    #   base = d.roll()
    #   if base <= a:
    #       print 'You rolled', base, ', Miss!', 0, 'Damage!'
    #   elif base > b:
    #       print 'You rolled', base, ', Hit!', Damage, 'Damage!'
    #   elif base < b:
    #       print 'You rolled', base, ', Nicked!', Nicked, 'Damage!'
    #   else:
    #       print base
    
    ####################NEW CODE#######################################
    def Menu():
        print '(1)Attack';
        print '(2)Choose Enemy';
        print '(3)Charge';
        print '(4)Item';
    
    
    def select():
        choice = input('Enter Choice: ');
        EE = EnemyStats()
        if (choice == 1):
            Attacktype();
        elif (choice == 2):
            EE.Estats();
        elif (choice == 3):
            Charge();
        elif (choice == 4):
            ItemSelection();
        else:
            print 'There are Numbers for a reason Nuub!',;
    
    ##############Enemy Stats############
    
    class EnemyStats():
        def Ename(self):
            return 
        def EBaseDodge(self):
            return 
        def EnemyEvasion(self):
            return 
        def ENickRange(self):
            return 
        def EBaseAttack(self):
            return 
        def EWeaponAttack(self):
            return 
        def EAttackRating(self):
            return 
        def EnemyDefense(self):
            return 
        def EAttackDamage(self):
            return 
        def Damage(self):
            return ((PAttackDamage-EnemyDefense)if (PAttackDamage-EnemyDefense>0) else 0);
        def EDamage(self):
            return ((EAttackDamage-PDefense) if ((EAttackDamage-PDefense)>0) else 0);
        def LightAttackDamage(self):
            return int(LightAttackDamage == (Damage * 0.72));
        def HeavyAttackDamage(self):
            return (Damage * 1.28);
        def LightNicked(self):
            return (LightAttackDamage/2);
        def HeavyNicked(self):
            return (HeavyAttackDamage/2);
        def Nicked(self):
            return (Damage/2)
    
        def Estats(self):
            Ename = raw_input('Target Enemy Name: ');
            EBaseDodge = int(raw_input('Enter Enemy Dodge: '));
            EnemyEvasion = int(raw_input('Enter Enemy Evasion: '));
            ENickRange = (EBaseDodge + EnemyEvasion);
            EBaseAttack = int(raw_input('Enter Enemy Base Attack: '));
            EWeaponAttack = int(raw_input('Enter Enemy Weapon Attack(If N/A, 0): '));
            EAttackRating = (EBaseAttack + EWeaponAttack);
            EnemyDefense = int(raw_input('Enter Enemy Defense: '));
            EAttackDamage = int(raw_input('Enter Enemy Attack Damage: '));
            Damage = ((PAttackDamage-EnemyDefense)if (PAttackDamage-EnemyDefense>0) else 0);
            EDamage = ((EAttackDamage-PDefense) if ((EAttackDamage-PDefense)>0) else 0);
            LightAttackDamage = (Damage * 0.72);
            HeavyAttackDamage = (Damage * 1.28);
            LightNicked = (LightAttackDamage/2);
            HeavyNicked = (HeavyAttackDamage/2);
            Nicked = (Damage/2)
    
    
    
    #Attacking
    def Attacktype():
        print '(1)LightAttack';
        print '(2)NormalAttack';
        print '(3)HeavyAttack';
        print '(4)Use Dem Magicks';
        print '(5)Menu(<<This is for nuublets)';
        Attchoice = input('Enter Choice: ')
        if (Attchoice == 1):
            PLightAttackForm();
        elif (Attchoice == 2):
            PNormalAttackForm();
        elif (Attchoice == 3):
            PHeavyAttackForm();
        elif (Attchoice == 4):
            MagicMenu();
        elif (Attchoice == 5):
            Menu();
        else:
            print 'You wot M8?';
            Menu();
    
    
    def PLightAttackForm():#light attack
        print 'Light attack!';
        d = dice()
        lightbase = d.LightAttack()
        EE = EnemyStats()
        if lightbase <= EE.EBaseDodge:
            print 'You rolled', lightbase, ', Miss!', 0, 'Damage!'
        elif lightbase > EE.ENickRange:
            print 'You rolled', lightbase, ', Hit!', EE.LightAttackDamage, 'Damage!'
        elif lightbase < EE.ENickRange:
            print 'You rolled', lightbase, ', Nicked!', EE.LightNicked, 'Damage!'
        else:
            print lightbase
    
    def PNormalAttackForm():#Normal attack
        print 'Normal Attack!';
        d = dice()
        base = d.NormalAttack()
        EE = EnemyStats()
        if base <= EE.EBaseDodge:
            print 'You rolled', base, ', Miss!', 0, 'Damage!'
        elif base > EE.ENickRange:
            print 'You rolled', base, ', Hit!', EE.Damage, 'Damage!'
        elif base < EE.ENickRange:
            print 'You rolled', base, ', Nicked!', EE.Nicked, 'Damage!'
        else:
            print base
    
    def PHeavyAttackForm():#Heavy Attack
        print 'Heavy Attack!';
        d = dice()
        heavybase = d.HeavyAttack()
        EE = EnemyStats()
        if heavybase <= EE.EBaseDodge:
            print 'You rolled', heavybase, ', Miss!', 0, 'Damage!'
        elif heavybase > EE.ENickRange:
            print 'You rolled', heavybase, ', Hit!', EE.HeavyAttackDamage, 'Damage!'
        elif heavybase < EE.ENickRange:
            print 'You rolled', heavybase, ', Nicked!', EE.HeavyNicked, 'Damage!'
        else:
            print heavybase
    
    def MagicMenu():#magic menu()   
        print 'Magic menu!';
    
    
    ##############Enemy Stats############
    
    
    
    ####################NEW CODE#######################################
    


Answer: As That1Guy said, you're not passing parameters to your functions. In python,
functions are objects as well, and you can compare them to other objects. So
when you do:

    
    
    if lightbase <= EE.EBaseDodge:
        print 'You rolled', lightbase, ', Miss!', 0, 'Damage!'
    elif lightbase > EE.ENickRange:
        print 'You rolled', lightbase, ', Hit!', EE.LightAttackDamage, 'Damage!'
    elif lightbase < EE.ENickRange:
        print 'You rolled', lightbase, ', Nicked!', EE.LightNicked, 'Damage!'
    else:
        print lightbase
    

`lightbase <= EE.EBaseDodge` always evaluates to true.

You need to add parenthesis to the calls to`EBase...` methods. Also you need
to add return values to the declaration of the methods. so make your functions
look something like (assuming you have a variable called base_dodge):

    
    
     def EBaseDodge(self):
        return base_dodge
    

and change your ifs to:

    
    
     if lightbase <= EE.EBaseDodge():
        ...
    

I'm not sure why you are trying to use methods for all of those values in the
first place. It would make more sense if the methods were attributes.

Try removing all of the methods in `Enemystats` and making your variables
instance variables:

    
    
    class EnemyStats:
        def Estats(self):
            #Keep this method to set all of the stats and add self. before them like this
            self.Ename = raw_input('Target Enemy Name: ');
            self.EBaseDodge = int(raw_input('Enter Enemy Dodge: '));
            self.EnemyEvasion = int(raw_input('Enter Enemy Evasion: '));
            self.ENickRange = (self.EBaseDodge + self.EnemyEvasion);
            ....
    

Putting `self.` before all of your variables associates them to an instance of
your class (`EnemyStats`).

Then to create a new EnemyStats object and input the values:

    
    
    EE = EnemyStats()
    EE.Estats() # will prompt you for the values
    

After that you can reference your values like you had wanted to before:

    
    
    if lightbase <= EE.EBaseDodge:
       ...
    

Just so you know, this is not the most organized/recommended way of doing
things.

