Skip to content

Instantly share code, notes, and snippets.

@kawashirov
Created March 11, 2017 13:00
Show Gist options
  • Save kawashirov/71033f9a1f59d46ed13dbbf787b6e81d to your computer and use it in GitHub Desktop.
Save kawashirov/71033f9a1f59d46ed13dbbf787b6e81d to your computer and use it in GitHub Desktop.
package com.catstudio.moegirlcafe.cache.cfg.loader;
import com.catstudio.moegirlcafe.util.ServerTool;
import com.catstudio.restaurant.Statics;
import com.catstudio.restaurant.lan.Lan;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Date;
public class StaffDef {
public static final int BYTE = 0;
public static final int INT = 2;
public static final int SHORT = 1;
public static final int STRING = 3;
public static final int WORD_TYPE_STANDBY = 0;
public static final int WORD_TYPE_TIRED = 2;
public static final int WORD_TYPE_WANTGIFT = 3;
public static final int WORD_TYPE_WORKING = 1;
public static ArrayList<StaffDefBean> datas = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType1 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType2 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType3 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType4 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType5 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollType6 = new ArrayList();
public static ArrayList<StaffDefBean> datasRollTypeLottery = new ArrayList();
public static int[] types;
public static class StaffDefBean {
public int Character;
public Date EndTime = new Date();
public int Gender;
public boolean HaveNormalAVatar = true;
public boolean HaveSpecialAvatar;
public int Id;
public boolean Lottery;
public String[] Name = new String[4];
public int[] Piece = new int[5];
public int Place;
public int SPAnimIndex;
public String[] SpName = new String[4];
public Date StartTime = new Date();
public int Type;
public int Weight;
public int favDish;
public String[] longDesc = new String[4];
public int multi;
public String[][][] words =
((String[][][]) Array.newInstance(String[].class, new int[] {4, 4}));
public String[] 三围 = new String[4];
public String[] 体重 = new String[4];
public String[] 兴趣爱好 = new String[4];
public String[] 喜欢的食物 = new String[4];
public String[] 声优 = new String[4];
public String[] 学校 = new String[4];
public String[] 年龄 = new String[4];
public String[] 性别 = new String[4];
public String[] 性格 = new String[4];
public String[] 星座 = new String[4];
public String[] 昵称 = new String[4];
public String[] 生日 = new String[4];
public String[] 简介 = new String[4];
public String[] 血型 = new String[4];
public String[] 身高 = new String[4];
public String getName(boolean isSpecial) {
if (isSpecial) {
return this.SpName[Lan.TYPE];
}
return this.Name[Lan.TYPE];
}
}
public static ArrayList<StaffDefBean> load() {
try {
DataInputStream din;
if (System.getProperties().getProperty("os.name").toLowerCase().startsWith("win")) {
din = new DataInputStream(new FileInputStream(new File(Statics.resPath + "def/Staff.bin")));
} else {
din = new DataInputStream(Explore_AreaLv.class.getResourceAsStream("/def/Staff.bin"));
}
return load(din);
} catch (Exception e) {
e.printStackTrace();
return datas;
}
}
public static ArrayList<StaffDefBean> load(DataInputStream din) {
try {
int i;
ArrayList<StaffDefBean> datas = new ArrayList();
ArrayList<StaffDefBean> datasRollType1 = new ArrayList();
ArrayList<StaffDefBean> datasRollType2 = new ArrayList();
ArrayList<StaffDefBean> datasRollType3 = new ArrayList();
ArrayList<StaffDefBean> datasRollType4 = new ArrayList();
ArrayList<StaffDefBean> datasRollType5 = new ArrayList();
ArrayList<StaffDefBean> datasRollType6 = new ArrayList();
ArrayList<StaffDefBean> datasRollTypeLottery = new ArrayList();
types = new int[din.readInt()];
for (i = 0; i < types.length; i++) {
types[i] = din.readByte();
}
int dataLen = din.readInt();
for (i = 0; i < dataLen; i++) {
int j;
String[] strArr;
StaffDefBean row = new StaffDefBean();
row.Id = din.readInt();
for (j = 0; j < row.Name.length; j++) {
row.Name[j] = din.readUTF();
}
row.Gender = din.readInt();
row.Type = din.readInt();
row.Character = din.readInt();
row.Place = din.readInt();
row.SPAnimIndex = din.readInt();
row.favDish = din.readInt();
for (j = 0; j < row.Piece.length; j++) {
row.Piece[j] = 100;
}
row.Piece[2] = din.readInt();
row.Piece[3] = din.readInt();
row.Piece[4] = din.readInt();
row.Weight = din.readInt();
row.HaveSpecialAvatar = din.readByte() != (byte) 0;
for (j = 0; j < row.longDesc.length; j++) {
row.longDesc[j] = "";
}
for (j = 0; j < row.昵称.length; j++) {
row.昵称[j] = din.readUTF();
if (row.昵称[j].equals("null")) {
row.昵称[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][0] + row.昵称[j] + "\n";
}
}
for (j = 0; j < row.声优.length; j++) {
row.声优[j] = din.readUTF();
if (row.声优[j].equals("null")) {
row.声优[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][1] + row.声优[j] + "\n";
}
}
for (j = 0; j < row.性别.length; j++) {
row.性别[j] = din.readUTF();
if (row.性别[j].equals("null")) {
row.性别[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][2] + row.性别[j] + "\n";
}
}
for (j = 0; j < row.年龄.length; j++) {
row.年龄[j] = din.readUTF();
if (row.年龄[j].equals("null")) {
row.年龄[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][3] + row.年龄[j] + "\n";
}
}
for (j = 0; j < row.生日.length; j++) {
row.生日[j] = din.readUTF();
if (row.生日[j].equals("null")) {
row.生日[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][4] + row.生日[j] + "\n";
}
}
for (j = 0; j < row.星座.length; j++) {
row.星座[j] = din.readUTF();
if (row.星座[j].equals("null")) {
row.星座[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][5] + row.星座[j] + "\n";
}
}
for (j = 0; j < row.身高.length; j++) {
row.身高[j] = din.readUTF();
if (row.身高[j].equals("null")) {
row.身高[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][6] + row.身高[j] + "\n";
}
}
for (j = 0; j < row.体重.length; j++) {
row.体重[j] = din.readUTF();
if (row.体重[j].equals("null")) {
row.体重[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][7] + row.体重[j] + "\n";
}
}
for (j = 0; j < row.三围.length; j++) {
row.三围[j] = din.readUTF();
if (row.三围[j].equals("null")) {
row.三围[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][8] + row.三围[j] + "\n";
}
}
for (j = 0; j < row.血型.length; j++) {
row.血型[j] = din.readUTF();
if (row.血型[j].equals("null")) {
row.血型[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][9] + row.血型[j] + "\n";
}
}
for (j = 0; j < row.性格.length; j++) {
row.性格[j] = din.readUTF();
if (row.性格[j].equals("null")) {
row.性格[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][10] + row.性格[j] + "\n";
}
}
for (j = 0; j < row.学校.length; j++) {
row.学校[j] = din.readUTF();
if (row.学校[j].equals("null")) {
row.学校[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][11] + row.学校[j] + "\n";
}
}
for (j = 0; j < row.兴趣爱好.length; j++) {
row.兴趣爱好[j] = din.readUTF();
if (row.兴趣爱好[j].equals("null")) {
row.兴趣爱好[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][12] + row.兴趣爱好[j] + "\n";
}
}
for (j = 0; j < row.喜欢的食物.length; j++) {
row.喜欢的食物[j] = din.readUTF();
if (row.喜欢的食物[j].equals("null")) {
row.喜欢的食物[j] = null;
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][13] + row.喜欢的食物[j] + "\n";
}
}
for (j = 0; j < row.简介.length; j++) {
row.简介[j] = din.readUTF();
if (row.简介[j].equals("null")) {
row.简介[j] = "";
} else {
strArr = row.longDesc;
strArr[j] = strArr[j] + Lan.staff[16][14] + row.简介[j] + "\n";
}
}
for (j = 0; j < row.words.length; j++) {
row.words[j][0] = din.readUTF().replace("|", "_").split("_");
row.words[j][1] = din.readUTF().replace("|", "_").split("_");
row.words[j][2] = din.readUTF().replace("|", "_").split("_");
row.words[j][3] = din.readUTF().replace("|", "_").split("_");
}
for (j = 0; j < row.SpName.length; j++) {
row.SpName[j] = din.readUTF();
}
row.multi = din.readInt();
String startDateStr = din.readUTF();
row.StartTime.setYear(Integer.parseInt(startDateStr.substring(0, 4)) - 1900);
row.StartTime.setMonth(Integer.parseInt(startDateStr.substring(4, 6)) - 1);
row.StartTime.setDate(Integer.parseInt(startDateStr.substring(6, 8)));
row.StartTime.setHours(Integer.parseInt(startDateStr.substring(8, 10)));
row.StartTime.setMinutes(Integer.parseInt(startDateStr.substring(10, 12)));
row.StartTime.setSeconds(0);
String endDateStr = din.readUTF();
row.EndTime.setYear(Integer.parseInt(endDateStr.substring(0, 4)) - 1900);
row.EndTime.setMonth(Integer.parseInt(endDateStr.substring(4, 6)) - 1);
row.EndTime.setDate(Integer.parseInt(endDateStr.substring(6, 8)));
row.EndTime.setHours(Integer.parseInt(endDateStr.substring(8, 10)));
row.EndTime.setMinutes(Integer.parseInt(endDateStr.substring(10, 12)));
row.EndTime.setSeconds(0);
row.Lottery = din.readBoolean();
row.HaveNormalAVatar = din.readByte() != (byte) 0;
if (row.Lottery) {
datasRollTypeLottery.add(row);
}
datas.add(row);
for (j = 0; j < row.multi; j++) {
if (row.Type == 1) {
datasRollType1.add(row);
} else if (row.Type == 2) {
datasRollType2.add(row);
} else if (row.Type == 3) {
datasRollType3.add(row);
} else if (row.Type == 4) {
datasRollType4.add(row);
} else if (row.Type == 5) {
datasRollType5.add(row);
} else if (row.Type == 6) {
datasRollType6.add(row);
} else if (row.Type == 6) {
datasRollType6.add(row);
}
}
}
din.close();
datas = datas;
datasRollType1 = datasRollType1;
datasRollType2 = datasRollType2;
datasRollType3 = datasRollType3;
datasRollType4 = datasRollType4;
datasRollType5 = datasRollType5;
datasRollType6 = datasRollType6;
datasRollTypeLottery = datasRollTypeLottery;
} catch (Exception e) {
e.printStackTrace();
}
return datas;
}
public static String getRandomWords(int id, int workType) {
if (id < 0 || id >= datas.size()) {
return "";
}
try {
StaffDefBean def = (StaffDefBean) datas.get(id);
return def.words[workType][Lan.TYPE][
ServerTool.getRandom(def.words[workType][Lan.TYPE].length)];
} catch (Exception e) {
return "";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment