Add in Eve's new emote "The Fruits of our Labor". Improved efficiency of
Gacha bot tremendously. Removed redundant web requests and mapped cards to IDs.
This commit is contained in:
parent
3c580f3cb6
commit
250c41d0cf
Binary file not shown.
@ -321,6 +321,7 @@ public class BandoriBot extends ListenerAdapter{
|
|||||||
stamp_map.put("hagumi_hooray",Arrays.asList("hooray","hiphip","whoo","yahoo"));
|
stamp_map.put("hagumi_hooray",Arrays.asList("hooray","hiphip","whoo","yahoo"));
|
||||||
stamp_map.put("kanon_keepgoing",Arrays.asList("keepgoing","dontstop","youcandoit","makeit","gaja","petan","pettan","pengu"));
|
stamp_map.put("kanon_keepgoing",Arrays.asList("keepgoing","dontstop","youcandoit","makeit","gaja","petan","pettan","pengu"));
|
||||||
stamp_map.put("tsugumi_amazing",Arrays.asList("amazing","wow","sugoi","wooo","cool!","tsugurific"));
|
stamp_map.put("tsugumi_amazing",Arrays.asList("amazing","wow","sugoi","wooo","cool!","tsugurific"));
|
||||||
|
stamp_map.put("eve_thefruits",Arrays.asList("fruits","labor","hardwork","effort"));
|
||||||
|
|
||||||
|
|
||||||
/// BOT ONLY!!! DO NOT ADD THE BELOW LINES TO BANDORI MODULE IN SIGIRC!!!
|
/// BOT ONLY!!! DO NOT ADD THE BELOW LINES TO BANDORI MODULE IN SIGIRC!!!
|
||||||
|
@ -11,8 +11,13 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
@ -24,10 +29,6 @@ import java.util.List;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import sig.sigIRC;
|
|
||||||
import sig.modules.ChatLog.ChatLogMessage;
|
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public static String[] readFromFile(String filename) {
|
public static String[] readFromFile(String filename) {
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
@ -246,8 +247,21 @@ public class FileUtils {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int LastSlash(String s) {
|
||||||
|
int lastSlashpos = 0;
|
||||||
|
for (int i=0;i<s.length();i++) {
|
||||||
|
if (s.charAt(i)=='/') {
|
||||||
|
lastSlashpos=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastSlashpos;
|
||||||
|
}
|
||||||
|
|
||||||
public static void downloadFileFromUrl(String url, String file) throws IOException, JSONException {
|
public static void downloadFileFromUrl(String url, String file) throws IOException, JSONException {
|
||||||
URL website = new URL(url);
|
String temp = url.substring(0,LastSlash(url));
|
||||||
|
String temp2 = url.substring(LastSlash(url));
|
||||||
|
|
||||||
|
URL website = new URL(temp+URLEncoder.encode(temp2, "UTF-8"));
|
||||||
HttpURLConnection connection = (HttpURLConnection) website.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) website.openConnection();
|
||||||
/*for (String s : connection.getHeaderFields().keySet()) {
|
/*for (String s : connection.getHeaderFields().keySet()) {
|
||||||
System.out.println(s+": "+connection.getHeaderFields().get(s));
|
System.out.println(s+": "+connection.getHeaderFields().get(s));
|
||||||
|
@ -14,6 +14,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -35,8 +36,10 @@ public class GachaBot {
|
|||||||
static int cardcount = 0;
|
static int cardcount = 0;
|
||||||
static int membercount = 0;
|
static int membercount = 0;
|
||||||
public static int databasecheck = 86400;
|
public static int databasecheck = 86400;
|
||||||
public static List<Card> cardlist = new ArrayList<Card>();
|
public static HashMap<Integer,Member> memberlist = new HashMap<Integer,Member>();
|
||||||
public static List<Member> memberlist = new ArrayList<Member>();
|
public static HashMap<Integer,Card> card_idmap = new HashMap<Integer,Card>();
|
||||||
|
public static HashMap<Integer,List<Card>> card_raritymap = new HashMap<Integer,List<Card>>();
|
||||||
|
public static HashMap<Integer,List<Card>> card_membermap = new HashMap<Integer,List<Card>>();
|
||||||
public static Font programFont = new Font("Century Schoolbook L",Font.PLAIN,24);
|
public static Font programFont = new Font("Century Schoolbook L",Font.PLAIN,24);
|
||||||
public GachaBot(JDA bot) {
|
public GachaBot(JDA bot) {
|
||||||
this.bot=bot;
|
this.bot=bot;
|
||||||
@ -81,6 +84,11 @@ public class GachaBot {
|
|||||||
.append("4* Cards: "+(p.GetPullData()[2])+" ("+df.format((double)(p.GetPullData()[2])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[2]+" dupe"+((p.GetDupeData()[2]==1)?"":"s")+"]").append('\n')
|
.append("4* Cards: "+(p.GetPullData()[2])+" ("+df.format((double)(p.GetPullData()[2])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[2]+" dupe"+((p.GetDupeData()[2]==1)?"":"s")+"]").append('\n')
|
||||||
.append("3* Cards: "+(p.GetPullData()[1])+" ("+df.format((double)(p.GetPullData()[1])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[1]+" dupe"+((p.GetDupeData()[1]==1)?"":"s")+"]").append('\n')
|
.append("3* Cards: "+(p.GetPullData()[1])+" ("+df.format((double)(p.GetPullData()[1])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[1]+" dupe"+((p.GetDupeData()[1]==1)?"":"s")+"]").append('\n')
|
||||||
.append("2* Cards: "+(p.GetPullData()[0])+" ("+df.format((double)(p.GetPullData()[0])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[0]+" dupe"+((p.GetDupeData()[0]==1)?"":"s")+"]").append('\n')
|
.append("2* Cards: "+(p.GetPullData()[0])+" ("+df.format((double)(p.GetPullData()[0])/(p.GetPullData()[0]+p.GetPullData()[1]+p.GetPullData()[2])*100)+"%)").append(" ["+p.GetDupeData()[0]+" dupe"+((p.GetDupeData()[0]==1)?"":"s")+"]").append('\n')
|
||||||
|
.append('\n')
|
||||||
|
.append("Collection: "+(p.GetCollectionData()[2]+p.GetCollectionData()[1]+p.GetCollectionData()[0])+"/"+(Card.star4total+Card.star3total+Card.star2total)).append('\n')
|
||||||
|
.append("4* Cards: "+(p.GetCollectionData()[2])+"/"+Card.star4total).append(" ("+df.format(((double)p.GetCollectionData()[2]/Card.star4total)*100)+"%)").append('\n')
|
||||||
|
.append("3* Cards: "+(p.GetCollectionData()[1])+"/"+Card.star3total).append(" ("+df.format(((double)p.GetCollectionData()[1]/Card.star3total)*100)+"%)").append('\n')
|
||||||
|
.append("2* Cards: "+(p.GetCollectionData()[0])+"/"+Card.star2total).append(" ("+df.format(((double)p.GetCollectionData()[0]/Card.star2total)*100)+"%)").append('\n')
|
||||||
.append("```").build()).queue();
|
.append("```").build()).queue();
|
||||||
}break;
|
}break;
|
||||||
case ".gacha":{
|
case ".gacha":{
|
||||||
@ -124,16 +132,19 @@ public class GachaBot {
|
|||||||
star_rating=3;
|
star_rating=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Card c = Card.pickRandomCardByStarRating(cardlist, star_rating);
|
Card c = Card.pickRandomCardByStarRating(star_rating);
|
||||||
boolean trained = (star_rating>2 && p.getNumberOfCardsInCollection(c)%2==1);
|
boolean trained = (star_rating>2 && p.getNumberOfCardsInCollection(c)%2==1);
|
||||||
picked_cards.add(c);
|
picked_cards.add(c);
|
||||||
|
File card_file = new File(BandoriBot.BASEDIR+"card_art/"+c.getCardID()+((trained)?"_trained":"")+".png");
|
||||||
|
if (!card_file.exists()) {
|
||||||
System.out.println("Requesting Card "+c+" from "+c.getCardURL(trained));
|
System.out.println("Requesting Card "+c+" from "+c.getCardURL(trained));
|
||||||
try {
|
try {
|
||||||
FileUtils.downloadFileFromUrl(c.getCardURL(trained), "card_art/"+c.getCardID()+((trained)?"_trained":"")+".png");
|
FileUtils.downloadFileFromUrl(c.getCardURL(trained), "card_art/"+c.getCardID()+((trained)?"_trained":"")+".png");
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
File card_file = new File(BandoriBot.BASEDIR+"card_art/"+c.getCardID()+((trained)?"_trained":"")+".png");
|
|
||||||
|
}
|
||||||
File star_file = new File(BandoriBot.BASEDIR+"newstar.png");
|
File star_file = new File(BandoriBot.BASEDIR+"newstar.png");
|
||||||
//channel.sendFile(card_file).queue();
|
//channel.sendFile(card_file).queue();
|
||||||
BufferedImage card_img = null;
|
BufferedImage card_img = null;
|
||||||
@ -191,6 +202,7 @@ public class GachaBot {
|
|||||||
if (c!=null) {
|
if (c!=null) {
|
||||||
//Download the image...
|
//Download the image...
|
||||||
try {
|
try {
|
||||||
|
System.out.println(c.getCardArtURL(false));
|
||||||
FileUtils.downloadFileFromUrl(c.getCardArtURL(false), "art/"+card_id+".png");
|
FileUtils.downloadFileFromUrl(c.getCardArtURL(false), "art/"+card_id+".png");
|
||||||
channel.sendFile(new File(BandoriBot.BASEDIR+"art/"+card_id+".png")).queue();
|
channel.sendFile(new File(BandoriBot.BASEDIR+"art/"+card_id+".png")).queue();
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
@ -203,11 +215,17 @@ public class GachaBot {
|
|||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
channel.sendMessage("*I am sorry, but I would like a number there instead...*").queue();
|
channel.sendMessage("*I am sorry, but I would like a number there instead...*").queue();
|
||||||
}*/
|
}*/
|
||||||
|
/*try {
|
||||||
|
FileUtils.downloadFileFromUrl("https://i.bandori.party/u/c/art/1023Lisa-Imai-Pure-%E3%82%B3%E3%83%9F%E3%83%A5%E5%8A%9BMAX-kYqpMS.png", "art/testart.png");
|
||||||
|
channel.sendFile(new File(BandoriBot.BASEDIR+"art/testart.png")).queue();
|
||||||
|
} catch (JSONException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
String character = wordparse[1];
|
String character = wordparse[1];
|
||||||
Member m = Member.getMemberByName(memberlist, character);
|
Member m = Member.getMemberByName(memberlist, character);
|
||||||
if (m!=null) {
|
if (m!=null) {
|
||||||
int character_id = m.getMemberID();
|
int character_id = m.getMemberID();
|
||||||
Card c = Card.pickRandomCardByMemberID(cardlist, character_id);
|
Card c = Card.pickRandomCardByMemberID(character_id);
|
||||||
if (c!=null) {
|
if (c!=null) {
|
||||||
//Download the image...
|
//Download the image...
|
||||||
try {
|
try {
|
||||||
@ -237,8 +255,6 @@ public class GachaBot {
|
|||||||
private static void UpdateCardDatabase() {
|
private static void UpdateCardDatabase() {
|
||||||
int cardsLoaded = 0;
|
int cardsLoaded = 0;
|
||||||
int membersLoaded = 0;
|
int membersLoaded = 0;
|
||||||
List<Card> tempcardlist = new ArrayList<Card>();
|
|
||||||
List<Member> tempmemberlist = new ArrayList<Member>();
|
|
||||||
try {
|
try {
|
||||||
int pagecount = 1;
|
int pagecount = 1;
|
||||||
do {
|
do {
|
||||||
@ -261,9 +277,43 @@ public class GachaBot {
|
|||||||
//System.out.println(cardcount+";"+nexturl+";"+prevurl+";"+carddata);
|
//System.out.println(cardcount+";"+nexturl+";"+prevurl+";"+carddata);
|
||||||
for (Object obj : carddata) {
|
for (Object obj : carddata) {
|
||||||
JSONObject card = (JSONObject) obj;
|
JSONObject card = (JSONObject) obj;
|
||||||
tempcardlist.add(new Card(card));
|
Card c = new Card(card);
|
||||||
|
if (!card_idmap.containsKey(c.getCardID())) {
|
||||||
|
card_idmap.put(c.getCardID(), c);
|
||||||
|
if (card_raritymap.containsKey(c.getCardStarRating())) {
|
||||||
|
List<Card> raritylist = card_raritymap.get(c.getCardStarRating());
|
||||||
|
raritylist.add(c);
|
||||||
|
card_raritymap.put(c.getCardStarRating(), raritylist);
|
||||||
|
} else {
|
||||||
|
List<Card> raritylist = new ArrayList<Card>();
|
||||||
|
raritylist.add(c);
|
||||||
|
card_raritymap.put(c.getCardStarRating(), raritylist);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card_membermap.containsKey(c.getMember())) {
|
||||||
|
List<Card> memberlist = card_membermap.get(c.getMember());
|
||||||
|
memberlist.add(c);
|
||||||
|
card_membermap.put(c.getMember(),memberlist);
|
||||||
|
} else {
|
||||||
|
List<Card> memberlist = new ArrayList<Card>();
|
||||||
|
memberlist.add(c);
|
||||||
|
card_membermap.put(c.getMember(), memberlist);
|
||||||
|
}
|
||||||
|
switch (c.getCardStarRating()) {
|
||||||
|
case 3: {
|
||||||
|
Card.star3total++;
|
||||||
|
}break;
|
||||||
|
case 4: {
|
||||||
|
Card.star4total++;
|
||||||
|
}break;
|
||||||
|
case 2: {
|
||||||
|
Card.star2total++;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
cardcount++;
|
||||||
cardsLoaded++;
|
cardsLoaded++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (nexturl.length()==0) {
|
if (nexturl.length()==0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -294,7 +344,11 @@ public class GachaBot {
|
|||||||
//System.out.println(cardcount+";"+nexturl+";"+prevurl+";"+carddata);
|
//System.out.println(cardcount+";"+nexturl+";"+prevurl+";"+carddata);
|
||||||
for (Object obj : memberdata) {
|
for (Object obj : memberdata) {
|
||||||
JSONObject member = (JSONObject) obj;
|
JSONObject member = (JSONObject) obj;
|
||||||
tempmemberlist.add(new Member(member));
|
Member m = new Member(member);
|
||||||
|
if (!memberlist.containsKey(m.getMemberID())) {
|
||||||
|
memberlist.put(m.getMemberID(),m);
|
||||||
|
membercount++;
|
||||||
|
}
|
||||||
membersLoaded++;
|
membersLoaded++;
|
||||||
}
|
}
|
||||||
if (nexturl.length()==0) {
|
if (nexturl.length()==0) {
|
||||||
@ -305,15 +359,5 @@ public class GachaBot {
|
|||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (cardsLoaded == cardcount) {
|
|
||||||
cardlist.clear();
|
|
||||||
cardlist.addAll(tempcardlist);
|
|
||||||
System.out.println("Updated all card entries.");
|
|
||||||
}
|
|
||||||
if (membersLoaded == membercount) {
|
|
||||||
memberlist.clear();
|
|
||||||
memberlist.addAll(tempmemberlist);
|
|
||||||
System.out.println("Updated all member entries.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,18 @@ package sig.gacha;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import sig.GachaBot;
|
||||||
|
|
||||||
public class Card {
|
public class Card {
|
||||||
|
public static int star4total = 0;
|
||||||
|
public static int star3total = 0;
|
||||||
|
public static int star2total = 0;
|
||||||
int id;
|
int id;
|
||||||
int member;
|
int member;
|
||||||
int rarity;
|
int rarity;
|
||||||
@ -65,32 +71,17 @@ public class Card {
|
|||||||
System.out.println("Card Data: "+this);
|
System.out.println("Card Data: "+this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card findCardByID(List<Card> database,int cardID) {
|
public static Card findCardByID(int cardID) {
|
||||||
for (Card c : database) {
|
return GachaBot.card_idmap.get(cardID);
|
||||||
if (c.id == cardID) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card pickRandomCardByStarRating(List<Card> database,int stars) {
|
public static Card pickRandomCardByStarRating(int stars) {
|
||||||
List<Card> cardList = new ArrayList<Card>();
|
List<Card> cardList = GachaBot.card_raritymap.get(stars);
|
||||||
for (Card c : database) {
|
|
||||||
if (c.rarity==stars) {
|
|
||||||
cardList.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cardList.get((int)(Math.random()*cardList.size()));
|
return cardList.get((int)(Math.random()*cardList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card pickRandomCardByMemberID(List<Card> database,int memberID) {
|
public static Card pickRandomCardByMemberID(int memberID) {
|
||||||
List<Card> cardList = new ArrayList<Card>();
|
List<Card> cardList = GachaBot.card_membermap.get(memberID);
|
||||||
for (Card c : database) {
|
|
||||||
if (c.member == memberID) {
|
|
||||||
cardList.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cardList.get((int)(Math.random()*cardList.size()));
|
return cardList.get((int)(Math.random()*cardList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +109,10 @@ public class Card {
|
|||||||
return rarity;
|
return rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMember() {
|
||||||
|
return member;
|
||||||
|
}
|
||||||
|
|
||||||
int getIntFromJson(JSONObject data, String key) {
|
int getIntFromJson(JSONObject data, String key) {
|
||||||
if (data.has(key) && data.get(key) instanceof Integer) {
|
if (data.has(key) && data.get(key) instanceof Integer) {
|
||||||
return data.getInt(key);
|
return data.getInt(key);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package sig.gacha;
|
package sig.gacha;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -41,8 +42,9 @@ public class Member {
|
|||||||
desc = getStringFromJson(data,"description");
|
desc = getStringFromJson(data,"description");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Member getMemberByName(List<Member> database, String name) {
|
public static Member getMemberByName(HashMap<Integer,Member> database, String name) {
|
||||||
for (Member m : database) {
|
for (Integer i : database.keySet()) {
|
||||||
|
Member m = database.get(i);
|
||||||
if (m.name.split(" ")[0].equalsIgnoreCase(name)) {
|
if (m.name.split(" ")[0].equalsIgnoreCase(name)) {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -50,13 +52,8 @@ public class Member {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Member getMemberByID(List<Member> database, int id) {
|
public static Member getMemberByID(HashMap<Integer,Member> database, int id) {
|
||||||
for (Member m : database) {
|
return database.get(id);
|
||||||
if (m.id==id) {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMemberID() {
|
public int getMemberID() {
|
||||||
|
@ -25,6 +25,9 @@ public class Player {
|
|||||||
int dupepulls4;
|
int dupepulls4;
|
||||||
int dupepulls3;
|
int dupepulls3;
|
||||||
int dupepulls2;
|
int dupepulls2;
|
||||||
|
int collection4;
|
||||||
|
int collection3;
|
||||||
|
int collection2;
|
||||||
HashMap<Integer,Integer> card_collection = new HashMap<Integer,Integer>();
|
HashMap<Integer,Integer> card_collection = new HashMap<Integer,Integer>();
|
||||||
|
|
||||||
public Player(long discordID, String discordName) {
|
public Player(long discordID, String discordName) {
|
||||||
@ -36,6 +39,9 @@ public class Player {
|
|||||||
dupepulls4=0;
|
dupepulls4=0;
|
||||||
dupepulls3=0;
|
dupepulls3=0;
|
||||||
dupepulls2=0;
|
dupepulls2=0;
|
||||||
|
collection4=0;
|
||||||
|
collection3=0;
|
||||||
|
collection2=0;
|
||||||
//SavePlayerProfile();
|
//SavePlayerProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +58,10 @@ public class Player {
|
|||||||
return new int[]{dupepulls2,dupepulls3,dupepulls4};
|
return new int[]{dupepulls2,dupepulls3,dupepulls4};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[] GetCollectionData() {
|
||||||
|
return new int[]{collection2,collection3,collection4};
|
||||||
|
}
|
||||||
|
|
||||||
private String[] GetFileData() {
|
private String[] GetFileData() {
|
||||||
List<String> fileFormat = new ArrayList<String>();
|
List<String> fileFormat = new ArrayList<String>();
|
||||||
fileFormat.add(Long.toString(discordID));
|
fileFormat.add(Long.toString(discordID));
|
||||||
@ -86,9 +96,9 @@ public class Player {
|
|||||||
case 4:{
|
case 4:{
|
||||||
pulls4++;
|
pulls4++;
|
||||||
}break;
|
}break;
|
||||||
default:{
|
case 2:{
|
||||||
pulls2++;
|
pulls2++;
|
||||||
}
|
}break;
|
||||||
}
|
}
|
||||||
if (card_collection.containsKey(c.id)) {
|
if (card_collection.containsKey(c.id)) {
|
||||||
card_collection.put(c.id,card_collection.get(c.id)+1);
|
card_collection.put(c.id,card_collection.get(c.id)+1);
|
||||||
@ -99,11 +109,22 @@ public class Player {
|
|||||||
case 4:{
|
case 4:{
|
||||||
dupepulls4++;
|
dupepulls4++;
|
||||||
}break;
|
}break;
|
||||||
default:{
|
case 2:{
|
||||||
dupepulls2++;
|
dupepulls2++;
|
||||||
}
|
}break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
switch (c.rarity) {
|
||||||
|
case 3:{
|
||||||
|
collection3++;
|
||||||
|
}break;
|
||||||
|
case 4:{
|
||||||
|
collection4++;
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
collection2++;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
card_collection.put(c.id, 1);
|
card_collection.put(c.id, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,10 +150,21 @@ public class Player {
|
|||||||
while (i<filedata.length) {
|
while (i<filedata.length) {
|
||||||
String s = filedata[i++];
|
String s = filedata[i++];
|
||||||
String[] parse = s.split(";");
|
String[] parse = s.split(";");
|
||||||
Card c = Card.findCardByID(GachaBot.cardlist, Integer.parseInt(parse[0]));
|
Card c = Card.findCardByID(Integer.parseInt(parse[0]));
|
||||||
//p.addCardToCollection(c);
|
//p.addCardToCollection(c);
|
||||||
int cardcount = Integer.parseInt(parse[1]);
|
int cardcount = Integer.parseInt(parse[1]);
|
||||||
p.card_collection.put(c.id, cardcount);
|
p.card_collection.put(c.id, cardcount);
|
||||||
|
switch (c.rarity) {
|
||||||
|
case 3:{
|
||||||
|
p.collection3++;
|
||||||
|
}break;
|
||||||
|
case 4:{
|
||||||
|
p.collection4++;
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
p.collection2++;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
if (cardcount>1) {
|
if (cardcount>1) {
|
||||||
switch (c.rarity) {
|
switch (c.rarity) {
|
||||||
case 3:{
|
case 3:{
|
||||||
@ -141,9 +173,9 @@ public class Player {
|
|||||||
case 4:{
|
case 4:{
|
||||||
p.dupepulls4+=cardcount-1;
|
p.dupepulls4+=cardcount-1;
|
||||||
}break;
|
}break;
|
||||||
default:{
|
case 2:{
|
||||||
p.dupepulls2+=cardcount-1;
|
p.dupepulls2+=cardcount-1;
|
||||||
}
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Loaded card "+c.id+" to profile "+p.discordName);
|
System.out.println("Loaded card "+c.id+" to profile "+p.discordName);
|
||||||
@ -169,16 +201,19 @@ public class Player {
|
|||||||
try {
|
try {
|
||||||
int card_id = c.getCardID();
|
int card_id = c.getCardID();
|
||||||
boolean trained = (card_amt==2)?true:false;
|
boolean trained = (card_amt==2)?true:false;
|
||||||
|
File cardfile = new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
|
Message msg = null;
|
||||||
|
if (!cardfile.exists()) {
|
||||||
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
||||||
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
Message msg;
|
}
|
||||||
if (card_amt==1) {
|
if (card_amt==1) {
|
||||||
msg = new MessageBuilder().append("*Congratulations for unlocking a new* 4\\* **"+p.discordName+"**!").append('\n').
|
msg = new MessageBuilder().append("*Congratulations for unlocking a new* 4\\* **"+p.discordName+"**!").append('\n').
|
||||||
append("**"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"]").build();
|
append("**"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"]").build();
|
||||||
} else {
|
} else {
|
||||||
msg = new MessageBuilder().append("**"+p.discordName+"** unlocked the trained version of **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"]! **Congratulations!**").build();
|
msg = new MessageBuilder().append("**"+p.discordName+"** unlocked the trained version of **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"]! **Congratulations!**").build();
|
||||||
}
|
}
|
||||||
channel.sendFile(new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png"),msg).queue();
|
channel.sendFile(cardfile,msg).queue();
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -189,15 +224,18 @@ public class Player {
|
|||||||
try {
|
try {
|
||||||
int card_id = c.getCardID();
|
int card_id = c.getCardID();
|
||||||
boolean trained = (card_amt==10)?true:false;
|
boolean trained = (card_amt==10)?true:false;
|
||||||
|
File cardfile = new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
|
Message msg = null;
|
||||||
|
if (!cardfile.exists()) {
|
||||||
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
||||||
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
Message msg;
|
}
|
||||||
if (card_amt==5) {
|
if (card_amt==5) {
|
||||||
msg = new MessageBuilder().append("**Congratulations for collecting 5 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
msg = new MessageBuilder().append("**Congratulations for collecting 5 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
||||||
} else {
|
} else {
|
||||||
msg = new MessageBuilder().append("**Congratulations for collecting 10 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
msg = new MessageBuilder().append("**Congratulations for collecting 10 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
||||||
}
|
}
|
||||||
channel.sendFile(new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png"),msg).queue();
|
channel.sendFile(cardfile,msg).queue();
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -208,10 +246,13 @@ public class Player {
|
|||||||
int card_id = c.getCardID();
|
int card_id = c.getCardID();
|
||||||
boolean trained = false;
|
boolean trained = false;
|
||||||
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
System.out.println("Requesting Card "+c+" from "+c.getCardArtURL(trained));
|
||||||
|
File cardfile = new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
|
Message msg = null;
|
||||||
|
if (!cardfile.exists()) {
|
||||||
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
FileUtils.downloadFileFromUrl(c.getCardArtURL(trained), "art/"+card_id+((trained)?"_trained":"")+".png");
|
||||||
Message msg;
|
}
|
||||||
msg = new MessageBuilder().append("**Congratulations for collecting 100 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
msg = new MessageBuilder().append("**Congratulations for collecting 100 **"+Member.getMemberByID(GachaBot.memberlist, c.member).name+"** ["+c.name+"] **"+p.discordName+"**!").build();
|
||||||
channel.sendFile(new File(BandoriBot.BASEDIR+"art/"+card_id+((trained)?"_trained":"")+".png"),msg).queue();
|
channel.sendFile(cardfile,msg).queue();
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user