Skip to content

Commit

Permalink
Ability class added
Browse files Browse the repository at this point in the history
Working on ability loading from firestore
  • Loading branch information
John Taoi committed Apr 24, 2024
1 parent 4ed3101 commit a758ccc
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 31 deletions.
228 changes: 198 additions & 30 deletions app/src/main/java/com/example/proj2/Classes/Ability.java
Original file line number Diff line number Diff line change
@@ -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<Double> 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<Double> dotDamage;
ArrayList<Double> dotRatio;
ArrayList<Double> summonAA;
ArrayList<Double> summonRatioAD;
ArrayList<Double> summonRatioAP;

int instances;

//ratio
double[] ratioAD;
double[] ratioAP;
double[] coefficentArmor;
double[] coefficentMR;
double[] coefficentHP;
double[] coefficentStacks;
ArrayList<Double> ratioBAD;
ArrayList<Double> ratioAD;
ArrayList<Double> ratioAP;

public ArrayList<Double> getDamage() {
return damage;
}

public void setDamage(ArrayList<Double> 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<Double> getDotDamage() {
return dotDamage;
}

public void setDotDamage(ArrayList<Double> dotDamage) {
this.dotDamage = dotDamage;
}

public ArrayList<Double> getDotRatio() {
return dotRatio;
}

public void setDotRatio(ArrayList<Double> dotRatio) {
this.dotRatio = dotRatio;
}

public ArrayList<Double> getSummonAA() {
return summonAA;
}

public void setSummonAA(ArrayList<Double> summonAA) {
this.summonAA = summonAA;
}

public ArrayList<Double> getSummonRatioAD() {
return summonRatioAD;
}

public void setSummonRatioAD(ArrayList<Double> summonRatioAD) {
this.summonRatioAD = summonRatioAD;
}

public ArrayList<Double> getSummonRatioAP() {
return summonRatioAP;
}

public void setSummonRatioAP(ArrayList<Double> summonRatioAP) {
this.summonRatioAP = summonRatioAP;
}

public int getInstances() {
return instances;
}

public void setInstances(int instances) {
this.instances = instances;
}

public ArrayList<Double> getRatioBAD() {
return ratioBAD;
}

public void setRatioBAD(ArrayList<Double> ratioBAD) {
this.ratioBAD = ratioBAD;
}

public ArrayList<Double> getRatioAD() {
return ratioAD;
}

public void setRatioAD(ArrayList<Double> ratioAD) {
this.ratioAD = ratioAD;
}

public ArrayList<Double> getRatioAP() {
return ratioAP;
}

public void setRatioAP(ArrayList<Double> ratioAP) {
this.ratioAP = ratioAP;
}

public void setRankToThree(){
rank = 3;
}
}
12 changes: 11 additions & 1 deletion app/src/main/java/com/example/proj2/Classes/Champion.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package com.example.proj2.Classes;

import java.util.ArrayList;

public class Champion {
//Ability[] abilities;
public ArrayList<Ability> getAbilities() {
return abilities;
}

public void setAbilities(ArrayList<Ability> abilities) {
this.abilities = abilities;
}

ArrayList<Ability> abilities;
int id;
public String name;
//Stats
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/com/example/proj2/Classes/ChampionViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Champion> championData = new MutableLiveData<>();
Expand All @@ -21,7 +29,40 @@ public class ChampionViewModel extends ViewModel {
public LiveData<Champion> 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<DocumentSnapshot>() {
@Override
public void onComplete( Task<DocumentSnapshot> 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<Ability> abilities = new ArrayList<Ability>();
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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a758ccc

Please sign in to comment.