Skip to content
Snippets Groups Projects
Commit cf2769d6 authored by Leonard's avatar Leonard
Browse files

added stuff

parent 521d2009
No related branches found
No related tags found
No related merge requests found
Showing
with 272 additions and 43 deletions
package com.galaxytrucker.galaxytruckerreloaded.Controller.Actions;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import java.net.Socket;
public class Client {
private Socket socket;
private ClientControllerCommunicator clientControllerCommunicator;
public String sendAndReceive(){
// View clicks something
// Controller issues a request
// Client ships request to server
// receive response
// give response to controller
// update views
// return server response as string
return null;
}
/** Constructor */
public Client(){
clientControllerCommunicator = new ClientControllerCommunicator();
// Connect to server
try {
// Send login request
// receive true/false
// send ship request
//clientControllerCommunicator.setClientShip();
}
catch (Exception e){
}
while (true){
sendAndReceive();
}
}
}
package com.galaxytrucker.galaxytruckerreloaded.Controller.Actions;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import lombok.Setter;
@Setter
public class ClientControllerCommunicator {
/** Client ship */
private Ship clientShip;
/** Issue a new request and receive a response
* @param request - the request
* @return the server's response */
public String sendRequest(String request){
return null;
}
/** Issue login request
* @param username - the username
* @return true if the user already exists else create a enw spaceship */
public boolean login(String username){
return false;
}
}
package com.galaxytrucker.galaxytruckerreloaded.Controller.Actions;
public abstract class Controller {
/** ClientControllerCommunicator */
private ClientControllerCommunicator clientControllerCommunicator;
// Extend me
}
package com.galaxytrucker.galaxytruckerreloaded.Server;
import com.galaxytrucker.galaxytruckerreloaded.Server.Database.Database;
import com.galaxytrucker.galaxytruckerreloaded.Server.Services.CrewService;
import com.j256.ormlite.support.ConnectionSource;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
/**
......@@ -12,52 +9,32 @@ import java.net.Socket;
*/
public class Server {
/**
* The database
*/
private Database database;
/**
* Start the server
*/
public static void main(String[] args) {
Database database = new Database();
database.setup();
}
/** Server service communicator */
private ServerServiceCommunicator serverServiceCommunicator;
/**
* Client handler handles clients connected
*/
public void client_handler(Socket socket) {
}
/** Main method */
public static void main(String[] args){}
/**
* Send some data
*
* @param stream - input stream of data to send
*/
public void sendPackets(InputStream stream) {
}
/** Client handler
* @param socket - the client's socket */
private void clientHandler(Socket socket){
/**
* Receive some data
*
* @return outputstream of received data
*/
public OutputStream receivePackets() {
return null;
}
/**
* Validate packets
*/
public void validatePackets() {
/** Start serverServiceCommunicator
* @param source - the database connection source */
private void startServerServiceCommunicator(ConnectionSource source){
}
/**
* Initialize database
*/
private void initializeDatabase() {
/** Receive some data from the client and return a response
* @param socket - the client socket */
private void receiveAndSendData(Socket socket){
}
/** Initialize database
* @return the database connection source */
private ConnectionSource initializeDatabase(){
return null;
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.j256.ormlite.support.ConnectionSource;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class ServerServiceCommunicator {
/** Database connection source */
@NonNull
private ConnectionSource databaseConnectionSource;
/** Take a request from the client side, pass it through the services
* and return a response
* @return the server's response to the client's request */
public String getResponse(String request){
return null;
}
/** Send the client his ship
* @param username - the client's username
* @return the client's ship */
public Ship getClientShip(String username){
return null;
}
/** Login
* @param username - the user that wants to login
* @return if the client is allowed to login */
public String login(String username){
return null;
}
}
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.Weapons.Weapon;
import lombok.*;
@Getter
@Setter
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class BattleService {
/** List of ships participating in the fight */
@NonNull
private List<Ship> participants;
/** The ship which's round it is */
private Ship currentRound;
/** Change the ship which's round it is */
public void nextRound(){}
/** 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 */
private boolean validMove(Ship s){
return false;
}
/** Make one ship attack another's section
* @param attacker - the attacking ship
* @param opponent - the opponent's ship
* @param weapon - the weapon attacking */
private void attack(Ship attacker, Ship opponent, Weapon weapon){}
/** Heal a ship
* @param ship - the ship to heal
* @param healingWeapon - the healing weapon */
private void heal(Ship ship,Weapon healingWeapon){}
/** Flee a fight, reward the winner
* @param coward - the ship that wants to flee
* @param opponent - the opponent that wins the fight */
private void fleeFight(Ship coward, Ship opponent){}
/** Give winner reward and end the fight (or the game)
* @param loser - the ship that lost
* @param victor - the ship that won */
private void endFight(Ship loser, Ship victor){}
/** Receive data from server and turn into valid battle move
* @param s - the string to turn to battle moves
* @return the outcome of the battle moves as a string command */
public String applyBattleMoves(String s){
return null;
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.PlanetEvent;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO;
import lombok.*;
@Getter
@Setter
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class PlanetEventService {
/** Type of planet event currently happening */
@NonNull
private Enum<PlanetEvent> currentEvent;
/** Ship DAO */
@NonNull
private ShipDAO shipDAO;
/** Round counter (meteorShower/Nebula) */
private int roundCounter = 0;
/** Give the player some coins
* @param s - the ship to give coins to
* @param amount - amount of coins to add */
public void giveCoins(Ship s,int amount){}
/** Take coins away from player
* @param s - the ship to remove coins from
* @param amount - the amount of coins to remove */
public void removeCoins(Ship s,int amount){}
/** Give the player a weapon as loot
* @param s - the ship to give the reward to
* @param weapons - list of possible drops */
public void giveWeapon(Ship s, List<Weapon> weapons){}
/** Trader shop
* @return a list of all available stock */
public List<Weapon> getTraderStock(){
return null;
}
/** MeteorShower damage
* @param s - the player in the meteorShower */
private void meteorShower(Ship s){}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
public class RewardService {
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Planet;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO;
import lombok.*;
/** Used to move user from one star to another */
@Getter
@Setter
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class TravelService {
/** ShipDAO for database access */
@NonNull
private ShipDAO shipDAO;
/** Validate the travel request
* @param s - the ship that wisches to travel
* @return true if the travel request is valid */
public boolean validateJump(Ship s){
return false;
}
/** Jump ship from one star to another
* @param s - the ship to jump
* @param dest - the destination star */
public void jump(Ship s, Planet dest){}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment