📄 kmrichman.java
字号:
* 显示卡片信息
* @param cards 卡片
*/
void showCards(int cards[])
{
Display.getDisplay(this).setCurrent(new CardCanvas(this, cards, 0, false));
}
/**
* 使用卡片(手动返回)
* @param cardIDs 卡片
* @param cardIndex 卡片序号
*/
void useCard_hunman(int cardIDs[], int cardIndex)
{
Display.getDisplay(this).setCurrent(new CardCanvas(this, cardIDs, cardIndex, false));
}
/**
* 使用卡片(自动返回)
* @param cardIDs 卡片
* @param cardIndex 卡片序号
*/
void useCard_ComputerActor(int cardIDs[], int cardIndex)
{
Display.getDisplay(this).setCurrent(new CardCanvas(this, cardIDs, cardIndex, true));
}
/**
* 显示广播信息(龙卷风,地震等)
* @param message 消息
* @param grounds 地皮
* @param isAuto 是否自动返回
* @param title 窗口标题
*/
void showBroadCast(String message, int grounds[], boolean isAuto, String title)
{
if(grounds != null)
{
for(int i = 0; i < grounds.length; i++)
{
message = message + " ".concat(fetchGroundName(grounds[i]).trim());
if(i != grounds.length - 1)
message = message.concat(",");
}
}
Display.getDisplay(this).setCurrent(new PlayMessageForm(this, title, message, 2, isAuto));
}
/**
* 获取地皮名字
* @param location 地皮位置
*/
private String fetchGroundName(int location)
{
switch(location)
{
case 0: // '\0'
return " 阿拉斯加 ";
case 1: // '\001'
return " 安克雷奇 ";
case 3: // '\003'
return " 佛罗里达 ";
case 4: // '\004'
return " 迪斯尼乐园 ";
case 7: // '\007'
return " 夏威夷 ";
case 8: // '\b'
return " 瓦胡岛 ";
case 9: // '\t'
return " 哈奇奇海滩 ";
case 12: // '\f'
return " 德克萨斯 ";
case 13: // '\r'
return " 达拉斯 ";
case 17: // '\021'
return " 内华达 ";
case 18: // '\022'
return " 拉斯韦加斯 ";
case 19: // '\023'
return " 塔霍湖 ";
case 21: // '\025'
return " 纽约 ";
case 22: // '\026'
return " 曼哈顿 ";
case 23: // '\027'
return " 布鲁克林 ";
case 24: // '\030'
return " 奎恩斯 ";
case 26: // '\032'
return " 华盛顿 ";
case 29: // '\035'
return " 西雅图 ";
case 30: // '\036'
return " 华盛顿特区 ";
case 31: // '\037'
return " 白宫 ";
case 33: // '!'
return " 伊洛尼斯 ";
case 34: // '"'
return " 芝加哥 ";
case 35: // '#'
return " 鲁斯莫尔峰 ";
case 38: // '&'
return " 加利福尼亚 ";
case 39: // '\''
return " 洛杉矶 ";
case 40: // '('
return " 好莱坞 ";
case 43: // '+'
return " 贝弗莉山 ";
case 44: // ','
return " 旧金山 ";
case 46: // '.'
return "费阿斯门码头";
case 47: // '/'
return " 39码头 ";
case 2: // '\002'
case 5: // '\005'
case 6: // '\006'
case 10: // '\n'
case 11: // '\013'
case 14: // '\016'
case 15: // '\017'
case 16: // '\020'
case 20: // '\024'
case 25: // '\031'
case 27: // '\033'
case 28: // '\034'
case 32: // ' '
case 36: // '$'
case 37: // '%'
case 41: // ')'
case 42: // '*'
case 45: // '-'
default:
return "土地";
}
}
/**
* 转换到股票列表
*/
void setDisplayToStockList()
{
Display.getDisplay(this).setCurrent(new StockList(this, this.playCanvas));
}
/**
* 显示机会获得(地图上的?)的信息
* @param msg 信息
*/
void showChance(String msg)
{
Display.getDisplay(this).setCurrent(new PlayMessageForm(this, "机会", msg, 3, true));
}
/**
* 转换到色子窗口
*/
void setDisplayToDiceCanvas()
{
Display.getDisplay(this).setCurrent(new DiceCanvas(this, true));
}
/**
* 转换到色子窗口(现金卡加钱用)
* @param playerMoney 角色的金钱 (好象这里用不到)
* @param playerID 角色的index (好象这里用不到)
*/
void setDisplayToDiceForm(int playerMoney[], int playerID)
{
Display.getDisplay(this).setCurrent(new DiceCanvas(this, false));
}
/**
* 显示最高分
*/
void showHighScore()
{
String playerNames[] = {
"孙小美", "阿土伯", "钱夫人"
};
String playerData[][] = new String[3][2];
// 得到存贮的最高分
try {
RecordStore recordstore = RecordStore.openRecordStore("RichManScore", false);
ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(
recordstore.getRecord(1));
DataInputStream datainputstream = new DataInputStream(
bytearrayinputstream);
for (int l = 0; l < 3; l++) {
playerData[l][0] = playerNames[datainputstream.readInt()];
playerData[l][1] = "".concat(String.valueOf(datainputstream.readInt()));
}
datainputstream.close();
bytearrayinputstream.close();
recordstore.closeRecordStore();
}
catch (Exception exception) {
// 要是出现异常,用默认值
playerData[0][0] = "孙小美";
playerData[0][1] = "105";
playerData[1][0] = "阿土伯";
playerData[1][1] = "155";
playerData[2][0] = "钱夫人";
playerData[2][1] = "166";
}
Display.getDisplay(this).setCurrent(new HighScoreCanvas(this, playerData));
}
/**
* 更新最高分
* @param playerName 玩家名字
* @param turnCount 游戏进行的轮数(3个人依次玩一次为一轮)
*/
void freshHighScore(int playerName, int turnCount)
{
RecordStore recordstore = null;
int score[][] = new int[3][2];
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 2; j++)
score[i][j] = -1;
}
try
{
recordstore = RecordStore.openRecordStore("RichManScore", false);
}
catch(Exception exception)
{
score[0][0] = 0;
score[0][1] = 105;
score[1][0] = 1;
score[1][1] = 155;
score[2][0] = 2;
score[2][1] = 166;
}
try
{
if(recordstore != null)
{
ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(recordstore.getRecord(1));
DataInputStream datainputstream = new DataInputStream(bytearrayinputstream);
for(int i = 0; i < 3; i++)
{
score[i][0] = datainputstream.readInt();
score[i][1] = datainputstream.readInt();
}
datainputstream.close();
bytearrayinputstream.close();
recordstore.closeRecordStore();
}
}
catch(Exception exception1) { }
// 插入分数
if(turnCount < score[0][1])
{
score[2][0] = score[1][0];
score[2][1] = score[1][1];
score[1][0] = score[0][0];
score[1][1] = score[0][1];
score[0][0] = playerName;
score[0][1] = turnCount;
} else
if(turnCount < score[1][1])
{
score[2][0] = score[1][0];
score[2][0] = score[1][0];
score[1][0] = playerName;
score[1][1] = turnCount;
} else
if(turnCount < score[2][1])
{
score[2][0] = playerName;
score[2][0] = turnCount;
}
byte bytes[] = null;
// 从新写入文件
try
{
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
for(int i2 = 0; i2 < 3; i2++)
{
for(int j2 = 0; j2 < 2; j2++)
dataoutputstream.writeInt(score[i2][j2]);
}
bytes = bytearrayoutputstream.toByteArray();
dataoutputstream.close();
bytearrayoutputstream.close();
}
catch(Exception exception2) { }
try {
RecordStore.deleteRecordStore("RichManScore");
}
catch (RecordStoreException ex) {
System.out.println("Can't find Score!");
}
try
{
RecordStore recordstore1 = RecordStore.openRecordStore("RichManScore", true);
recordstore1.addRecord(bytes, 0, bytes.length);
recordstore1.closeRecordStore();
}
catch(Exception exception3) { }
}
/**
* 买地或或是加盖房子
*/
public void buyGroundorBuilding()
{
playCanvas.buyLand();
confirmMessage(); // 买土地返回
}
/**
* 程序开始,转换到开始画面
*/
public void startApp()
{
Display.getDisplay(this).setCurrent(new OpenCanvas(this));
}
/**
* 暂停程序
*/
public void pauseApp()
{
}
/**
* 破坏程序
*/
public void destroyApp(boolean flag)
{
}
/**
* 退出游戏
*/
public static void exitGame()
{
richMan.destroyApp(true);
richMan.notifyDestroyed();
richMan = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -