Android Open Source - Freebloks-Android Player






From Project

Back to project page Freebloks-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project Freebloks-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.saschahlusiak.freebloks.model;
//from  w  w  w . j  a  v  a2 s  .  c  om
import java.io.Serializable;

public class Player implements Serializable, Cloneable {
  private static final long serialVersionUID = -7320011705508155304L;

  public int m_stone_points;
  public int m_stone_count;
  public int m_number_of_possible_turns;
  int m_position_points;

  int m_teammate;
  int m_nemesis;
  int m_number;

  Stone m_stone[] = new Stone[Stone.STONE_COUNT_ALL_SHAPES];
  public Stone m_lastStone;

  public Player() {
    for (int i = 0; i < Stone.STONE_COUNT_ALL_SHAPES; i++){
      m_stone[i] = new Stone();
    }
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    Player c = (Player) super.clone();
    c.m_stone = m_stone.clone();
    for (int i = 0; i < Stone.STONE_COUNT_ALL_SHAPES; i++)
      c.m_stone[i] = (Stone)m_stone[i].clone();
    return c;
  }

  void init(Spiel spiel, int playernumber){
    m_number = playernumber;
    for (int i = 0; i < Stone.STONE_COUNT_ALL_SHAPES; i++){
      m_stone[i].init(i);
    }
    refresh_data(spiel);
  }

  public final void copyFrom(Player from) {
    this.m_stone_points = from.m_stone_points;
    this.m_stone_count = from.m_stone_count;
    this.m_number_of_possible_turns = from.m_number_of_possible_turns;
    this.m_position_points = from.m_position_points;
    this.m_teammate = from.m_teammate;
    this.m_nemesis = from.m_nemesis;
    this.m_number = from.m_number;
    for (int i = 0; i < m_stone.length; i++) {
      this.m_stone[i].copyFrom(from.m_stone[i]);
    }
  }

  public int getPlayerNumber() {
    return m_number;
  }

  final public Stone get_stone(int n) {
    if (n < 0 || n > m_stone.length)
      return null;
    return m_stone[n];
  }

  void set_teammate(int player) {
    m_teammate = player;
  }

  void set_nemesis(int player) {
    m_nemesis = player;
  }


  void refresh_data(Spiel spiel){
    m_stone_points = 0;
    m_number_of_possible_turns = 0;
    m_position_points = 0;
    m_stone_count = 0;

    for (int n = 0; n < Stone.STONE_COUNT_ALL_SHAPES; n++){
      Stone stone = m_stone[n];
      m_stone_count += stone.get_available();
    }

    for (int x = 0; x < spiel.m_field_size_x; x++){
      for (int y = 0; y < spiel.m_field_size_y; y++){
        if (spiel.get_game_field(m_number, y, x) == Stone.FIELD_ALLOWED){
          int turns_in_pos = 0;
          for (int n = 0; n < Stone.STONE_COUNT_ALL_SHAPES; n++){
            Stone stone = m_stone[n];
            if (stone.get_available() > 0){
              int turns;

              turns = stone.calculate_possible_turns_in_position(spiel, m_number, y, x);
              turns_in_pos += turns;
              m_position_points += turns * stone.get_stone_position_points() * stone.get_stone_points();
            }
          }
          m_number_of_possible_turns += turns_in_pos;
          if (turns_in_pos == 0) {
            /* there is no available turn in this position. mark as not allowed */
            spiel.set_field_free_bit(m_number, y, x);
          }
        } else if (spiel.get_game_field(y, x) == m_number)
          m_stone_points++;
      }
    }
    if (m_stone_count == 0 && m_lastStone != null) {
      m_stone_points += 15;
      if (m_lastStone.m_shape == 0)
        m_stone_points += 5;
    }
  }
}




Java Source Code List

