Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function granblue(commands) {
- const subCommand = commands[1];
- const memberCount = 5;
- switch (subCommand) {
- case ("캐릭터"): {
- const charProperty = commands[2];
- if (charProperty === "도움") {
- return "캐릭터 속성과 이름을 입력해주기 바라네. 예를 들자면 !퐞 캐릭터 암속 오키스 그랜드 와 같은 식이네.";
- }
- if (charProperty === undefined || charProperty === null ||
- ["화속", "수속", "토속", "풍속", "광속", "암속"].indexOf(charProperty) < 0) {
- return "캐릭터 속성을 지정해주기 바라네.";
- }
- const charName = commands[3];
- if (charName === undefined || charName === null) {
- return "캐릭터 이름을 입력해주기 바라네.";
- }
- const charType = commands[4];
- if (charType !== undefined && Object.keys(characterTypeColorData).indexOf(charType) < 0) {
- let message = "올바른 캐틱터 유형을 지정해주기 바라네. 지원하는 유형은";
- for (supportedType of Object.keys(characterTypeColorData)) {
- message = message.concat(supportedType, ", ");
- }
- return message.slice(0, -2).concat("일세.");
- }
- let url = "https://sheets.googleapis.com/v4/spreadsheets/" + granblueSheetID
- + "/values/'" + charProperty + "'!A2:I100?key=" + googleSpreadsheetAPIKey;
- let apiResponse = org.jsoup.Jsoup.connect(url).ignoreContentType(true).get();
- let data = JSON.parse(apiResponse.body().text()).values;
- let cellUrl = "https://sheets.googleapis.com/v4/spreadsheets/" + granblueSheetID;
- cellUrl += "?includeGridData=true&ranges='" + charProperty + "'!A2:A100&key=";
- cellUrl += googleSpreadsheetAPIKey;
- let apiCellResponse = org.jsoup.Jsoup.connect(cellUrl).ignoreContentType(true).get();
- let cellData = JSON.parse(apiCellResponse.body().text()).sheets[0].data;
- let message = "";
- for (let i = 1; i < data.length; i++) {
- if (charName === data[i][0]) {
- let colorInfo = cellData[0].rowData[i].values[0].userEnteredFormat.textFormat.foregroundColor;
- if (charType !== undefined) {
- if (colorInfo.red !== characterTypeColorData[charType].red
- || colorInfo.green !== characterTypeColorData[charType].green
- || colorInfo.blue !== characterTypeColorData[charType].blue) {
- continue;
- }
- message = message.concat(charType, " ");
- } else if (colorInfo !== undefined && Object.keys(colorInfo).length > 0) {
- continue;
- }
- message = message.concat(charName, "을(를) 보유하고 있는 기공사는 ");
- let anyoneHasChar = false;
- for (let j = 1; j < memberCount + 1; j++) {
- if (data[i][j] === "X") {
- message = message.concat(data[0][j], ", ");
- anyoneHasChar = true;
- }
- }
- if (!anyoneHasChar) {
- message = message.concat("없네.");
- } else {
- message = message.slice(0, -2);
- message = message.concat("일세.");
- }
- message = message.concat("\n이 캐릭터의 게임위드 평점은 ", data[i][7],
- ", 갤러리 평점은 ", data[i][8], "일세.");
- return message;
- }
- }
- return "캐릭터를 찾을 수 없었네. 시트에 등록되어 있는 대로 이름을 입력했는지 확인해주기 바라네.";
- break;
- }
- case ("십천중"): {
- const eternalName = commands[2];
- if (eternalName === undefined || eternalName === null) {
- return "보유 상태를 확인할 십천중의 이름을 입력해주게.";
- }
- let url = "https://sheets.googleapis.com/v4/spreadsheets/" + granblueSheetID;
- url += "/values/'십천중%2F아카룸'!A2:G100?key=" + googleSpreadsheetAPIKey;
- Log.d(url);
- let apiResponse = org.jsoup.Jsoup.connect(url).ignoreContentType(true).get();
- let data = JSON.parse(apiResponse.body().text()).values;
- let message = "";
- for (let i = 1; i < data.length; i++) {
- if (eternalName === data[i][0]) {
- message = message.concat(eternalName + "을(를) 보유하고 있는 기공사는 ");
- let anyoneHasChar = false;
- for (let j = 1; j < memberCount + 1; j++) {
- if (data[i][j] === "X") {
- message = message.concat(data[0][j], ", ");
- anyoneHasChar = true;
- } else if (data[i][j] === "XX") {
- message = message.concat(data[0][j], "(최종), ");
- anyoneHasChar = true;
- }
- }
- if (!anyoneHasChar) {
- message = message.concat("없네.");
- } else {
- message = message.slice(0, -2);
- message = message.concat("일세.");
- }
- return message;
- }
- }
- return "십천중을 찾을 수 없었네. 십천중의 이름을 제대로 입력했는지 확인해주기 바라네.";
- break;
- }
- case ("도움"): {
- return "현재 지원하는 명령어는 다음과 같네: 캐릭터, 십천중";
- }
- default: {
- return "지원하지 않는 명령어라네. !퐞 도움 을 통해 가능한 명령어를 확인해 보게.";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement