Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Run breakdown #499

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
11 changes: 11 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@ object Config : Vigilant(
)
var partyFinderStats = false

@Property(
type = PropertyType.SELECTOR, name = "Run Breakdown",
description = "§b[WIP] Shows a Breakdown on what players did in the dungeon.",
options = ["Disabled", "Enabled", "Enabled + Terminals"],
category = "Dungeons", subcategory = "Miscellaneous",
i18nName = "skytils.config.dungeons.miscellaneous.run_breakdown",
i18nCategory = "skytils.config.dungeons",
i18nSubcategory = "skytils.config.dungeons.miscellaneous"
)
var runBreakdown = 0

@Property(
type = PropertyType.SWITCH, name = "Dungeon Chest Profit",
description = "Shows the estimated profit for items from chests in dungeons.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ object DungeonListener {
private val secretsRegex = Regex("\\s*§7(?<secrets>\\d+)\\/(?<maxSecrets>\\d+) Secrets")
private val keyPickupRegex = Regex("§r§e§lRIGHT CLICK §r§7on §r§7.+?§r§7 to open it\\. This key can only be used to open §r§a(?<num>\\d+)§r§7 door!§r")
private val witherDoorOpenedRegex = Regex("^(?:\\[.+?] )?(?<name>\\w+) opened a WITHER door!$")
private val terminalCompletedRegex = Regex("§r§.(?<username>\\w+)§r§a (?:activated|completed) a (?<type>device|terminal|lever)! \\(§r§c(?<completed>\\d)§r§a\\/(?<total>\\d)\\)§r")
private const val bloodOpenedString = "§r§cThe §r§c§lBLOOD DOOR§r§c has been opened!§r"
val outboundRoomQueue = ConcurrentLinkedQueue<C2SPacketDungeonRoom>()
var isSoloDungeon = false
Expand Down Expand Up @@ -150,7 +151,7 @@ object DungeonListener {
if (room.foundSecrets != sec) {
room.foundSecrets = sec
if (team.size > 1)
WSClient.sendPacketAsync(C2SPacketDungeonRoomSecret(SBInfo.server ?: return@setFoundSecrets, room.mainRoom.data.name, sec))
WSClient.sendPacketAsync(C2SPacketDungeonRoomSecret(SBInfo.server ?: return@setFoundSecrets, room.mainRoom.data.name, sec, mc.thePlayer.name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the point of this? two players can have the same update at the same time and can be in the same room at the same time

additionally the server is aware of the sender of the packet

}
}
}
Expand All @@ -160,6 +161,17 @@ object DungeonListener {
DungeonFeatures.DungeonSecretDisplay.maxSecrets = -1
}
} else {
terminalCompletedRegex.find(text)?.let {
val completer = team[it.groups["username"]?.value]
val type = it.groups["type"]?.value

if (completer != null && type != null) {
when (type) {
"lever" -> completer.leversDone++
"terminal", "device" -> completer.terminalsDone++
}
}
}
if (text.stripControlCodes()
.trim() == "> EXTRA STATS <"
) {
Expand All @@ -181,6 +193,22 @@ object DungeonListener {
if (Skytils.config.autoRepartyOnDungeonEnd) {
RepartyCommand.processCommand(mc.thePlayer, emptyArray())
}
if (Skytils.config.runBreakdown != 0) {
tickTimer(6) {
val output = team.map {
//TODO: Maybe also save the rank color?
var output = "§6${it.key}§a | Secrets: §6${it.value.secretsDone}§a | Rooms: §6${it.value.roomsDone}§a | Deaths: §6${it.value.deaths}"

if (Skytils.config.runBreakdown == 2 && DungeonFeatures.dungeonFloorNumber == 7) {
output += "§a | Terminals: §6${it.value.terminalsDone}§a | Levers: §6${it.value.leversDone}"
}

output
}

UChat.chat(output.joinToString("\n"))
}
}
} else if (text.startsWith("§r§c ☠ ")) {
if (text.endsWith(" §r§7reconnected§r§7.§r")) {
val match = reconnectedRegex.find(text) ?: return
Expand Down Expand Up @@ -510,6 +538,11 @@ object DungeonListener {
}
var dead = false
var deaths = 0
var secretsDone = 0
var roomsDone = 0
var terminalsDone = 0
var leversDone = 0

var lastLivingStateChange: Long? = null

val mapPlayer = DungeonMapPlayer(this, skin)
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsws/client/PacketHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import gg.skytils.skytilsmod.features.impl.dungeons.catlas.utils.ScanUtils
import gg.skytils.skytilsmod.features.impl.mining.CHWaypoints
import gg.skytils.skytilsmod.features.impl.mining.CHWaypoints.CHInstance
import gg.skytils.skytilsmod.features.impl.mining.CHWaypoints.chWaypointsList
import gg.skytils.skytilsmod.listeners.DungeonListener.team
import gg.skytils.skytilsmod.utils.SBInfo
import gg.skytils.skytilsws.shared.IPacketHandler
import gg.skytils.skytilsws.shared.SkytilsWS
Expand Down Expand Up @@ -62,6 +63,15 @@ object PacketHandler : IPacketHandler {
DungeonInfo.uniqueRooms.find { it.mainRoom.data.name == packet.roomId }?.let {
if (packet.secretCount > (it.foundSecrets ?: -1)) {
it.foundSecrets = packet.secretCount
val finder = team[packet.finder]

if (finder != null) {
finder.secretsDone++

if (packet.secretCount == it.mainRoom.data.secrets) {
finder.roomsDone++
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skytils/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ skytils.config.dungeons.miscellaneous.auto_copy_fails_to_clipboard=Auto Copy Fai
skytils.config.dungeons.quality_of_life.autoreparty_on_dungeon_ending=Auto-Reparty on Dungeon Ending
skytils.config.dungeons.miscellaneous.death_counter=Death Counter
skytils.config.dungeons.party_finder.party_finder_stats=Party Finder Stats
skytils.config.dungeons.miscellaneous.run_breakdown=Run Breakdown
skytils.config.dungeons.miscellaneous.dungeon_chest_profit=Dungeon Chest Profit
skytils.config.dungeons.miscellaneous.dungeon_chest_profit_includes_essence=Dungeon Chest Profit Includes Essence
skytils.config.dungeons.miscellaneous.highlight_unopened_croesus_chests=Highlight Unopened Croesus Chests
Expand Down
Loading