Package y3.players

Source Code of y3.players.Warrior

package y3.players;

import java.util.List;

import y3.fight.Fight;
import y3.playground.Board;
import y3.playground.Tile;
import y3.threadViz.ThreadViz;

/**
* S�dalase klass.
* M�ngija abstraktse klassi Player alamklass.
*
* @author Jaak Laanpere
*
*/
public class Warrior extends Player {

  /**
   * Konstruktor.
   *
   * @param name
   * @param board
   */
  public Warrior(String name, Board board) {
    super(name, board);
  }

  /**
   * Punasele m�nguv�ljale sisenemise meetod.
   * Kontrollib, kas m�nguv�ljal on koletisi.
   * Kui koletis satub m�ne teist t��pi m�ngijaga samale v�ljale, toimub v�itlus.
   *
   * Kui m�ngija on �ksi punasel v�ljal, on ta tegevusetu (h�ppab niisama).
   *
   */
  @Override
  public void enterRedTile(Tile t) {
    List<Player> players = t.getPlayers();
    if(players.isEmpty()){
      ThreadViz.addMessage(this, " hyppab kannatamatult yhelt jalalt teisele.");
    } else {
      for(Player p : players){
        if(!(p instanceof Monster)){
          players.remove(p);
        }
      }
      if (!players.isEmpty()) {
        Player opponent = players.get(0);
        Fight fight = new Fight(this, opponent, t);
      }
    }
  }

  /**
   * Valgele m�nguv�ljale sisenemise meetod.
   * Kui m�ngija pole saavutanud maksimaalset level'it,
   * siis harjutab m��gav�itlust ja saab k�rgema leveli.
   *
   */
  @Override
  public void enterWhiteTile(Tile t) {
    levelUp();
    if (level < MAXLEVEL) {
      ThreadViz.addMessage(this, "harjutab m��ga k�sitsemist, uus level: " + this.getLevel());
    } else {
      ThreadViz.addMessage(this, "Maksimaalne tase saavutatud.");
    }
  }

}
TOP

Related Classes of y3.players.Warrior

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.