?? fightcalc.java
字號(hào):
public class FightCalc
{
public static final int MIN_ORGE_INDEX = 50;
public static final int MAX_ORGE_INDEX = 80;
//hold the offset of orge pic in the map pic
private static final int OFFSET = 50;
//hold the orge's attribute
private static final int[][] orgeAttr= {
//HP,attack,defend,money,experience
{50, 20, 1, 1, 1},
{70, 15, 2, 2, 1},
{100, 20, 5, 3, 2},
{110, 25, 5, 5, 3},
{200, 35, 10, 5, 3},
{150, 40, 20, 8, 5},
{125, 50, 25, 10, 7},
{150, 65, 30, 10, 8},
{300, 75, 45, 13, 10},
{400, 90, 50, 15, 12},
{500, 115, 65, 15, 15},
{250, 120, 70, 20, 15},
{450, 150, 90, 22, 19},
{550, 170, 100, 25, 20},
{100, 200, 110, 30, 25},
{700, 250, 125, 32, 25},
{1300, 300, 150, 40, 30},
{850, 350, 200, 45, 35},
{500, 400, 260, 47, 35},
{900, 450, 330, 50, 40},
{1250, 500, 400, 55, 45},
{1500, 560, 460, 60, 50},
{1200, 620, 520, 65, 50},
{2000, 680, 590, 70, 55},
{900, 750, 650, 77, 60},
{1500, 830, 730, 80, 65},
{2500, 900, 850, 84, 70},
{1200, 980, 900, 88, 75},
{3100, 1050, 950, 92, 80},
{15000, 1000, 1000, 100, 100},
{25000, 1500, 1200, 150, 120}
};
public static final int HP = 0,
ATTACK = 1,
DEFEND = 2,
MONEY = 3,
EXPERIENCE = 4;
public static final int BOUT_NUM = 0,
HERO_DAMAGE_PER_BOUT = 1,
ORGE_DAMAGE_PER_BOUT = 2;
//hold the orge's name list
private static final String[] orgeName =
{"綠頭怪 ", "紅頭怪 ","小蝙蝠 ", "骷髏人 ","青頭怪","骷髏士兵",
"初級(jí)法師", "大蝙蝠 ", "獸面人 ", "骷髏隊(duì)長", "石頭怪人", "麻衣法師",
"初級(jí)衛(wèi)兵", "紅蝙蝠 ", "高級(jí)法師", "怪王", "白衣武士", "金甲衛(wèi)士",
"紅衣法師", "獸面武士", "冥衛(wèi)兵 ", "高級(jí)衛(wèi)兵", "雙手劍士", "冥戰(zhàn)士 ",
"金甲隊(duì)長", "靈法師 ", "冥隊(duì)長 ", "靈武士 ", "影子戰(zhàn)士", "紅衣魔王", "冥靈魔王"};
private HeroSprite hero;
//current orge type
private int curOrge;
private int heroDamagePerBout,orgeDamagePerBout;
//hold the bout number that hero attack the orge
private int heroBout;
//hold the bout number that orge attack the hero
private int orgeBout;
public FightCalc(HeroSprite hero)
{
this.hero = hero;
}
//convert the orge pic index to type
private int calcType(int type){return type - OFFSET;}
private void calcBout()
{
//curOrge = calcType(type);
//boolean result = false;
heroDamagePerBout = orgeAttr[curOrge][ATTACK] - hero.getDefend();
orgeDamagePerBout = hero.getAttack() - orgeAttr[curOrge][DEFEND];
heroBout = orgeAttr[curOrge][HP] / orgeDamagePerBout;
if((orgeAttr[curOrge][HP] - orgeDamagePerBout* heroBout)>0) heroBout++;
if(heroDamagePerBout <= 0){
heroDamagePerBout = 0;
orgeBout = Integer.MAX_VALUE;
}else{
orgeBout = hero.getHp() / heroDamagePerBout;
if((hero.getHp() - heroDamagePerBout * orgeBout)>0) orgeBout++;
}
/*System.out.println("heroDamagePerBout:"+heroDamagePerBout);
System.out.println("orgeDamagePerBout:"+orgeDamagePerBout);
System.out.println("heroBout:"+heroBout);
System.out.println("orgeBout:"+orgeBout);*/
}
//return if hero can attack the orge or not
public boolean canAttack(int type)
{
boolean result = false;
curOrge = calcType(type);
if(orgeAttr[curOrge][DEFEND] >= hero.getAttack()){
result = false;
}else{
/*
heroDamagePerBout = orgeAttr[curOrge][ATTACK] - hero.getDefend();
orgeDamagePerBout = hero.getAttack() - orgeAttr[curOrge][DEFEND];
heroBout = orgeAttr[curOrge][HP] / orgeDamagePerBout;
if((orgeAttr[curOrge][HP] - orgeDamagePerBout* heroBout)>0) heroBout++;
orgeBout = hero.getHp() / heroDamagePerBout;
if((hero.getHp() - heroDamagePerBout * orgeBout)>0) orgeBout++;
*/
calcBout();
if(heroBout < orgeBout)result = true;
}
return result;
}
//return the fighting param list
public int[] getFightParam()
{
/*result[0]: bout number
*result[1]: heroDamagePerBout
*result[2]: orgeDamagePerBout
*/
int[] result = new int[3];
result[BOUT_NUM] = heroBout;
result[HERO_DAMAGE_PER_BOUT] = heroDamagePerBout;
result[ORGE_DAMAGE_PER_BOUT] = orgeDamagePerBout;
return result;
}
public String getOrgeName(int type){return orgeName[calcType(type)];}
//public String getOrgeName(){return orgeName[curOrge];}
public int[] getOrgeAttr(int type)
{
int[] result = new int[5];
for(int i = 0;i < 5;i ++)
{ //System.out.println(type+" "+calcType(type));
result[i] = orgeAttr[calcType(type)][i];
}
return result;
}
//public int[] getOrgeAttr(){return getOrgeAttr(curOrge);}
public int getHeroDamage(int type)
{
int result = 0;
curOrge = calcType(type);
if(orgeAttr[curOrge][DEFEND] >= hero.getAttack()){
result = -1;
}else{
calcBout();
result = heroBout * heroDamagePerBout;
}
return result;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -