- UID
- 137347
- 閱讀權限
- 10
- 主題
- 5
- 帖子
- 63
- 精華
- 0
- A幣
- 20
- 在線時間
- 44 小時
- 最後登錄
- 2024-6-22
集團新軍
- 主題
- 5
- 帖子
- 63
- 精華
- 0
- 綜合社群主題發文量
- 5
- 電玩社群主題發文量
- 0
- 娛樂社群主題發文量
- 0
- 技術社群主題發文量
- 5
- 閱讀權限
- 10
- 註冊時間
- 2021-8-6
TA的每日心情 | 開心 2022-7-11 11:36 |
---|
簽到天數: 14 天 連續簽到: 1 天 [LV.3]偶爾看看II
|
之前花很久時間 終於寫出來的東西 然後在看完幾天前那篇轉蛋機文章 也來發一下這篇 來感謝這邊所有人 如果寫不好 請見諒 這必須有Gashapon語法才能用在Gashapon.java新增 以下語法
public String ShowItem(String type) { //可以顯示轉蛋機物品
StringBuilder sb = new StringBuilder();
Iterator<Pair<Long, GashaponReward>> iterator = this.items.iterator();
sb.append("#b轉蛋機物品有:\r\n");
while (iterator.hasNext()) {
Pair<Long, GashaponReward> c = iterator.next();
if (MapleItemInformationProvider.getInstance().itemExists(c.right.getItemId()) && c.right.getChance() > 0) {
switch (type) {
case "1":
sb.append("#v" + c.right.getItemId() + "#");
break;
case "2":
sb.append("#v" + c.right.getItemId() + "# 道具名稱: #z" + c.right.getItemId() + "#\r\n");
break;
case "GM":
sb.append("#L" + c.right.getItemId() + "##v" + c.right.getItemId() + "##z" + c.right.getItemId() + "# 機率:" + c.right.getChance() + "(點擊更改)\r\n");
break;
default:
sb.append("顯示錯誤!");
break;
}
}
}
if (type == "GM") {
sb.append("\r\n#b#L10000#我要新增抽獎物品#l\r\n");
}
return sb.toString();
}
public String ShowItem_GM() { //透過GM權限可以修改轉蛋機物品
StringBuilder sb = new StringBuilder();
Iterator<Pair<Long, GashaponReward>> iterator = this.items.iterator();
sb.append("#b轉蛋機物品有:\r\n");
while (iterator.hasNext()) {
Pair<Long, GashaponReward> c = iterator.next();
if (MapleItemInformationProvider.getInstance().itemExists(c.right.getItemId())) {
sb.append("#L" + items.size() + "##v" + c.right.getItemId() + "##z" + c.right.getItemId() + "# 機率:" + c.right.getChance() + "(點擊更改)\r\n");
}
}
return sb.toString();
}
public void ChangeChance(MapleCharacter chr, int itemid, int chance) { // 更改轉蛋物機率
try (Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("UPDATE gashapon_items SET chance = ? WHERE gashaponsid = ? AND itemid = ?")) {
ps.setInt(1, chance);
ps.setInt(2, getId());
ps.setInt(3, itemid);
ps.executeUpdate();
} catch (SQLException ex) {
System.out.println("Error GashaponChance" + ex);
FilePrinter.printError("GashaponChance.txt", ex, "GashaponChance has SQL Exception");
}
FileoutputUtil.logToFile("logs/GM_LOG/GM更改轉蛋物機率.txt", "\r\n" + FileoutputUtil.NowTime() + "GM: " + chr.getName() + " 更改物品:" + MapleItemInformationProvider.getInstance().getName(itemid) + " 機率更改為" + chance); //可以新增LOG紀錄
}
public void AddItem(MapleCharacter chr, int itemid, int chance, boolean msg) { //新增轉蛋機物品
try (Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("INSERT INTO gashapon_items SET chance = ? , gashaponsid = ? , itemid = ? , name = ?, showmsg = ?")) {
ps.setInt(1, chance);
ps.setInt(2, getId());
ps.setInt(3, itemid);
ps.setString(4, MapleItemInformationProvider.getInstance().getName(itemid));
ps.setInt(5, (msg ? 1 : 0));
ps.executeUpdate();
} catch (SQLException ex) {
System.out.println("Error GashaponAddItem" + ex);
FilePrinter.printError("GashaponAddItem.txt", ex, "GashaponAddItem has SQL Exception");
}
FileoutputUtil.logToFile("logs/GM_LOG/GM新增轉蛋物.txt", "\r\n" + FileoutputUtil.NowTime() + "GM: " + chr.getName() + " 新增轉蛋物品:" + MapleItemInformationProvider.getInstance().getName(itemid) + " 機率設定為" + chance + " 是否上綠廣:" + (msg ? "是" : "否")); //可以新增LOG紀錄
}
配合轉蛋機重載指令 跟JS 就能做出以下效果
JS就不提供了 謝謝個未
|
|