commonMain.ro.dragossusi.sevens.socket.command.ServerFrameKey.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of socket-jvm Show documentation
Show all versions of socket-jvm Show documentation
Socket classes used in sevens
package ro.dragossusi.sevens.socket.command
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.builtins.ListSerializer
import ro.dragossusi.sevens.payload.Card
/**
* Frame keys received by the server
*
* server
*
* Copyright (C) 2020 Rachieru Dragos-Mihai
*
* server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with server. If not, see [License](http://www.gnu.org/licenses/) .
*
*/
sealed class ServerFrameKey(
override val key: String,
override val serializer: KSerializer?
) : FrameKey {
override fun equals(other: Any?): Boolean {
if (other == key) return true
return super.equals(other)
}
override fun toString(): String {
return key
}
companion object {
/**
* All types used for socket
*/
fun values() = arrayOf(
PLACE_CARDS,
DRAW_CARD,
PICK_TYPE,
END_TURN
)
}
/**
* Place a card
*/
@SerialName("place_card")
object PLACE_CARDS : ServerFrameKey>("place_card", ListSerializer(Card.serializer()))
/**
* Draw a card
*/
@SerialName("draw_card")
object DRAW_CARD : ServerFrameKey("draw_card", null)
/**
* Pick a card type
*/
@SerialName("pick_type")
object PICK_TYPE : ServerFrameKey("pick_type", Card.Type.serializer())
/**
* End a round
*/
@SerialName("end_round")
object END_TURN : ServerFrameKey("end_round", null)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy