📄 playcanvas.java.bak
字号:
case 2: // 显示
this.richMan.setDisplayToFucntionList();
break;
case 3: // 选项
this.richMan.setDisplayToOptionList();
break;
}
break;
}
}
/**
* 随机事件发生(角色走到?处)
*/
private void randomEvent()
{
int random = fetchRandom(9);
String s = "";
switch(random)
{
case 0: // '\0'
player_prinson_canNotMoveNum[nowPlayerID] += 2;
player_location[nowPlayerID] = 16;
s = "监狱(连续停留)2天";
break;
case 1: // '\001'
player_money[nowPlayerID] += 300;
s = "抽奖赢得 + $300";
break;
case 2: // '\002'
s = "获得财富的 10%\n" + " + $".concat(String.valueOf(player_money[nowPlayerID] / 10));
player_money[nowPlayerID] = (player_money[nowPlayerID] * 110) / 100;
break;
case 3: // '\003'
s = "海外投资失利!\n损失财产10%\n" + " + $".concat(String.valueOf(String.valueOf((player_money[nowPlayerID] * 90) / 100)));
player_money[nowPlayerID] = (player_money[nowPlayerID] * 90) / 100;
break;
case 4: // '\004'
s = "收入税 5%\n" + " - $".concat(String.valueOf(String.valueOf(player_money[nowPlayerID] / 20)));
player_money[nowPlayerID] = (player_money[nowPlayerID] * 95) / 100;
break;
case 5: // '\005'
s = "财产税 5%\n" + " - $".concat(String.valueOf(String.valueOf(fetchBuildingTax() / 20)));
player_money[nowPlayerID] -= fetchBuildingTax() / 20;
break;
case 6: // '\006'
tricleBroadCast(15);
s = "地震";
break;
case 7: // '\007'
tricleBroadCast(25);
s = "龙卷风";
break;
case 8: // '\b'
fireGround();
s = "火警";
break;
case 9: // '\t'
player_money[nowPlayerID] += 200;
s = "地产投资获利\n+ $200";
break;
}
if(random != 6 && random != 7 && random != 8)
richMan.showChance(s);
}
/**
* 进入监狱
*/
private void prise()
{
player_prinson_canNotMoveNum[nowPlayerID] += 3;
richMan.showInPrisonMessage();
}
/**
* 显示飞到下一个飞机场信息
*/
private void showFlyToNextStation()
{
richMan.showBroadCast("飞到下一个机场.", null, true, "机场");
}
/**
* 飞到下飞机场
*/
public void fly()
{
try
{
Thread.sleep(1000L);
}
catch(Exception exception) { }
switch(player_location[nowPlayerID])
{
case 6: // '\006'
player_location[nowPlayerID] = 37;
break;
case 37: // '%'
player_location[nowPlayerID] = 6;
break;
}
nextPlay(1000);
}
/**
* 使用卡片
* @param cardID 卡片的ID
*/
void useCard(int cardID)
{
switch(cardID)
{
case 4: // 免罪卡
default:
break;
case 0: // 偷盗卡
int cardNum = stealCard();
if(cardNum == -1)
richMan.showCardUsedMessage("没有卡片可偷.");
else {
deleteCard(nowPlayerID, cardID);
addCard(cardNum);
}
break;
case 1: // 均富卡
deleteCard(nowPlayerID, cardID);
int money = 0;
for(int i = 0; i < 3; i++)
if(i != nowPlayerID)
{
player_money[i] /= 2;
money += player_money[i];
}
player_money[nowPlayerID] += money;
richMan.showCardUsedMessage("获得 + $".concat(String.valueOf(money)));
break;
case 2: // 强占卡
if(!isNowPlayerIDGround()) {
occupyGround();
deleteCard(nowPlayerID, cardID);
}
else {
richMan.showCardUsedMessage("你不能在这用这张卡片.");
}
break;
case 3: // 睡眠卡
deleteCard(nowPlayerID, cardID);
int playerID;
for(playerID = fetchRandom(2); playerID == nowPlayerID; playerID = fetchRandom(2));
player_sleep_canNotMoveNum[playerID] += 3;
player_prinson_canNotMoveNum[playerID] = 0;
richMan.showCardUsedMessage("玩家不能移动三轮.");
break;
case 5: // 怪兽卡
deleteCard(nowPlayerID, cardID);
tricleBroadCast(5);
break;
case 6: // 天使卡
deleteCard(nowPlayerID, cardID);
tricleBroadCast(11);
break;
case 7: // 现金卡
deleteCard(nowPlayerID, cardID);
richMan.setDisplayToDiceForm(player_money, nowPlayerID);
break;
case 8: // 财神卡
if(isEmptyGround(player_location[nowPlayerID]))
{
groundForBuilding[player_location[nowPlayerID]] = -1;
deleteCard(nowPlayerID, cardID);
nextPlay(1000);
} else
{
richMan.showCardUsedMessage("你不能在这使用.");
}
break;
case 9: // 衰神卡
if(isEmptyGround(player_location[nowPlayerID]))
{
groundForBuilding[player_location[nowPlayerID]] = -2;
deleteCard(nowPlayerID, cardID);
nextPlay(1000);
} else
{
richMan.showCardUsedMessage("你不能在这使用.");
}
break;
}
}
/**
* 判断是否是空地
* @param groundLocation 空地位置
*/
private boolean isEmptyGround(int groundLocation)
{
return groundLocation != 2 && groundLocation != 6 && groundLocation != 11 && groundLocation != 16 && groundLocation != 20 && groundLocation != 25 && groundLocation != 28 && groundLocation != 32 && groundLocation != 37 && groundLocation != 42 && groundLocation != 45 && groundLocation != 49 && groundForBuilding[groundLocation] == 0;
}
/**
* 强占土地
*/
private void occupyGround()
{
for(; groundForBuilding[player_location[nowPlayerID]] > 9; groundForBuilding[player_location[nowPlayerID]] /= 10);
switch(nowPlayerID)
{
case 2: // '\002'
groundForBuilding[player_location[nowPlayerID]] *= 100;
case 1: // '\001'
groundForBuilding[player_location[nowPlayerID]] *= 10;
default:
richMan.showCardUsedMessage("这块地现在是你的了.");
break;
}
}
/**
* 删除卡片
* @param playID 角色ID
* @param cardID 卡片ID
*/
private boolean deleteCard(int playID, int cardID)
{
boolean flag = false;
//判断有没有这张卡
for(int i = 0; i < player_cards[playID].length; i++)
if(player_cards[playID][i] == cardID)
flag = true;
if(!flag)
return false;
for(int i = 0; i < player_cards[playID].length; i++)
if(player_cards[playID][i] == cardID)
{
player_cards[playID][i] = 16;
i = 5; // 跳出循环,很奇怪的设置。。呵呵
}
// 重新排列卡片
for(int i = 0; i < 4; i++)
if(player_cards[playID][i] == 16)
{
player_cards[playID][i] = player_cards[playID][i + 1];
player_cards[playID][i + 1] = 16;
}
return true;
}
/**
* 偷卡片
*/
private int stealCard()
{
if(nowPlayerID == 0 && player_cards[1][0] == 16 && player_cards[2][0] == 16 ||
nowPlayerID == 1 && player_cards[0][0] == 16 && player_cards[2][0] == 16 ||
nowPlayerID == 2 && player_cards[0][0] == 16 && player_cards[1][0] == 16)
return -1;
int cardNum = 16;
int id = fetchRandomIn0ToMaxNumExceptExcludeNum(2, nowPlayerID);
for(; cardNum == 16; cardNum = player_cards[id][fetchRandom(4)])
id = fetchRandomIn0ToMaxNumExceptExcludeNum(2, nowPlayerID);
deleteCard(id, cardNum);
return cardNum;
}
/**
* 增加卡片
* @param 卡片ID
*/
private void addCard(int cardID)
{
if(cardID == 10) // 随机增加卡片
cardID = fetchRandom(9);
for(int i = 0; i < 5; i++)
if(player_cards[nowPlayerID][i] == 16)
{
player_cards[nowPlayerID][i] = cardID;
richMan.showCardMessage(cardID);
return;
}
forceAddCard(cardID);
}
/**
* 强行增加卡片(5张卡片都满的时候)
* @param 卡片ID
*/
private void forceAddCard(int cardNum)
{
for(int i = 0; i < 4; i++)
player_cards[nowPlayerID][i] = player_cards[nowPlayerID][i + 1];
player_cards[nowPlayerID][4] = cardNum;
richMan.showCardMessage(cardNum);
}
/**
* 获的一个随机数(>=0 and <= number)
* @param number 最大数(包括)
*/
private int fetchRandom(int number)
{
return (random.nextInt() % (number + 1) + (number + 1)) % (number + 1);
}
/**
* 获得一个随机数,除去一个数
* @param maxNum 最大数
* @param excludeNum 排除数
*/
private int fetchRandomIn0ToMaxNumExceptExcludeNum(int maxNum, int excludeNum)
{
int id;
for(id = fetchRandom(maxNum); id == excludeNum; id = fetchRandom(maxNum));
return id;
}
/**
* 火灾
*/
private void fireGround()
{
int groundID = autoFetchNotSpecialGround();
int groundID2;
for(groundID2 = autoFetchNotSpecialGround(); groundNotConnected(groundID) != groundNotConnected(groundID2) || groundID2 == groundID; groundID2 = autoFetchNotSpecialGround());
firedetroyGround(groundID, groundID + 1, 1);
firedetroyGround(groundID2, groundID2 + 1, 1);
repaint();
serviceRepaints();
int groundIDs[] = {
groundID, groundID2
};
richMan.showBroadCast("这些区域被火灾摧毁了:", groundIDs, nowPlayerID != 0, "火警");
}
/**
* 破坏地皮(因为火灾)
* @param beginIndex 地皮开始序号
* @param endIndex 地皮结束序号
* @param j1 我都不知道干什么用的。。呵呵。(j1在这里没有用)
*/
private void firedetroyGround(int beginIndex, int endIndex, int j1)
{
for(int k1 = beginIndex; k1 < endIndex + 1; k1++)
if(groundForBuilding[k1] != 0)
groundForBuilding[k1] = groundForBuilding[k1] >= 10 ? groundForBuilding[k1] >= 100 ? 100 : 10 : 1;
}
/**
* 自动获取非特殊地皮。(除去?,飞机场等)
*/
private int autoFetchNotSpecialGround()
{
int l = fetchRandom(47);
if(l == 2 || l == 5 || l == 6 || l == 10 || l == 11 || l == 14 || l == 15 || l == 16 || l == 20 || l == 25 || l == 27 || l == 28 || l == 32 || l == 36 || l == 37 || l == 41 || l == 42 || l == 45)
l = autoFetchNotSpecialGround();
return l;
}
/**
* 获取不连接的土地
* @param groundLocation 地皮位置
*/
private int groundNotConnected(int groundLocation)
{
return groundLocation >= 2 ? groundLocation >= 5 ? groundLocation >= 10 ? ((int) (groundLocation >= 14 ? ((int) (groundLocation >= 20 ? ((int) (groundLocation >= 25 ? ((int) (groundLocation >= 32 ? ((int) (groundLocation >= 36 ? ((int) (groundLocation >= 41 ? 9 : 8)) : 7)) : 6)) : 5)) : 4)) : 3)) : 2 : 1 : 0;
}
/**
* 激发广播(地震等)
* @param broadCastType 广播类型
*/
private void tricleBroadCast(int broadCastType)
{
int groundIDs[] = null;
switch(fetchRandom(8))
{
case 0: // '\0'
broadCastChangeGround(0, 1, broadCastType);
groundIDs = (new int[] {
0, 1
});
break;
case 1: // '\001'
broadCastChangeGround(3, 4, broadCastType);
groundIDs = (new int[] {
3, 4
});
break;
case 2: // '\002'
broadCastChangeGround(7, 9, broadCastType);
groundIDs = (new int[] {
7, 8, 9
});
break;
case 3: // '\003'
broadCastChangeGround(12, 13, broadCastType);
groundIDs = (new int[] {
12, 13
});
break;
case 4: // '\004'
broadCastChangeGround(17, 19, broadCastType);
groundIDs = (new int[] {
17, 18, 19
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -