second commit
This commit is contained in:
parent
56d08a6a6c
commit
870f5a4b8d
3 changed files with 44 additions and 3 deletions
9
src/de/sus/items/Item.java
Normal file
9
src/de/sus/items/Item.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package de.sus.items;
|
||||
|
||||
public abstract class Item {
|
||||
|
||||
|
||||
public Item() {
|
||||
|
||||
}
|
||||
}
|
28
src/de/sus/user/Player.java
Normal file
28
src/de/sus/user/Player.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package de.sus.user;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import de.sus.items.*;
|
||||
|
||||
public class Player {
|
||||
/** The player's username/display name */
|
||||
private String username;
|
||||
/** The player's inventory */
|
||||
private ArrayList<Item> inventory = new ArrayList<>;
|
||||
|
||||
public Player(String name) {
|
||||
this.username = name;
|
||||
}
|
||||
|
||||
public void addItem(Item item) {
|
||||
inventory.add(item);
|
||||
}
|
||||
|
||||
public boolean removeItem(Item item) {
|
||||
return inventory.remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.username;
|
||||
}
|
||||
}
|
|
@ -9,11 +9,16 @@ public class Board {
|
|||
/**
|
||||
* Constructor
|
||||
* @author Michael Rodin
|
||||
* @param size the radius of the boards aka. field count of the horizontal
|
||||
* @param size the radius of the boards aka. field count of the horizontal. Must be uneven
|
||||
*/
|
||||
public Board(int size) {
|
||||
if (size < 1) throw new IllegalArgumentException("The size must be 1 or higher!");
|
||||
if (size % 2 == 0) throw new IllegalArgumentException("The size must be uneven!");
|
||||
|
||||
this.initBoard(size);
|
||||
}
|
||||
|
||||
private void initBoard(int size) {
|
||||
this.boardfields = new Field[size][];
|
||||
|
||||
int i = size/2-1;
|
||||
|
@ -32,8 +37,7 @@ public class Board {
|
|||
Random random = new Random();
|
||||
for (Field[] k: this.boardfields) {
|
||||
for (Field j: k) {
|
||||
j = new Field(Resource.getRandom(), random.nextInt(12)+1);
|
||||
System.out.println(j);
|
||||
j = new Field(Resource.getRandom(), random.nextInt(12)+1); // TODO: improve resource logic?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue