08-12-2013, 12:43 AM
Pages: 1 2
08-12-2013, 02:05 PM
Τελικά το έφτιαξα πολύ εύκολα με μακροεντολή. Πατώντας το κουμπί "Calculate Overall Harm" σου υπολογίζει και για τα 6 Pokemon το Overall Harm.
Για το Biased Overall Harm πως προτείνετε να το κάνω; να επιλέγεις το checkbox από πάνω για να υπολογίζεις την ανάλογη στήλη; Ή να βάλω άλλα 2 κουμπιά, 1 για κάθε στήλη;
Λίγο μεγαλούτσικος ο κώδικας γιατί υπολογίζει x6 το Overall Harm. Προγραμματιστικά δεν το λες και πολύ σωστό αλλά δεν μπορώ να σκεφτώ κάτι άλλο προς το παρών.
Για το Biased Overall Harm πως προτείνετε να το κάνω; να επιλέγεις το checkbox από πάνω για να υπολογίζεις την ανάλογη στήλη; Ή να βάλω άλλα 2 κουμπιά, 1 για κάθε στήλη;
Λίγο μεγαλούτσικος ο κώδικας γιατί υπολογίζει x6 το Overall Harm. Προγραμματιστικά δεν το λες και πολύ σωστό αλλά δεν μπορώ να σκεφτώ κάτι άλλο προς το παρών.
Code:
Sub OverallHarm()
Dim HP As Double
Dim Def As Double
Dim SpDef As Double
Dim HP_EV As Long
Dim Def_EV As Long
Dim SpDef_EV As Long
Dim HP_IV As Long
Dim Def_IV As Long
Dim SpDef_IV As Long
Dim HP_Base As Long
Dim Def_Base As Long
Dim SpDef_Base As Long
Dim Level As Long
Dim Nature As String
Dim HP_EV_min As Long
Dim Def_EV_min As Long
Dim SpDef_EV_min As Long
Dim OverallHarm_min As Double
Dim OverallHarm_test As Double
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Calculators")
'''''''''''' Pokemon 1 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN5")
Nature = sheet.Range("AO5")
HP_Base = sheet.Range("AP5")
Def_Base = sheet.Range("AQ5")
SpDef_Base = sheet.Range("AR5")
HP_IV = sheet.Range("AV5")
Def_IV = sheet.Range("AW5")
SpDef_IV = sheet.Range("AX5")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY5") = HP_EV_min
sheet.Range("AZ5") = Def_EV_min
sheet.Range("BA5") = SpDef_EV_min
sheet.Range("BC5") = OverallHarm_min
'''''''''''' Pokemon 2 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN6")
Nature = sheet.Range("AO6")
HP_Base = sheet.Range("AP6")
Def_Base = sheet.Range("AQ6")
SpDef_Base = sheet.Range("AR6")
HP_IV = sheet.Range("AV6")
Def_IV = sheet.Range("AW6")
SpDef_IV = sheet.Range("AX6")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY6") = HP_EV_min
sheet.Range("AZ6") = Def_EV_min
sheet.Range("BA6") = SpDef_EV_min
sheet.Range("BC6") = OverallHarm_min
'''''''''''' Pokemon 3 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN7")
Nature = sheet.Range("AO7")
HP_Base = sheet.Range("AP7")
Def_Base = sheet.Range("AQ7")
SpDef_Base = sheet.Range("AR7")
HP_IV = sheet.Range("AV7")
Def_IV = sheet.Range("AW7")
SpDef_IV = sheet.Range("AX7")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY7") = HP_EV_min
sheet.Range("AZ7") = Def_EV_min
sheet.Range("BA7") = SpDef_EV_min
sheet.Range("BC7") = OverallHarm_min
'''''''''''' Pokemon 4 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN8")
Nature = sheet.Range("AO8")
HP_Base = sheet.Range("AP8")
Def_Base = sheet.Range("AQ8")
SpDef_Base = sheet.Range("AR8")
HP_IV = sheet.Range("AV8")
Def_IV = sheet.Range("AW8")
SpDef_IV = sheet.Range("AX8")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY8") = HP_EV_min
sheet.Range("AZ8") = Def_EV_min
sheet.Range("BA8") = SpDef_EV_min
sheet.Range("BC8") = OverallHarm_min
'''''''''''' Pokemon 5 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN9")
Nature = sheet.Range("AO9")
HP_Base = sheet.Range("AP9")
Def_Base = sheet.Range("AQ9")
SpDef_Base = sheet.Range("AR9")
HP_IV = sheet.Range("AV9")
Def_IV = sheet.Range("AW9")
SpDef_IV = sheet.Range("AX9")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY9") = HP_EV_min
sheet.Range("AZ9") = Def_EV_min
sheet.Range("BA9") = SpDef_EV_min
sheet.Range("BC9") = OverallHarm_min
'''''''''''' Pokemon 6 ''''''''''''
OverallHarm_min = 300
OverallHarm_test = 0
HP_EV = 0
Def_EV = 0
SpDef_EV = 0
HP_EV_min = 0
Def_EV_min = 0
SpDef_EV_min = 0
Level = sheet.Range("AN10")
Nature = sheet.Range("AO10")
HP_Base = sheet.Range("AP10")
Def_Base = sheet.Range("AQ10")
SpDef_Base = sheet.Range("AR10")
HP_IV = sheet.Range("AV10")
Def_IV = sheet.Range("AW10")
SpDef_IV = sheet.Range("AX10")
For HP_EV = 0 To 252 Step 4
For Def_EV = 0 To 252 Step 4
For SpDef_EV = 0 To 252 Step 4
HP = (((HP_IV + (2 * HP_Base) + (HP_EV / 4) + 100) * Level) / 100) + 10
Def = ((((Def_IV + (2 * Def_Base) + (Def_EV / 4)) * Level) / 100) + 5) * NatureDef(Nature)
SpDef = ((((SpDef_IV + (2 * SpDef_Base) + (SpDef_EV / 4)) * Level) / 100) + 5) * NatureSpDef(Nature)
OverallHarm_test = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
If OverallHarm_test < OverallHarm_min And (HP_EV + Def_EV + SpDef_EV) <= 510 Then
OverallHarm_min = ((20000 * (Def + SpDef) + 4 * Def * SpDef) / (HP * Def * SpDef))
HP_EV_min = HP_EV
Def_EV_min = Def_EV
SpDef_EV_min = SpDef_EV
End If
Next SpDef_EV
Next Def_EV
Next HP_EV
sheet.Range("AY10") = HP_EV_min
sheet.Range("AZ10") = Def_EV_min
sheet.Range("BA10") = SpDef_EV_min
sheet.Range("BC10") = OverallHarm_min
End Sub
Pages: 1 2