Android Open Source - Freebloks-Android Spielleiter






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.controller;
//from w w  w  .  j  av  a  2  s .c  om
import java.io.Serializable;
import java.util.Arrays;

import de.saschahlusiak.freebloks.model.Player;
import de.saschahlusiak.freebloks.model.Spiel;
import de.saschahlusiak.freebloks.model.Stone;
import de.saschahlusiak.freebloks.model.Turn;
import de.saschahlusiak.freebloks.model.Turnpool;

public class Spielleiter extends Spiel implements Cloneable, Serializable {
  private static final long serialVersionUID = -7880809258246268794L;

  static final int PLAYER_COMPUTER = -2;
  static final int PLAYER_LOCAL = -1;

  int m_current_player;
  int spieler[] = new int[Spiel.PLAYER_MAX];
  public GameMode m_gamemode;
  boolean finished = false;
  boolean started = false;

  Turnpool history;

  public Spielleiter(int size_y, int size_x) {
    super(size_y, size_x);
    m_current_player=-1;
    m_gamemode = GameMode.GAMEMODE_4_COLORS_4_PLAYERS;
    for (int i=0;i<PLAYER_MAX;i++)spieler[i]=PLAYER_COMPUTER;
    history=new Turnpool();
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    Spielleiter c = (Spielleiter)super.clone();
    c.spieler = spieler.clone();
    c.history = new Turnpool();
    return c;
  }

  void set_noplayer() {
    m_current_player=-1;
  }

  public int current_player() {
    return m_current_player;
  }

  public Player get_current_player() {
    if (m_current_player == -1)
      return null;
    else
      return get_player(m_current_player);
  }

  GameMode get_gamemode() {
    return m_gamemode;
  }

  void addHistory(Turn turn)
  {
    history.add_turn(turn);
  }

  void addHistory(int player, Stone stone, int y, int x)
  {
    history.add_turn(player, stone, y, x);
  }

  int num_players()
  {
    int n;
    n=0;
    for (int i=0;i<PLAYER_MAX;i++)if (spieler[i]!=PLAYER_COMPUTER)n++;
    return n;
  }

  /**
   * Gibt true zurueck, wenn der Spieler kein Computerspieler ist
   **/
  public boolean is_local_player(int player) {
    /*
     * Bei keinem aktuellem Spieler, ist der aktuelle natuerlich nicht
     * lokal.
     */
    if (player == -1)
      return false;
    return (spieler[player] != Spielleiter.PLAYER_COMPUTER);
  }

  public boolean is_local_player() {
    return is_local_player(m_current_player);
  }

  public boolean isFinished() {
    return finished;
  }

  public void setFinished(boolean finished) {
    this.finished = finished;
  }

  public boolean isStarted() {
    return started;
  }

  public void setStarted(boolean started) {
    this.started = started;
  }

  public PlayerData[] getResultData() {
    PlayerData[] data;
    int i;
    switch (m_gamemode) {
    case GAMEMODE_2_COLORS_2_PLAYERS:
    case GAMEMODE_DUO:
    case GAMEMODE_JUNIOR:
      data = new PlayerData[2];
      data[0] = new PlayerData(this, 0);
      data[1] = new PlayerData(this, 2);
      break;

    case GAMEMODE_4_COLORS_2_PLAYERS:
      data = new PlayerData[2];
      data[0] = new PlayerData(this, 0, 2);
      data[1] = new PlayerData(this, 1, 3);
      break;

    case GAMEMODE_4_COLORS_4_PLAYERS:
    default:
      data = new PlayerData[4];
      data[0] = new PlayerData(this, 0);
      data[1] = new PlayerData(this, 1);
      data[2] = new PlayerData(this, 2);
      data[3] = new PlayerData(this, 3);
      break;
    }

    Arrays.sort(data);
    int place;
    for (i = 0; i < data.length; i++) {
      place = i + 1;
      if (i > 0) {
        if (data[i].compareTo(data[i-1]) == 0)
          place = data[i-1].place;
      }

      data[i].place = place;
    }
    return data;
  }
}




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