Commit 67cb69fc authored by Mathieu Féry (Mathius)'s avatar Mathieu Féry (Mathius)
Browse files

Merge branch 'api' into jonctApiFront

parents 69e3dffd 7c404a40
Pipeline #23293 failed with stages
in 2 minutes and 33 seconds
......@@ -15,8 +15,8 @@ public class DnDAttr implements Serializable {
/**
* Basic Constructor for create attribute if beautiful value is missing.
* @param nameAttr
* @param value
* @param nameAttr : String represent Name of attribute
* @param value : Integer represent Value of attribute
*/
public DnDAttr(@NonNull String nameAttr, @NonNull Integer value) {
this(nameAttr, value, String.valueOf(value));
......@@ -24,9 +24,9 @@ public class DnDAttr implements Serializable {
/**
* Basic Constructor for create attribute if all arguments are provided.
* @param nameAttr
* @param value
* @param valueUserReadable
* @param nameAttr : String represent Name of attribute
* @param value : Integer represent Value of attribute
* @param valueUserReadable : String represent Value with modifier, ex : "14 (+2)"
*/
public DnDAttr(@NonNull String nameAttr, @NonNull Integer value,
@NonNull String valueUserReadable) {
......@@ -40,6 +40,7 @@ public class DnDAttr implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
return String.format("%s : %s", nameAttr, valueUserReadable);
}
......@@ -55,7 +56,7 @@ public class DnDAttr implements Serializable {
/**
* For compare Any Object with this attribute.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......
......@@ -15,7 +15,7 @@ public class DnDAttrs implements Serializable {
/**
* Basic Constructor for create attributes if all arguments are provided.
* @param attrs
* @param attrs : List of DnDAttr represents all attributes of DnDSheet
*/
public DnDAttrs(@NonNull List<DnDAttr> attrs) {
this.attrs = attrs;
......@@ -26,6 +26,7 @@ public class DnDAttrs implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
String out = "";
for (DnDAttr attr : attrs)
......@@ -35,9 +36,10 @@ public class DnDAttrs implements Serializable {
/**
* For get specific attribute if is present.
* @param nameAttr
* @param nameAttr : String to represent Attribute to search
* @return attr
*/
@Nullable
public DnDAttr get(@NonNull String nameAttr) {
for (DnDAttr attr : attrs)
if (attr.nameAttr.toLowerCase().equals(nameAttr.toLowerCase()))
......@@ -56,7 +58,7 @@ public class DnDAttrs implements Serializable {
/**
* For compare Any Object with this attributes.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......
......@@ -8,30 +8,57 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* DnDClass is a class representing the character’s class with possibly the search parameter to
* retrieve cards of that class only
*/
public class DnDClass implements Serializable, Comparable<DnDClass> {
public String queryArg;
public String name;
/**
* Basic Constructor for create class if queryArg is missing
* @param name : String represent Name of this class
*/
public DnDClass(@NonNull String name) {
this(name, null);
}
/**
* Basic Constructor for create attribute if all arguments are provided.
* @param name : String represent Name of this class
* @param queryArg : String represent the argument to pass to find a record with this class.
*/
public DnDClass(@NonNull String name, @Nullable String queryArg) {
this.name = name;
this.queryArg = queryArg;
}
/**
* For write class.
* @return toString
*/
@Override
@NonNull
public String toString() {
return this.name;
}
/**
* For identify attributes.
* @return hashCode
*/
@Override
public int hashCode() {
return this.name.hashCode();
}
/**
* For compare Any Object with this class.
* @param obj : Object for comparison
* @return equals
*/
@Override
public boolean equals(@Nullable Object obj) {
if (obj != null && obj.getClass() == this.getClass())
......@@ -65,19 +92,26 @@ public class DnDClass implements Serializable, Comparable<DnDClass> {
* For get random class from the API.
* @return class
*/
@NonNull
public static DnDClass getRandomClass() {
return getRandomClass(classes);
}
/**
* For get random class from list provided.
* @param dnDclass
* @param dnDclass : List where we’re going to shoot randomly
* @return class
*/
@NonNull
public static DnDClass getRandomClass(@NonNull List<DnDClass> dnDclass) {
return dnDclass.get(new Random().nextInt(dnDclass.size()));
}
/**
* For compare 2 class
* @param o : Object for comparison
* @return compareToResult
*/
@Override
public int compareTo(DnDClass o) {
return this.name.compareTo(o.name);
......
package fr.iutnantes.miar.dndgenerator.api.dnd;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.Serializable;
......@@ -15,11 +16,11 @@ public class DnDSaves implements Serializable {
/**
* Basic Constructor for create saves if all arguments are provided.
* @param wands
* @param breath
* @param stone
* @param magic
* @param poison
* @param wands : Integer represent resistance to wands
* @param breath : Integer represent resistance to breath
* @param stone : Integer represent resistance to stone
* @param magic : Integer represent resistance to magic
* @param poison : Integer represent resistance to poison
*/
public DnDSaves(@Nullable Integer wands, @Nullable Integer breath, @Nullable Integer stone,
@Nullable Integer magic, @Nullable Integer poison) {
......@@ -35,6 +36,7 @@ public class DnDSaves implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
String out = "";
String[] labels = new String[]{"wands", "breath", "stone", "magic", "poison"};
......@@ -61,7 +63,7 @@ public class DnDSaves implements Serializable {
/**
* For compare Any Object with this saves.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......
......@@ -16,8 +16,8 @@ public class DnDSkill implements Serializable {
/**
* Basic Constructor for create skill if all arguments are provided.
* @param skillName
* @param value
* @param skillName : String to represent name of this skill
* @param value : Integer to represent value of this skill
*/
public DnDSkill(@NonNull String skillName, @NonNull Integer value) {
this.skillName = skillName;
......@@ -28,6 +28,7 @@ public class DnDSkill implements Serializable {
* For write skill.
* @return toString
*/
@NonNull
@Override
public String toString() {
return String.format("%s : %s", skillName, value);
......@@ -44,7 +45,7 @@ public class DnDSkill implements Serializable {
/**
* For compare Any Object with this skill.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......
......@@ -18,7 +18,7 @@ public class DnDSkills implements Serializable {
/**
* Basic Constructor for create skills if all arguments are provided.
* @param skills
* @param skills : List of DnDSkill represents all attributes of DnDSheet
*/
public DnDSkills(@NonNull List<DnDSkill> skills) {
this.skills = skills;
......@@ -28,6 +28,7 @@ public class DnDSkills implements Serializable {
* For write skills.
* @return toString
*/
@NonNull
@Override
public String toString() {
String out = "";
......@@ -47,7 +48,7 @@ public class DnDSkills implements Serializable {
/**
* For compare Any Object with this skills.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......
......@@ -18,7 +18,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
/**
* Basic Constructor for create system if longName is missing.
* @param name
* @param name : String represent acronym of this system
*/
public DnDSystem(@NonNull String name) {
this(name, name);
......@@ -26,8 +26,8 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
/**
* Basic Constructor for create system if all arguments are provided.
* @param name
* @param longName
* @param name : String represent acronym of this system
* @param longName : String represent full name of this system
*/
public DnDSystem(@NonNull String name, @NonNull String longName) {
this.name = name;
......@@ -38,6 +38,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
* For write system.
* @return toString
*/
@NonNull
@Override
public String toString(){
return String.format("System of %s", longName);
......@@ -82,7 +83,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
/**
* For get random system from list provided.
* @param systems
* @param systems : List where we’re going to shoot randomly
* @return system
*/
public static DnDSystem getRandomSystem(@NonNull List<DnDSystem> systems) {
......@@ -91,7 +92,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
/**
* For get random system exclude param if present
* @param system
* @param system : System that we want to exclude from our circulation
* @return system
*/
public static DnDSystem getRandomSystemExcludingSystem(@NonNull DnDSystem system) {
......@@ -114,7 +115,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
/**
* For compare Any Object with this system.
* @param obj
* @param obj : Object for comparison
* @return equals
*/
@Override
......@@ -125,6 +126,11 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
return false;
}
/**
* For compare 2 system
* @param o : Object for comparison
* @return compareToResult
*/
@Override
public int compareTo(DnDSystem o) {
return this.longName.compareTo(o.longName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment