Commits

Nikolaos Margaris  committed 271638c

... adding more on game and players

  • Participants
  • Parent commits a1ada6c

Comments (0)

Files changed (7)

File src/com/nima/Game.java

 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.Queue;
 
 public class Game {
 	
 		return gameEnded;
 	}
 	
-	public Pawn next(){
-		return null;
+	public Player next(){
+		return players.get(currentPlayerIndex);
 	}
 	
 	public void endCurrentTurn(){
 		return board.export();
 	}
 	
-	public void rollTurns(){
-		//TBD
+	public void rollTurns(){		
 	}
 	
-	public void createPlayers(){
-		//commit from android
+	public void showMoveMap(){		
+	}
+	
+	public void searchTreasure(Pawn pawn){		
+	}
+	
+	public void searchSecret(Pawn pawn){		
+	}
+	
+	public void searchTrap(Pawn pawn){		
+	}
+	
+	public void disarmTrap(Pawn pawn){		
 	}
 }

File src/com/nima/Hero.java

 	}
 
 	public boolean attack(Pawn other) {
+		if (other == null) return false;
 		int damage = rollAttack() - other.rollDefence();
 		if(damage > 0){
 			other.hit(damage);
 	public int getQuestsCompleted() {
 		return questsCompleted;
 	}
+
+	
+	public boolean hasMoved() {	
+		return false;
+	}
+
+	public boolean actionPerformed() {	
+		return false;
+	}
 	
 }

File src/com/nima/HeroQuest.java

 import java.io.UnsupportedEncodingException;
 import java.util.Properties;
 
+import com.nima.Pawn.STATE;
+
 public class HeroQuest {
 	public static void main(String[] args) {
 		System.out.println("Welcome to HeroQuest Engine!!!");
 			// Need to write down what each class should do from now on ... !!!
 			
 			//define turns
-			//...tbd
+			game.rollTurns();
 			
 			//simple logic to be implemented and tested
 			
 			game.begin();
 			
-			//1) check if game ended
+			// check if game ended
 			while(!game.isGameEnded()){				
 			
-			//2) who is next?
-				
-			//3) if player then goto :5 
-			//4) zargon plays
-			//5) check if next player is alive: on.yes then 'play' else goto :2
-			
-			//DM's play
-			//1) find active monsters
-			//2) decide monster's turn
-			//3) find next monster's visible heroes
-			//4) move monster to closest hero
-			//5) if not close then goto :7
-			//6) attack adjacent hero
-			//7) if monsters available then goto :3				
+				// who is next?
+				Player currentPlayer = game.next();
+				if(Player.XARGON.equals(currentPlayer.getName())){
+					/* DM's play
+					 * 1) find active monsters
+					 * 2) decide monster's turn
+					 * 3) find next monster's visible heroes
+					 * 4) move monster to closest hero
+					 * 5) if not close then goto :7
+					 * 6) attack adjacent hero
+					 * 7) if monsters available then goto :3 
+					 * */					
+				}else{					
+					//check if next player is alive: if yes then 'play'
+					if(currentPlayer.getActivePawn().getCurrentState() != STATE.DEAD){
+						
+						currentPlayer.getActivePawn().rollMovement();
+						
+						game.showMoveMap();
+						
+						boolean validMove = currentPlayer.getActivePawn().move(0, 0);
+						
+						game.searchTreasure(currentPlayer.getActivePawn());
+						game.searchSecret(currentPlayer.getActivePawn());
+						game.searchTrap(currentPlayer.getActivePawn());
+						game.disarmTrap(currentPlayer.getActivePawn());
+						
+						currentPlayer.getActivePawn().attack(null);						
+					}
+				}
+							
 				game.end();
 				game.endCurrentTurn();
 			}

File src/com/nima/HumanPlayer.java

 		this.activePawn = this.heroesOwned.size() - 1;
 	}
 
-	
-
 	public Object getCurrentMovePoints() {
 		return currentMovePoints;
 	}

File src/com/nima/Monster.java

 	public boolean attack(Pawn other) {
 		return false;
 	}
+
+	public boolean hasMoved() {
+		return false;
+	}
+
+	public boolean actionPerformed() {
+		return false;
+	}
 			
 }

File src/com/nima/Pawn.java

 	
 	protected int availableMovePoints = 0; //initialize
 		
-	public abstract boolean move(int toX, int toY);
-	public abstract boolean attack(Pawn other);
-	
 	protected void rollMovement(){
 		RedDice rd = new RedDice();
 		for(int i = 0; i <moveDice; i++){
 		}
 	}
 	
-	private int rollAttackDefence(Side side, int num){
+	protected int rollAttackDefence(Side side, int num){
 		int hits = 0;
 		WhiteDice white = new WhiteDice();
 		for(int i=0; i < num; i++){
 	public int getMovePoints(){
 		return availableMovePoints;
 	}
+	
+	
+	/*
+	 * Abstract Section
+	 */
+	
+	public abstract boolean move(int toX, int toY);
+	public abstract boolean attack(Pawn other);
+	public abstract boolean hasMoved();
+	public abstract boolean actionPerformed();
 }

File src/com/nima/Player.java

 package com.nima;
 
 public abstract class Player {
+	public static final String XARGON = "Xargon";
 	public enum Action {
 		ATTACK, CAST_SPELL, SEARCH_TREASURE, SEARCH_SECRET,
 		SEARCH_TRAP, DISARM_TRAP, NONE
 	public Action getCurrentAction() {
 		return currentAction;
 	}
-	public String getName(){
+	
+	public final String getName(){
 		return name;
 	}
 	
+	public final boolean isXargon(){
+		return XARGON.equals(name);
+	}
 	/*
 	 * Abstract Section
 	 */