D&D

drago18121996 -

import java.util.Random

class DndCharacter {
public int strength;
public int dexterity;
public int constitution;
public int intelligence;
public int wisdom;
public int charisma;
public int hitpoints;

 public DndCharacter(){
     strength = ability()
     dexterity = ability()
     constitution = ability()
     intelligence = ability()
     wisdom = ability()
     charisma = ability()
     hitpoints = 10 + modifier(constitution)
 }

static int ability(){
    List<Integer> listN = Rolldice()
    def count = listN.sum()
    return count-listN.min()
}

static List<Integer> Rolldice(){
    List<Integer> integerList = []
    def random = new Random()
    for(int i=0; i<4; i++){
        int num = random.nextInt(6)+1;
        integerList << num
    }
    return integerList
}

public static int modifier(constitution){
     (int) Math.floor((constitution - 10)/2.0)
} 

}