Skip to content

Commit

Permalink
v0.00
Browse files Browse the repository at this point in the history
  • Loading branch information
jmein committed Nov 28, 2011
1 parent 1f65efa commit fb7a373
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 54 deletions.
8 changes: 8 additions & 0 deletions Adult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

abstract class Adult extends Hero{

Adult(String nomen, Square start, boolean[] character){
super(nomen,3,start, character);
}

}
38 changes: 36 additions & 2 deletions Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,30 @@ class Board{
private Square[][] grid;
private ArrayList<Hero> heroes;
private ArrayList<Undead> zombies;
private int hDeath;
private int zDeath;
private int zPool;

Board(int xLong, int yLong){
this.grid = new Square[xLong][yLong];
//random board
}

Board(){
this.grid = new Square[4][4];
for(int i=0; i<4; i++){
for (int j=0; j<4; j++){
this.grid[i][j] = new Square(i,j,Board.rcEd(i,j,3,3),this);
}
}
grid[1][1]=grid[1][2]=grid[2][1]=grid[2][2]= new LargeSquare(1,1,Board.lgEd(),this);
}

Board(int n){ //square exterior board for mechanics testing
this.grid = new Square[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
grid[i][j] = new Square(i,j,Board.rectEdge(i,j,n-1,n-1),this);
this.grid[i][j] = new Square(i,j,Board.rcEd(i,j,n-1,n-1),this);
}
}
this.heroes = new ArrayList<Hero>();
Expand All @@ -26,15 +39,36 @@ class Board{
//generate board with given corners, center
}

Hero hero(int index){return this.heroes.get(index);}
Undead zed(int index){return this.zombies.get(index);}

void rem(Hero human){this.heroes.remove(human);}
void rem(Undead zed){this.zombies.remove(zed);}
void add(Hero human){this.heroes.add(human);}
void add(Undead zed){this.zombies.add(zed);}
void kill(Hero human){
hDeath++;
this.rem(human);
}
void kill(Undead zed){
zDeath++;
this.rem(zed);
}

Square sqAt(int x, int y){
return this.grid[x][y];
}

private static int[] rectEdge(int x, int y, int maxX, int maxY){
private static int[] lgEd(){
int[] arr = new int[13];
arr[0]=0;
for(int i=1; i<13; i++){
arr[i]=1;
}
return arr;
}

private static int[] rcEd(int x, int y, int maxX, int maxY){
int[] arr = new int[9];
arr[0] = 0;
for(int i=1; i<9; i++){
Expand Down
13 changes: 13 additions & 0 deletions Captain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

class Captain extends Hero{

private static boolean[] traits = {false,false,false,true,false,false};
Captain(Board town){
super("Captain Awesomepants", 4, Captain.spawn(town), Captain.traits);
}

static Square spawn(Board town){
return town.sqAt(0,0);
}

}
13 changes: 13 additions & 0 deletions Clumsy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

class Clumsy extends Adult{

private static boolean[] traits = {false,false,false,false,true,false};
Clumsy(Board town){
super("Clumsy",Clumsy.spawn(town),Clumsy.traits);
}

static Square spawn(Board town){
return town.sqAt(0,0);
}

}
11 changes: 10 additions & 1 deletion Figure.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@ abstract class Figure{
private int fDice;
private Square here;
private boolean[] thru;
private Board town;

Figure(String nomen, int healths, int dices, Square where, boolean[] move){
Figure(String nomen,int healths,int dices,Square where,boolean[] move){
this.name = nomen;
this.hp = this.maxHP = healths;
this.fDice = dices;
this.here = where;
this.thru = move;
this.town = where.isIn();
}

String tag(){return this.name;}
int[] hasHP(){int[] healths = {this.hp, this.maxHP};return healths;}
int dices(){return this.fDice;}
Square isAt(){return this.here;}
Board isIn(){return this.town;}

void heal(){this.hp = maxHP;}
void heal(int pts){
if(this.hp + pts < maxHP) this.hp = (this.hp + pts);
else this.heal();
}

void moveTo(Square dest){
//sounds good;
Expand Down
38 changes: 20 additions & 18 deletions Hero.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@

class Hero extends Figure{

private boolean winTie;
private boolean young;
private boolean fm;
private boolean mil;
private boolean med;
private boolean holy;
private boolean strg;

Hero(String nomen, int healths, Square start){
super(nomen, healths, 2, start, Hero.thru());
abstract class Hero extends Figure{

private static boolean[] thru = {false,true,true,false,false};
private boolean[] trait; // fm, holy, med, mil, strg, wT

Hero(String nomen, int healths, Square start, boolean[] character){
super(nomen, healths, 2, start, Hero.thru);
start.add(this);
start.city().add(this);
this.isIn().add(this);
this.trait = character;
}

static boolean[] thru(){
boolean[] answer = {false,true,true,false,false};
return answer;
boolean trt(int index){return this.trait[index];}
void mkTrt(int index, boolean maybe){this.trait[index]=maybe;}

void mvTo(int dir){
Square origin = this.isAt();
if(this.moveDir(dir)){
origin.rem(this);
this.isAt().add(this);
}
}

void dies(){
System.out.println(this.tag() + " dies...");
new ZombieHero(this);
this.isAt().rem(this);
this.isAt().city().rem(this);
this.isAt().isIn().kill(this);
}

void fight(Undead zed){
int[] hd = this.fRoll();
int[] zd = zed.fRoll();

if( (hd[0] > zd[0]) || ( (hd[0] == zd[0]) && this.winTie) ){
if( (hd[0] > zd[0]) || ( (hd[0] == zd[0]) && this.trt(5)) ){
System.out.println(this.tag() + " beats " + zed.tag() + "!");
if( Dice.hasDubs(hd) ) zed.wound();
}
Expand Down
24 changes: 12 additions & 12 deletions LargeSquare.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class LargeSquare extends Square{
}

Square inDir(int dir){ //replace old function b/c more edges
if(dir==12) return this.city().sqAt(this.x()+2, this.y());
else if(dir==11) return this.city().sqAt(this.x()+2, this.y()-1);
else if(dir==10) return this.city().sqAt(this.x()+1, this.y()-1);
else if(dir==9) return this.city().sqAt(this.x(), this.y()-1);
else if(dir==8) return this.city().sqAt(this.x()-1, this.y()-1);
else if(dir==7) return this.city().sqAt(this.x()-1, this.y());
else if(dir==6) return this.city().sqAt(this.x()-1, this.y()+1);
else if(dir==5) return this.city().sqAt(this.x()-1, this.y()+2);
else if(dir==4) return this.city().sqAt(this.x(), this.y()+2);
else if(dir==3) return this.city().sqAt(this.x()+1, this.y()+2);
else if(dir==2) return this.city().sqAt(this.x()+2, this.y()+2);
else if(dir==1) return this.city().sqAt(this.x()+2, this.y()+1);
if(dir==12) return this.isIn().sqAt(this.x()+2, this.y());
else if(dir==11) return this.isIn().sqAt(this.x()+2, this.y()-1);
else if(dir==10) return this.isIn().sqAt(this.x()+1, this.y()-1);
else if(dir==9) return this.isIn().sqAt(this.x(), this.y()-1);
else if(dir==8) return this.isIn().sqAt(this.x()-1, this.y()-1);
else if(dir==7) return this.isIn().sqAt(this.x()-1, this.y());
else if(dir==6) return this.isIn().sqAt(this.x()-1, this.y()+1);
else if(dir==5) return this.isIn().sqAt(this.x()-1, this.y()+2);
else if(dir==4) return this.isIn().sqAt(this.x(), this.y()+2);
else if(dir==3) return this.isIn().sqAt(this.x()+1, this.y()+2);
else if(dir==2) return this.isIn().sqAt(this.x()+2, this.y()+2);
else if(dir==1) return this.isIn().sqAt(this.x()+2, this.y()+1);
else return this;
}

Expand Down
27 changes: 27 additions & 0 deletions Lucky.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.util.Scanner;

class Lucky extends Student{
static private boolean traits[] = {true,false,false,false,false,false};
Lucky(Board town){
super("Lucky",Student.spawn(town), Lucky.traits);
}
static Square spawn(Board town){
return town.sqAt(0,0);
}

void fight(Undead zed){
int[] hd = this.fRoll();
int[] zd = zed.fRoll();

System.out.println("Force reroll?(#truth) ");
if( new Scanner(System.in).nextInt() != 0 ) zd = zed.fRoll();
if( (hd[0] > zd[0]) || ( (hd[0] == zd[0]) && this.trt(5)) ){
System.out.println(this.tag() + " beats " + zed.tag() + "!");
if( Dice.hasDubs(hd) ) zed.wound();
}
else{
System.out.println(zed.tag() + " beats " + this.tag() + "...");
this.wound();
}
}
}
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ lastnight emulates the board game "Last Night on Earth, the Zombie Game", create

v0.0

2011.11.26:
Hero abstracted. abstract children Student and Adult give basic division of
Heroes. Individual characters get own classes.
Lucky, Speedy, Clumsy, Captain Awesomepants classes exist.

2011.11.20:
variables privatized.
Undead abstract-general zombie-children ZombieHero and StdZombie
Expand Down
9 changes: 9 additions & 0 deletions Speedy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class Speedy extends Student{

static private boolean[] traits = {false,false,false,false,false,false};
Speedy(Board town){
super("Speedy",Student.spawn(town),Speedy.traits);
}

}
4 changes: 2 additions & 2 deletions Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int[] isAt(){
int x(){return this.x;}
int y(){return this.y;}
int zCt(){return this.zombies.size();}
Building isIn(){return this.house;}
Board city(){return this.town;}
Building isPt(){return this.house;}
Board isIn(){return this.town;}
int edge(int dir){return this.edge[dir];}
Undead zed(int index){return this.zombies.get(index);}

Expand Down
15 changes: 15 additions & 0 deletions Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

abstract class Student extends Hero{

Student(String nomen, Square start, boolean[] character){
super(nomen, 2, start, character);
}
static Square spawn(Board town){
return town.sqAt(0,0);
}

void rest(){
this.heal(1);
}

}
4 changes: 2 additions & 2 deletions Undead.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ abstract class Undead extends Figure{
Undead(String nomen, int healths, Square pit){
super(nomen, healths, 1, pit, Undead.thru());
pit.add(this);
pit.city().add(this);
pit.isIn().add(this);
}

static boolean[] thru(){
Expand All @@ -15,7 +15,7 @@ static boolean[] thru(){
void dies(){
System.out.println(this.tag() + " dies!");
this.isAt().rem(this);
this.isAt().city().rem(this);
this.isAt().isIn().kill(this);
}

}
Loading

0 comments on commit fb7a373

Please sign in to comment.