ここ数日でほとんどのことを行う方法を考え出しましたが、それが私の経験のすべてなので、これはおそらく簡単です。とにかく、いくつかの数式を複雑にするか、少なくともそれらが使用する値を変更しようとするまで、すべてがうまくいっていました。これが私が取り組んでいるものです。
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)
そして、これによって参照されます。
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
そして、すべてが驚くほどうまくいき、エラーはありませんが、私はこれを理解しています.
光攻撃!あなたは 700 を出しました、ミス!ダメージ0!#ヒットとダメージのはず
通常攻撃!あなたは 278 を出しました、ミス!ダメージ0!#当たってダメージを与えるべし
ヘビーアタック!あなたは 135 を出しました、ミス!0ダメージ!#ニックとダメージのはず
それは私が本当に知らないことだと確信していますが、もしあなたが私を助けることができれば、それは素晴らしいことです! ありがとうございました!
また、ここに私が書いたすべてのコードがあります。冗長性があるかもしれません... :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#######################################