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