Skip to content
Snippets Groups Projects
Commit 27ab5dc9 authored by Leonard Haddad's avatar Leonard Haddad :rocket:
Browse files

Merge branch 'model' into 'master'

added services, modified trader in model

See merge request reswp-2020/galaxytrucker!32
parents 1b8b2d01 c2eb9b17
No related branches found
No related tags found
No related merge requests found
Showing
with 256 additions and 29 deletions
......@@ -52,4 +52,8 @@ public class Planet implements Serializable {
@DatabaseField(foreign = true, columnName = "ships")
@NonNull
private List<Ship> ships;
/** Trader */
@DatabaseField(foreign = true)
private Trader trader;
}
package com.galaxytrucker.galaxytruckerreloaded.Model.Map;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew;
import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.*;
import java.io.Serializable;
@Getter
@Setter
@DatabaseTable
@DatabaseTable(tableName = "trader")
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor(access = AccessLevel.PUBLIC)
public class Trader extends Planet implements Serializable {
/** ID */
@DatabaseField(id = true)
private int id;
/** Associated user */
@DatabaseField
private String associatedUser;
/** Weapons for sale */
@DatabaseField(foreign = true)
@NonNull
private List<Weapon> weaponsForSale;
/** Rockets for sale */
@DatabaseField
@NonNull
private int rocketStock;
/** Fuel for sale */
@DatabaseField
@NonNull
private int fuelStock;
/** Crew for sale */
@DatabaseField(foreign = true)
@NonNull
private List<Crew> crewStock;
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Exception;
public class DuplicateTraderException extends Exception {
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Exception;
public class TraderNotFoundException extends Exception {
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Persistence;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Trader;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateTraderException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.TraderNotFoundException;
/**
* This class handles trader objects in the database
*/
public class TraderDAO extends ObjectDAO<Trader> {
/**
* Add a new trader to the database
*
* @param t - the trader to add
* @throws DuplicateTraderException if the trader already exists in the database
*/
@Override
public void persist(Trader t) throws DuplicateTraderException {
}
/**
* Edit an existing trader in the database
*
* @param t - the trader to edit
* @throws TraderNotFoundException if the trader cannot be found in the database
*/
public void edit(Trader t) throws TraderNotFoundException {
}
/**
* Remove an existing trader from the database
*
* @param t - the trader to remove
* @throws TraderNotFoundException if the trader cannot be found in the database
*/
@Override
public void remove(Trader t) throws TraderNotFoundException {
}
}
......@@ -42,6 +42,10 @@ public class BattleService {
/** Disabled system round counter */
private int disabledSystemCounter = 3;
/** Reward service */
@NonNull
private RewardService rewardService;
/** Change the ship which's round it is */
public void nextRound(){}
......
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.PlanetEvent;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
......@@ -10,6 +11,7 @@ import lombok.*;
@Getter
@Setter
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor(access = AccessLevel.PUBLIC)
public class PlanetEventService {
/** Type of planet event currently happening */
......@@ -20,6 +22,9 @@ public class PlanetEventService {
@NonNull
private ShipDAO shipDAO;
/** RewardService */
private RewardService rewardService;
/** Round counter (meteorShower/Nebula) */
private int roundCounter = 0;
......@@ -33,18 +38,17 @@ public class PlanetEventService {
* @param amount - the amount of coins to remove */
public void removeCoins(Ship s,int amount){}
/** Give the player a weapon as loot
/** Give the player some 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;
}
* @param dropTable - list of possible drops
* @param crewDropTable - list of possible crew drops */
public void giveLoot(Ship s, List<Weapon> dropTable, List<Crew> crewDropTable){}
/** MeteorShower damage
* @param s - the player in the meteorShower */
private void meteorShower(Ship s){}
/** Disable systems when in nebula
* @param s - the ship which's systems to disable */
public void disableSystemsInNebula(Ship s, int duration){}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.CrewDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.RoomDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.WeaponDAO;
import lombok.*;
/** This class handles reward handing to players */
/**
* This class handles reward handing to players
*/
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
@Getter
@Setter
public class RewardService {
/** ShipDAO */
/**
* ShipDAO
*/
@NonNull
private ShipDAO shipDAO;
/** WeaponDAO */
/**
* WeaponDAO
*/
@NonNull
private WeaponDAO weaponDAO;
/** Weapon reward
* @param s - the ship to give reward to
/**
* Room DAO
*/
@NonNull
private RoomDAO roomDAO;
/**
* Crew DAO
*/
@NonNull
private CrewDAO crewDAO;
/**
* Weapon reward
*
* @param s - the ship to give reward to
* @param dropTable - possible weapon drops
* @return the weapon given */
public Weapon weaponReward(Ship s, List<Weapon> dropTable){
* @return the weapon given
*/
public Weapon weaponReward(Ship s, List<Weapon> dropTable) {
return null;
}
/** Coin reward
/**
* Coin reward
*
* @param s - the ship to give reward to
* @param c - the coins to give it */
public void coinsReward(Ship s, int c){
* @param c - the coins to give it
*/
public void coinsReward(Ship s, int c) {
}
/** Fuel reward
/**
* Fuel reward
*
* @param s - the ship to give reward to
* @param f - the fuel to give it*/
public void fuelReward(Ship s,int f){
* @param f - the fuel to give it
*/
public void fuelReward(Ship s, int f) {
}
/** Rocket reward
/**
* Rocket reward
*
* @param s - the ship to give reward to
* @param r - the rockets to give it */
public void rocketReward(Ship s,int r){
* @param r - the rockets to give it
*/
public void rocketReward(Ship s, int r) {
}
/**
* Give the player a crew member as reward
*
* @param s - the ship to give the reward to
* @param crew - a list of possible crew member drops
*/
public void crewReward(Ship s, List<Crew> crew) {
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.PlanetEvent;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Trader;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.CrewDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.TraderDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.WeaponDAO;
import lombok.*;
@Getter
@Setter
@RequiredArgsConstructor(access = AccessLevel.PUBLIC)
public class TraderService extends PlanetEventService {
/**
* Trader DAO
*/
@NonNull
private TraderDAO traderDAO;
/** WeaponDAO */
@NonNull
private WeaponDAO weaponDAO;
/** CrewDAO */
@NonNull
private CrewDAO crewDAO;
/**
* Validate purchase by checking if the client has enough money
*
* @param ship - the ship which's purchase to validate
* @param price - the price to pay in coins
* @return true if the ship has enough money else false
*/
public boolean validatePurchase(Ship ship, int price) {
return false;
}
/**
* Buy a weapon from the trader
*
* @param ship - the ship that wishes to buy the weapon
* @param trader - the trader to buy the weapon from
* @param weapon - the weapon to buy
*/
private void purchaseWeapon(Ship ship, Trader trader, Weapon weapon) {
}
/**
* Buy crew from a trader
*
* @param ship - the ship that wants to buy a crew member
* @param trader - the trader to buy from
* @param crew - the crew to buy
*/
public void purchaseCrew(Ship ship, Trader trader, Crew crew) {
}
/**
* Buy rockets from the trader
*
* @param ship - the ship hat wishes to buy rockets
* @param trader - the trader to buy from
* @param amount - the amount of rockets to buy
*/
public void purchaseRockets(Ship ship, Trader trader, int amount) {
}
/**
* Buy fuel from the trader
*
* @param ship - the ship that wants to buy stuff
* @param trader - the trader to buy from
* @param amount - the amount of fuel to buy
*/
public void purchaseFuel(Ship ship, Trader trader, int amount) {
}
/**
* Buy health from the trader
*
* @param ship - the ship that wishes to buy health
* @param trader - the trader to buy from
* @param amount - the amount to buy
*/
public void purchaseHP(Ship ship, Trader trader, int amount) {
}
}
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