-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
275 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...et/handler/ClubSetUpgradePacketHandler.kt → ...ubworkshop/ClubSetUpgradePacketHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...fking/pangya/game/packet/handler/clubworkshop/ClubWorkshopAcceptTransformPacketHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package work.fking.pangya.game.packet.handler.clubworkshop | ||
|
||
import io.netty.buffer.ByteBuf | ||
import work.fking.pangya.game.GameServer | ||
import work.fking.pangya.game.net.ClientPacketHandler | ||
import work.fking.pangya.game.player.Player | ||
|
||
class ClubWorkshopAcceptTransformPacketHandler : ClientPacketHandler { | ||
override fun handle(server: GameServer, player: Player, packet: ByteBuf) { | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...king/pangya/game/packet/handler/clubworkshop/ClubWorkshopDeclineTransformPacketHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package work.fking.pangya.game.packet.handler.clubworkshop | ||
|
||
import io.netty.buffer.ByteBuf | ||
import work.fking.pangya.game.GameServer | ||
import work.fking.pangya.game.net.ClientPacketHandler | ||
import work.fking.pangya.game.player.Player | ||
|
||
class ClubWorkshopDeclineTransformPacketHandler : ClientPacketHandler { | ||
override fun handle(server: GameServer, player: Player, packet: ByteBuf) { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...lin/work/fking/pangya/game/packet/handler/clubworkshop/ClubWorkshopRankUpPacketHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package work.fking.pangya.game.packet.handler.clubworkshop | ||
|
||
import io.netty.buffer.ByteBuf | ||
import work.fking.pangya.game.GameServer | ||
import work.fking.pangya.game.model.IFF_TYPE_CLUBSET | ||
import work.fking.pangya.game.model.iffTypeFromId | ||
import work.fking.pangya.game.net.ClientPacketHandler | ||
import work.fking.pangya.game.packet.outbound.ClubSetReplies | ||
import work.fking.pangya.game.player.Player | ||
|
||
class ClubWorkshopRankUpPacketHandler : ClientPacketHandler { | ||
override fun handle(server: GameServer, player: Player, packet: ByteBuf) { | ||
val cardIffId = packet.readIntLE() | ||
val cardQuantity = packet.readShortLE() | ||
val clubSetUid = packet.readIntLE() | ||
println("cardIffId=$cardIffId, cardQuantity=$cardQuantity, clubSetUid=$clubSetUid") | ||
|
||
val clubSet = player.inventory.findByUid(clubSetUid) ?: throw IllegalStateException("Player ${player.nickname} tried to rank up a clubset it does not own ($clubSetUid)") | ||
|
||
val clubSetStats = clubSet.clubWorkshop.stats | ||
val statBefore = clubSetStats[0] | ||
clubSetStats[0]++ | ||
val statAfter = clubSetStats[0] | ||
player.write(ClubSetReplies.syncClubSetItem(clubSet, statBefore, statAfter)) | ||
player.writeAndFlush(ClubSetReplies.workshopRankUpAck(clubSetUid, 0)) | ||
} | ||
} |
51 changes: 48 additions & 3 deletions
51
game-server/src/main/kotlin/work/fking/pangya/game/packet/outbound/ClubSetReplies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,62 @@ | ||
package work.fking.pangya.game.packet.outbound | ||
|
||
import work.fking.pangya.game.player.Item | ||
import work.fking.pangya.game.player.write | ||
import work.fking.pangya.networking.protocol.OutboundPacket | ||
import java.time.Instant | ||
|
||
object ClubSetReplies { | ||
|
||
fun upgradeAck(type: Int, stat: Int, itemUid: Int, cost: Long): OutboundPacket { | ||
fun upgradeAck(result: UpgradeResult, stat: Int, itemUid: Int, cost: Long = 0): OutboundPacket { | ||
return OutboundPacket { buffer -> | ||
buffer.writeShortLE(0xa5) | ||
buffer.writeByte(type) | ||
buffer.writeByte(result.code) | ||
buffer.writeByte(1) // 0 doesn't upgrade a clubset but 1 does? | ||
buffer.writeByte(stat) | ||
buffer.writeIntLE(itemUid) | ||
buffer.writeLongLE(cost) // TODO: how to calculate the upgrade cost? | ||
buffer.writeLongLE(cost) | ||
} | ||
} | ||
|
||
fun workshopRankUpTransform(): OutboundPacket { | ||
return OutboundPacket { buffer -> buffer.writeShortLE(0x241) } | ||
} | ||
|
||
fun workshopRankUpAck(clubSetUid: Int, leveledUpStat: Int): OutboundPacket { | ||
return OutboundPacket { buffer -> | ||
buffer.writeShortLE(0x240) | ||
buffer.writeIntLE(0) // result 0 = ok, 1 = 'System error' | ||
|
||
buffer.writeIntLE(leveledUpStat) // which stat leveled up | ||
buffer.writeIntLE(clubSetUid) | ||
} | ||
} | ||
|
||
fun syncClubSetItem(item: Item, statBefore: Int, statAfter: Int): OutboundPacket { | ||
return OutboundPacket { buffer -> | ||
buffer.writeShortLE(0x216) | ||
|
||
buffer.writeIntLE(Instant.now().epochSecond.toInt()) | ||
buffer.writeIntLE(1) | ||
|
||
buffer.writeByte(0x2) // this packet can sync multiple things, 0x2 means it's an inventory item | ||
buffer.writeIntLE(item.iffId) | ||
buffer.writeIntLE(item.uid) | ||
buffer.writeIntLE(0) | ||
buffer.writeIntLE(statBefore) | ||
buffer.writeIntLE(statAfter) | ||
buffer.writeIntLE(item.quantity) | ||
buffer.writeZero(25) | ||
buffer.write(item.clubWorkshop) | ||
} | ||
} | ||
|
||
enum class UpgradeResult(val code: Int) { | ||
UPGRADE_SUCCESS(1), | ||
DOWNGRADE_SUCCESS(2), | ||
INSUFFICIENT_PANG(3), | ||
INSUFFICIENT_SLOTS(4), | ||
CANNOT_DOWNGRADE_ANYMORE(5), | ||
FAILED_TO_UPGRADE(6) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.