com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
de.saschahlusiak.freebloks.AboutActivity.java
de.saschahlusiak.freebloks.Global.java
de.saschahlusiak.freebloks.backup.FreebloksBackupAgent.java
de.saschahlusiak.freebloks.controller.GameMode.java
de.saschahlusiak.freebloks.controller.JNIServer.java
de.saschahlusiak.freebloks.controller.PlayerData.java
de.saschahlusiak.freebloks.controller.SpielClientInterface.java
de.saschahlusiak.freebloks.controller.SpielClient.java
de.saschahlusiak.freebloks.controller.Spielleiter.java
de.saschahlusiak.freebloks.database.FreebloksDBOpenHandler.java
de.saschahlusiak.freebloks.database.FreebloksDB.java
de.saschahlusiak.freebloks.database.HighscoreDB.java
de.saschahlusiak.freebloks.donate.DonateActivity.java
de.saschahlusiak.freebloks.game.ActivityInterface.java
de.saschahlusiak.freebloks.game.AddScoreTask.java
de.saschahlusiak.freebloks.game.CustomGameDialog.java
de.saschahlusiak.freebloks.game.FreebloksActivity.java
de.saschahlusiak.freebloks.game.GameFinishActivity.java
de.saschahlusiak.freebloks.game.GameMenu.java
de.saschahlusiak.freebloks.game.RateAppDialog.java
de.saschahlusiak.freebloks.game.RetainedConfig.java
de.saschahlusiak.freebloks.game.SpielClientThread.java
de.saschahlusiak.freebloks.lobby.ChatEntry.java
de.saschahlusiak.freebloks.lobby.ChatListAdapter.java
de.saschahlusiak.freebloks.lobby.ColorAdapter.java
de.saschahlusiak.freebloks.lobby.LobbyDialog.java
de.saschahlusiak.freebloks.model.Player.java
de.saschahlusiak.freebloks.model.Spiel.java
de.saschahlusiak.freebloks.model.Stone.java
de.saschahlusiak.freebloks.model.Turn.java
de.saschahlusiak.freebloks.model.Turnpool.java
de.saschahlusiak.freebloks.network.NET_CHAT.java
de.saschahlusiak.freebloks.network.NET_CURRENT_PLAYER.java
de.saschahlusiak.freebloks.network.NET_GAME_FINISH.java
de.saschahlusiak.freebloks.network.NET_GRANT_PLAYER.java
de.saschahlusiak.freebloks.network.NET_HEADER.java
de.saschahlusiak.freebloks.network.NET_REQUEST_GAME_MODE.java
de.saschahlusiak.freebloks.network.NET_REQUEST_HINT.java
de.saschahlusiak.freebloks.network.NET_REQUEST_PLAYER.java
de.saschahlusiak.freebloks.network.NET_REQUEST_UNDO.java
de.saschahlusiak.freebloks.network.NET_REVOKE_PLAYER.java
de.saschahlusiak.freebloks.network.NET_SERVER_STATUS.java
de.saschahlusiak.freebloks.network.NET_SET_STONE.java
de.saschahlusiak.freebloks.network.NET_START_GAME.java
de.saschahlusiak.freebloks.network.NET_UNDO_STONE.java
de.saschahlusiak.freebloks.network.Network.java
de.saschahlusiak.freebloks.preferences.AboutFragment.java
de.saschahlusiak.freebloks.preferences.DisplayFragment.java
de.saschahlusiak.freebloks.preferences.FreebloksPreferences.java
de.saschahlusiak.freebloks.preferences.InterfaceFragment.java
de.saschahlusiak.freebloks.preferences.MiscFragment.java
de.saschahlusiak.freebloks.preferences.StatisticsFragment.java
de.saschahlusiak.freebloks.preferences.ThemePreference.java
de.saschahlusiak.freebloks.stats.StatisticsActivity.java
de.saschahlusiak.freebloks.stats.StatisticsAdapter.java
de.saschahlusiak.freebloks.view.BackgroundRenderer.java
de.saschahlusiak.freebloks.view.BoardRenderer.java
de.saschahlusiak.freebloks.view.Freebloks3DView.java
de.saschahlusiak.freebloks.view.FreebloksRenderer.java
de.saschahlusiak.freebloks.view.SimpleModel.java
de.saschahlusiak.freebloks.view.effects.AbsEffect.java
de.saschahlusiak.freebloks.view.effects.AbsStoneEffect.java
de.saschahlusiak.freebloks.view.effects.BoardStoneGlowEffect.java
de.saschahlusiak.freebloks.view.effects.EffectSet.java
de.saschahlusiak.freebloks.view.effects.Effect.java
de.saschahlusiak.freebloks.view.effects.PhysicalStoneEffect.java
de.saschahlusiak.freebloks.view.effects.StoneFadeEffect.java
de.saschahlusiak.freebloks.view.effects.StoneRollEffect.java
de.saschahlusiak.freebloks.view.effects.StoneUndoEffect.java
de.saschahlusiak.freebloks.view.model.Board.java
de.saschahlusiak.freebloks.view.model.CurrentStone.java
de.saschahlusiak.freebloks.view.model.Intro.java
de.saschahlusiak.freebloks.view.model.Sounds.java
de.saschahlusiak.freebloks.view.model.Theme.java
de.saschahlusiak.freebloks.view.model.ViewElement.java
de.saschahlusiak.freebloks.view.model.ViewModel.java
de.saschahlusiak.freebloks.view.model.Wheel.java