Fixed bug where ultimate ironmen could have rewards sent to bank
Fixed the allquest command on new accounts on first login
This commit is contained in:
@@ -69,6 +69,11 @@ public final class FamiliarManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void parse(JSONObject familiarData) {
|
public void parse(JSONObject familiarData) {
|
||||||
|
int currentPet = -1;
|
||||||
|
if (familiarData.containsKey("currentPet")) {
|
||||||
|
currentPet = Integer.parseInt(familiarData.get("currentPet").toString());
|
||||||
|
}
|
||||||
|
if (player.version < 2) { //migrate the v1 format
|
||||||
for (Pets pet : Pets.values()) {
|
for (Pets pet : Pets.values()) {
|
||||||
for (int id : new int[]{pet.getBabyItemId(), pet.getGrownItemId(), pet.getOvergrownItemId()}) {
|
for (int id : new int[]{pet.getBabyItemId(), pet.getGrownItemId(), pet.getOvergrownItemId()}) {
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
@@ -77,11 +82,6 @@ public final class FamiliarManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentPet = -1;
|
|
||||||
if (familiarData.containsKey("currentPet")) {
|
|
||||||
currentPet = Integer.parseInt(familiarData.get("currentPet").toString());
|
|
||||||
}
|
|
||||||
if (player.version < 2) { //migrate the v1 format
|
|
||||||
JSONArray petDetails = (JSONArray) familiarData.get("petDetails");
|
JSONArray petDetails = (JSONArray) familiarData.get("petDetails");
|
||||||
for (Object petDetail : petDetails) {
|
for (Object petDetail : petDetails) {
|
||||||
JSONObject detail = (JSONObject) petDetail;
|
JSONObject detail = (JSONObject) petDetail;
|
||||||
@@ -267,6 +267,9 @@ public final class FamiliarManager {
|
|||||||
player.getDialogueInterpreter().sendDialogue("You need a summoning level of " + pets.getSummoningLevel() + " to summon this.");
|
player.getDialogueInterpreter().sendDialogue("You need a summoning level of " + pets.getSummoningLevel() + " to summon this.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!this.petDetails.containsKey(itemId)) {
|
||||||
|
petDetails.put(itemId, new ArrayList<PetDetails>());
|
||||||
|
}
|
||||||
int last = this.petDetails.get(itemId).size() - 1;
|
int last = this.petDetails.get(itemId).size() - 1;
|
||||||
if (last < 0) { //new pet
|
if (last < 0) { //new pet
|
||||||
last = 0;
|
last = 0;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package content.minigame.fishingtrawler
|
package content.minigame.fishingtrawler
|
||||||
|
|
||||||
import content.global.skill.fishing.Fish
|
import content.global.skill.fishing.Fish
|
||||||
|
import core.api.Container
|
||||||
|
import core.api.addItem
|
||||||
|
import core.api.addItemOrDrop
|
||||||
import core.api.splitLines
|
import core.api.splitLines
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.node.entity.player.link.IronmanMode
|
||||||
import core.game.node.item.GroundItemManager
|
import core.game.node.item.GroundItemManager
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
import core.game.node.item.WeightedChanceItem
|
import core.game.node.item.WeightedChanceItem
|
||||||
@@ -57,25 +61,34 @@ object TrawlerLoot {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun addLootAndMessage(player: Player, fishLevel: Int, rolls: Int, skipJunk: Boolean) {
|
fun addLootAndMessage(player: Player, fishLevel: Int, rolls: Int, skipJunk: Boolean) {
|
||||||
if (rolls < 1) return
|
if (rolls < 1) return
|
||||||
val frequencyList = listOf<MutableMap<String, Int>>(HashMap(), HashMap(), HashMap())
|
val frequencyList = listOf<MutableMap<Int, Int>>(HashMap(), HashMap(), HashMap())
|
||||||
getLoot(fishLevel, rolls, skipJunk).forEach {
|
getLoot(fishLevel, rolls, skipJunk).forEach {
|
||||||
if (!player.bank.add(it)) GroundItemManager.create(it, player)
|
|
||||||
when (it.id) {
|
when (it.id) {
|
||||||
in trawlerFishIds -> frequencyList[0].merge(it.name, 1, Int::plus)
|
in trawlerFishIds -> frequencyList[0].merge(it.id, 1, Int::plus)
|
||||||
in trawlerMisc -> frequencyList[1].merge(it.name, 1, Int::plus)
|
in trawlerMisc -> frequencyList[1].merge(it.id, 1, Int::plus)
|
||||||
in junkItems -> frequencyList[2].merge(it.name, 1, Int::plus)
|
in junkItems -> frequencyList[2].merge(it.id, 1, Int::plus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(colorize("%RYour reward has been sent to your bank:"))
|
// Extract and join each frequency map's entries as items
|
||||||
// Extract and join each frequency maps entries as string. Split based on length, then send each line as message.
|
|
||||||
frequencyList.forEachIndexed { idx, fMap ->
|
frequencyList.forEachIndexed { idx, fMap ->
|
||||||
if (fMap.isNotEmpty()) {
|
if (fMap.isNotEmpty()) {
|
||||||
|
// Give reward
|
||||||
|
fMap.forEach {
|
||||||
|
if (player.ironmanManager.mode == IronmanMode.ULTIMATE || !addItem(player, it.key, it.value, Container.BANK)) {
|
||||||
|
val notedIdIfFish = if (idx == 0) it.key + 1 else it.key
|
||||||
|
addItemOrDrop(player, notedIdIfFish, it.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Split based on length, then send each line as message
|
||||||
splitLines(
|
splitLines(
|
||||||
fMap.entries.joinToString(prefix = if (idx == 0) "Fish: " else if (idx == 1) "Misc: " else "Junk: ", postfix = ".") { "${it.key}: ${it.value}" },
|
fMap.entries.joinToString(prefix = if (idx == 0) "Fish: " else if (idx == 1) "Misc: " else "Junk: ", postfix = ".") { "${Item(it.key).name}: ${it.value}" },
|
||||||
85
|
85
|
||||||
).forEach { player.sendMessage(it) }
|
).forEach { player.sendMessage(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (player.ironmanManager.mode != IronmanMode.ULTIMATE) {
|
||||||
|
player.sendMessage(colorize("%RYour reward has been sent to your bank:"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val lootTable = arrayOf(
|
private val lootTable = arrayOf(
|
||||||
|
|||||||
@@ -448,9 +448,9 @@ fun addItemOrDrop(player: Player, id: Int, amount: Int = 1) {
|
|||||||
fun addItemOrBank(player: Player, id: Int, amount: Int = 1) {
|
fun addItemOrBank(player: Player, id: Int, amount: Int = 1) {
|
||||||
val item = Item(id, amount)
|
val item = Item(id, amount)
|
||||||
if (!player.inventory.add(item)) {
|
if (!player.inventory.add(item)) {
|
||||||
if (player.bankPrimary.add(item)) {
|
if (player.ironmanManager.mode != IronmanMode.ULTIMATE && player.bankPrimary.add(item)) {
|
||||||
sendMessage(player, colorize("%RThe ${item.name} has been sent to your bank."))
|
sendMessage(player, colorize("%RThe ${item.name} has been sent to your bank."))
|
||||||
} else if (player.bankSecondary.add(item)) {
|
} else if (player.ironmanManager.mode != IronmanMode.ULTIMATE && player.bankSecondary.add(item)) {
|
||||||
sendMessage(player, colorize("%RThe ${item.name} has been sent to your secondary bank."))
|
sendMessage(player, colorize("%RThe ${item.name} has been sent to your secondary bank."))
|
||||||
} else {
|
} else {
|
||||||
GroundItemManager.create(item, player)
|
GroundItemManager.create(item, player)
|
||||||
|
|||||||
Reference in New Issue
Block a user