summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/domain/client
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/main/java/kz/ilotterytea/frogartha/domain/client')
-rw-r--r--shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java b/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java
new file mode 100644
index 0000000..272f514
--- /dev/null
+++ b/shared/src/main/java/kz/ilotterytea/frogartha/domain/client/PlayerJumpAction.java
@@ -0,0 +1,32 @@
+package kz.ilotterytea.frogartha.domain.client;
+
+import com.github.czyzby.websocket.serialization.SerializationException;
+import com.github.czyzby.websocket.serialization.Transferable;
+import com.github.czyzby.websocket.serialization.impl.Deserializer;
+import com.github.czyzby.websocket.serialization.impl.Serializer;
+import kz.ilotterytea.frogartha.FrogarthaConstants;
+
+public class PlayerJumpAction implements Transferable<PlayerJumpAction> {
+ private float jumpStrength;
+
+ public PlayerJumpAction() {
+ }
+
+ public PlayerJumpAction(Float jumpStrength) {
+ this.jumpStrength = Math.min(jumpStrength, FrogarthaConstants.Player.MAX_JUMP_STRENGTH);
+ }
+
+ public float getJumpStrength() {
+ return jumpStrength;
+ }
+
+ @Override
+ public void serialize(Serializer serializer) throws SerializationException {
+ serializer.serializeFloat(jumpStrength);
+ }
+
+ @Override
+ public PlayerJumpAction deserialize(Deserializer deserializer) throws SerializationException {
+ return new PlayerJumpAction(deserializer.deserializeFloat());
+ }
+}