From fa3bc959a98ac445d21b2a195473af01754358f6 Mon Sep 17 00:00:00 2001 From: Leonard <Leonard@Leonard.Leo> Date: Mon, 15 Jun 2020 01:52:20 +0300 Subject: [PATCH] enough for today --- .../Server/RequestObject.java | 19 +++++++++++++++++++ .../Server/RequestType.java | 2 +- .../Server/Services/BattleService.java | 18 ++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestObject.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestObject.java index 8379a87b..8c340831 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestObject.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestObject.java @@ -1,9 +1,14 @@ package com.galaxytrucker.galaxytruckerreloaded.Server; +import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew; +import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Planet; +import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Trader; import com.galaxytrucker.galaxytruckerreloaded.Model.Ship; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class RequestObject { @@ -16,4 +21,18 @@ public class RequestObject { /** Ship */ private Ship ship; + + /** Trader */ + private Trader trader; + + /** Planet */ + private Planet planet; + + /** Crew */ + private Crew crew; + + /** List of crew */ + private List<Crew> moreCrew; + + } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestType.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestType.java index 8615f415..59033b7b 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestType.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/RequestType.java @@ -1,5 +1,5 @@ package com.galaxytrucker.galaxytruckerreloaded.Server; public enum RequestType { - LOGIN + } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/Services/BattleService.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/Services/BattleService.java index d925996d..beb4cad2 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/Services/BattleService.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Server/Services/BattleService.java @@ -1,6 +1,5 @@ package com.galaxytrucker.galaxytruckerreloaded.Server.Services; -import com.badlogic.gdx.scenes.scene2d.ui.List; import com.galaxytrucker.galaxytruckerreloaded.Model.Ship; import com.galaxytrucker.galaxytruckerreloaded.Model.ShipLayout.Room; import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon; @@ -10,6 +9,8 @@ import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO; import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.WeaponDAO; import lombok.*; +import java.util.List; + /** This class handles battle logic on the server side */ @Getter @Setter @@ -47,13 +48,19 @@ public class BattleService { private RewardService rewardService; /** Change the ship which's round it is */ - public void nextRound(){} + public void nextRound(){ + for (Ship s : participants){ + if (!s.getAssociatedUser().equals(currentRound.getAssociatedUser())){ + currentRound = s; + } + } + } /** Validate user input by checking if it's his round to play * @param s - the ship which wants to play * @return true if it is it's round else false */ public boolean validMove(Ship s){ - return false; + return currentRound.getAssociatedUser().equals(s.getAssociatedUser()); } /** Make one ship attack another's section @@ -61,7 +68,10 @@ public class BattleService { * @param opponent - the opponent's ship * @param weapon - the weapon attacking * @param room - the room being attacked */ - public void attack(Ship attacker, Ship opponent, Weapon weapon, Room room){} + public void attack(Ship attacker, Ship opponent, Weapon weapon, Room room){ + if (validMove(attacker)){ + } + } /** Heal a ship * @param ship - the ship to heal -- GitLab