Tried tu debug without success :C. Now thinking of unicorns to be happier :D
This commit is contained in:
parent
47797fc963
commit
2b938b68f9
@ -0,0 +1,31 @@
|
||||
package AttackInformations;
|
||||
|
||||
public class AttackInformations{
|
||||
private int attack_field_dice;
|
||||
private int defense_field_dice;
|
||||
private boolean attack_success;
|
||||
private boolean attack_allowed;
|
||||
|
||||
public AttackInformations(int input_att_field, int input_def_field,boolean input_attack_allowed){
|
||||
attack_field_dice = input_att_field;
|
||||
defense_field_dice = input_def_field;
|
||||
attack_success = (input_att_field >= input_def_field);
|
||||
attack_allowed = input_attack_allowed;
|
||||
}
|
||||
|
||||
public int get_attack_field_dice(){
|
||||
return attack_field_dice;
|
||||
}
|
||||
|
||||
public int get_defense_field_dice(){
|
||||
return defense_field_dice;
|
||||
}
|
||||
|
||||
public boolean get_attack_success(){
|
||||
return attack_success;
|
||||
}
|
||||
|
||||
public boolean get_attack_allowed(){
|
||||
return attack_allowed;
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
package Field;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Player;
|
@ -1,3 +1,5 @@
|
||||
package Field.Player;
|
||||
|
||||
public class Player{
|
||||
private String name;
|
||||
private int playerid;
|
@ -1,10 +1,13 @@
|
||||
import Player;
|
||||
import Field;
|
||||
package Manager;
|
||||
|
||||
import Field.Field;
|
||||
import Player.Player;
|
||||
import AttackInformations.AttackInformations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class Max{
|
||||
class Max{
|
||||
private int max;
|
||||
|
||||
public Max(int num1, int num2){
|
||||
@ -16,41 +19,11 @@ public class Max{
|
||||
}
|
||||
}
|
||||
|
||||
public get_max(){
|
||||
public int get_max(){
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
public class AttackInformations{
|
||||
private int attack_field_dice;
|
||||
private int defense_field_dice;
|
||||
private boolean attack_success;
|
||||
private boolean attack_allowed;
|
||||
|
||||
public AttackInformations(int input_att_field, int input_def_field,boolean input_attack_allowed){
|
||||
attack_field_dice = input_att_field;
|
||||
defense_field_dice = input_def_field;
|
||||
attack_success = (input_att_field >= input_def_field);
|
||||
attack_allowed = input_attack_allowed;
|
||||
}
|
||||
|
||||
public int get_attack_field_dice(){
|
||||
return attack_field_dice;
|
||||
}
|
||||
|
||||
public int get_defense_field_dice(){
|
||||
return defense_field_dice;
|
||||
}
|
||||
|
||||
public boolean get_attack_success(){
|
||||
return attack_success;
|
||||
}
|
||||
|
||||
public boolean get_attack_allowed(){
|
||||
return attack_allowed;
|
||||
}
|
||||
}
|
||||
|
||||
public class GameManager {
|
||||
private ArrayList<Field> fields;
|
||||
private ArrayList<Player> players;
|
||||
@ -69,12 +42,13 @@ public class GameManager {
|
||||
|
||||
public void add_player(String input){
|
||||
if(players.size() < 8){
|
||||
players.add(Player(input,players.size()));
|
||||
Player pl = new Player(input,players.size());
|
||||
players.add(pl);
|
||||
}
|
||||
}
|
||||
|
||||
public AttackInformations attack_field(Field att_field, Field def_field){
|
||||
boolean attack_allowed;
|
||||
boolean attack_allowed= false;
|
||||
boolean att_field_allowed = false;
|
||||
boolean def_field_allowed = false;
|
||||
|
||||
@ -95,6 +69,8 @@ public class GameManager {
|
||||
|
||||
attack_allowed = att_field_allowed && def_field_allowed && attack_allowed;
|
||||
|
||||
AttackInformations infor;
|
||||
|
||||
if(attack_allowed){
|
||||
int att_field_sum = 0;
|
||||
int def_field_sum = 0;
|
||||
@ -106,17 +82,21 @@ public class GameManager {
|
||||
def_field_sum += 1 + rand_num_gen.nextInt(6);
|
||||
}
|
||||
|
||||
AttackInformations infor = new AttackInformations(att_field_sum, def_field_sum,true);
|
||||
infor = new AttackInformations(att_field_sum, def_field_sum,true);
|
||||
|
||||
if(infor.get_attack_success()){
|
||||
def_field.set_dice_number(Max(att_field.get_dice_number()-1,1).get_max());
|
||||
Max M = new Max(att_field.get_dice_number()-1,1);
|
||||
def_field.set_dice_number(M.get_max());
|
||||
|
||||
def_field.set_owner(att_field.get_owner());
|
||||
}
|
||||
att_field.set_dice_number(1);
|
||||
}
|
||||
else{
|
||||
infor = new AttackInformations(-1,-1,false);
|
||||
}
|
||||
|
||||
return AttackInformations(-1,-1,false);
|
||||
return infor;
|
||||
}
|
||||
|
||||
public ArrayList<Field> get_fields(){
|
16
server/game-logic/Manager/Test.java
Normal file
16
server/game-logic/Manager/Test.java
Normal file
@ -0,0 +1,16 @@
|
||||
import Manager.GameManager;
|
||||
import Player.Player;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args){
|
||||
GameManager gm = new GameManager();
|
||||
gm.add_player("Sebastian");
|
||||
gm.add_player("Lars");
|
||||
gm.add_player("Nils");
|
||||
gm.add_player("Felix");
|
||||
|
||||
for(Player current:gm.get_players()){
|
||||
System.out.println(current);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,15 @@
|
||||
import GameManager.*;
|
||||
import Manager.GameManager;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args){
|
||||
Random rand_num = new Random();
|
||||
System.out.println(Integer.toString(rand_num.nextInt(2)));
|
||||
GameManager gm = new GameManager();
|
||||
gm.add_player("Sebastian");
|
||||
gm.add_player("Lars");
|
||||
gm.add_player("Nils");
|
||||
gm.add_player("Felix");
|
||||
|
||||
for(Player current:gm.get_players()){
|
||||
System.out.println(current);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user