diff --git a/app/src/main/java/com/example/proj2/Classes/Ability.java b/app/src/main/java/com/example/proj2/Classes/Ability.java index 1ab7c4e..0b7c379 100644 --- a/app/src/main/java/com/example/proj2/Classes/Ability.java +++ b/app/src/main/java/com/example/proj2/Classes/Ability.java @@ -1,39 +1,207 @@ package com.example.proj2.Classes; -public class Ability { - //Eability - // - //Qability - // - //Rability - // - //Wability - //Fields: - //Name - //damage:number - //ratioAP - //ratioAD - //isDamage - //isSummon - //instances - //duration +import java.util.ArrayList; +public class Ability { String name; - String spellnames; - double cost; + int damageType; + + int rank = 5; + ArrayList damage; + //Bools boolean isDamage; - double damage; - enum damageType{trueDamage,physicalDamage, magicalDamage}; + boolean isSummon; + boolean isStack; + boolean isCritiable; + boolean isMaxHP; + boolean isMaxHPDOT; boolean isDOT; - double dotDuration; - boolean multipleStage; - int stages; + double duration; + double perSecond; + ArrayList dotDamage; + ArrayList dotRatio; + ArrayList summonAA; + ArrayList summonRatioAD; + ArrayList summonRatioAP; + + int instances; //ratio - double[] ratioAD; - double[] ratioAP; - double[] coefficentArmor; - double[] coefficentMR; - double[] coefficentHP; - double[] coefficentStacks; + ArrayList ratioBAD; + ArrayList ratioAD; + ArrayList ratioAP; + + public ArrayList getDamage() { + return damage; + } + + public void setDamage(ArrayList damage) { + this.damage = damage; + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getDamageType() { + return damageType; + } + + public void setDamageType(int damageType) { + this.damageType = damageType; + } + + + public boolean isDamage() { + return isDamage; + } + + public void setDamage(boolean damage) { + isDamage = damage; + } + + public boolean isSummon() { + return isSummon; + } + + public void setSummon(boolean summon) { + isSummon = summon; + } + + public boolean isStack() { + return isStack; + } + + public void setStack(boolean stack) { + isStack = stack; + } + + public boolean isCritiable() { + return isCritiable; + } + + public void setCritiable(boolean critiable) { + isCritiable = critiable; + } + + public boolean isMaxHP() { + return isMaxHP; + } + + public void setMaxHP(boolean maxHP) { + isMaxHP = maxHP; + } + + public boolean isMaxHPDOT() { + return isMaxHPDOT; + } + + public void setMaxHPDOT(boolean maxHPDOT) { + isMaxHPDOT = maxHPDOT; + } + + public boolean isDOT() { + return isDOT; + } + + public void setDOT(boolean DOT) { + isDOT = DOT; + } + + public double getDuration() { + return duration; + } + + public void setDuration(double duration) { + this.duration = duration; + } + + public double getPerSecond() { + return perSecond; + } + + public void setPerSecond(double perSecond) { + this.perSecond = perSecond; + } + + public ArrayList getDotDamage() { + return dotDamage; + } + + public void setDotDamage(ArrayList dotDamage) { + this.dotDamage = dotDamage; + } + + public ArrayList getDotRatio() { + return dotRatio; + } + + public void setDotRatio(ArrayList dotRatio) { + this.dotRatio = dotRatio; + } + + public ArrayList getSummonAA() { + return summonAA; + } + + public void setSummonAA(ArrayList summonAA) { + this.summonAA = summonAA; + } + + public ArrayList getSummonRatioAD() { + return summonRatioAD; + } + + public void setSummonRatioAD(ArrayList summonRatioAD) { + this.summonRatioAD = summonRatioAD; + } + + public ArrayList getSummonRatioAP() { + return summonRatioAP; + } + + public void setSummonRatioAP(ArrayList summonRatioAP) { + this.summonRatioAP = summonRatioAP; + } + + public int getInstances() { + return instances; + } + + public void setInstances(int instances) { + this.instances = instances; + } + + public ArrayList getRatioBAD() { + return ratioBAD; + } + + public void setRatioBAD(ArrayList ratioBAD) { + this.ratioBAD = ratioBAD; + } + + public ArrayList getRatioAD() { + return ratioAD; + } + + public void setRatioAD(ArrayList ratioAD) { + this.ratioAD = ratioAD; + } + + public ArrayList getRatioAP() { + return ratioAP; + } + + public void setRatioAP(ArrayList ratioAP) { + this.ratioAP = ratioAP; + } + + public void setRankToThree(){ + rank = 3; + } } diff --git a/app/src/main/java/com/example/proj2/Classes/Champion.java b/app/src/main/java/com/example/proj2/Classes/Champion.java index 19be43b..0cba6cc 100644 --- a/app/src/main/java/com/example/proj2/Classes/Champion.java +++ b/app/src/main/java/com/example/proj2/Classes/Champion.java @@ -1,7 +1,17 @@ package com.example.proj2.Classes; +import java.util.ArrayList; + public class Champion { - //Ability[] abilities; + public ArrayList getAbilities() { + return abilities; + } + + public void setAbilities(ArrayList abilities) { + this.abilities = abilities; + } + + ArrayList abilities; int id; public String name; //Stats diff --git a/app/src/main/java/com/example/proj2/Classes/ChampionViewModel.java b/app/src/main/java/com/example/proj2/Classes/ChampionViewModel.java index 14888b7..9feff84 100644 --- a/app/src/main/java/com/example/proj2/Classes/ChampionViewModel.java +++ b/app/src/main/java/com/example/proj2/Classes/ChampionViewModel.java @@ -10,9 +10,17 @@ import com.android.volley.toolbox.Volley; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.firestore.DocumentReference; +import com.google.firebase.firestore.DocumentSnapshot; +import com.google.firebase.firestore.FirebaseFirestore; + import android.content.Context; +import android.util.Log; import java.io.File; +import java.util.ArrayList; public class ChampionViewModel extends ViewModel { private MutableLiveData championData = new MutableLiveData<>(); @@ -21,7 +29,40 @@ public class ChampionViewModel extends ViewModel { public LiveData getChampion() { return championData; } + public void fetchChampionAbility(String championName,Champion champ){ + FirebaseFirestore db = FirebaseFirestore.getInstance(); + + DocumentReference docRef = db.collection("championAbility") + .document(championName).collection("Eability").document("data"); + docRef.get().addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete( Task task) { + if (task.isSuccessful()) { + DocumentSnapshot document = task.getResult(); + if (document.exists()) { + Log.d("Print", "DocumentSnapshot data: " + document.getData()); + try{ + Ability qAbili = document.toObject(Ability.class); + ArrayList abilities = new ArrayList(); + abilities.add(qAbili); + champ.setAbilities(abilities); + Log.d("Q abi",qAbili.getName()); + }catch(Exception e){ + Log.d("Failed","went wrong"); + } + + } else { + Log.d("Print", "No such document"); + } + } else { + Log.d("Print", "get failed with ", task.getException()); + } + } + }); + + + } public void fetchChampionData(Context context, String championName) { if (queue == null) { queue = Volley.newRequestQueue(context); @@ -51,6 +92,7 @@ public void fetchChampionData(Context context, String championName) { rootNode.path(pathName).path("attackSpeedRatio").asDouble(), rootNode.path(pathName).path("attackSpeedPerLevel").asDouble() ); + fetchChampionAbility(urlInsert,champ); championData.postValue(champ); } catch (Exception e) { e.printStackTrace();