Exemplo n.º 1
0
  public boolean startTurn() {
    iteration++;
    int count = 0;
    count = Client.INSTANCE.getBaseCount(connection);
    bases = new Base[count];
    for (int i = 0; i < count; i++) {
      bases[i] = new Base(Client.INSTANCE.getBase(connection, i));
    }
    count = Client.INSTANCE.getPlayerCount(connection);
    players = new Player[count];
    for (int i = 0; i < count; i++) {
      players[i] = new Player(Client.INSTANCE.getPlayer(connection, i));
    }
    count = Client.INSTANCE.getTileCount(connection);
    tiles = new Tile[count];
    for (int i = 0; i < count; i++) {
      tiles[i] = new Tile(Client.INSTANCE.getTile(connection, i));
    }
    count = Client.INSTANCE.getVirusCount(connection);
    viruses = new Virus[count];
    for (int i = 0; i < count; i++) {
      viruses[i] = new Virus(Client.INSTANCE.getVirus(connection, i));
    }

    if (!initialized) {
      initialized = true;
      init();
    }
    return run();
  }
Exemplo n.º 2
0
 // can use UI thread here
 protected void onPostExecute(final Boolean success) {
   if (this.dialog.isShowing()) {
     this.dialog.dismiss();
   }
   doOnUserChangedListener(m_Login, success);
   Client.INSTANCE.doOnUserChangedListener(m_Login, success);
   if (success) {
     Toast.makeText(mContext, "Вход выполнен", Toast.LENGTH_SHORT).show();
   } else {
     if (ex != null) Log.e(mContext, ex);
     else
       new AlertDialog.Builder(mContext)
           .setIcon(R.drawable.icon)
           .setTitle("Ошибка")
           .setMessage(Client.INSTANCE.getLoginFailedReason())
           .setPositiveButton(android.R.string.ok, null)
           .create()
           .show();
   }
 }
Exemplo n.º 3
0
    @Override
    protected Boolean doInBackground(String... params) {
      try {

        return Client.INSTANCE.logout();
      } catch (Exception e) {
        Log.e(mContext, e);
        ex = e;
        return false;
      }
    }
Exemplo n.º 4
0
    @Override
    protected Boolean doInBackground(String... params) {
      try {
        m_Login = params[0];
        m_Password = params[1];
        m_Privacy = Boolean.parseBoolean(params[2]);

        return Client.INSTANCE.login(m_Login, m_Password, m_Privacy);
      } catch (Exception e) {

        ex = e;
        return false;
      }
    }
Exemplo n.º 5
0
    @Override
    protected Boolean doInBackground(String... params) {
      try {
        Client.INSTANCE.loadUserReputation(
            m_Reputations,
            new Client.OnProgressChangedListener() {
              public void onProgressChanged(String state) {
                publishProgress(state);
              }
            });

        return true;
      } catch (Exception e) {

        ex = e;
        return false;
      }
    }
Exemplo n.º 6
0
 /**
  * 上传文件
  *
  * @param context 上下文
  * @param file 文件
  * @param uid 服务调用者
  * @param shareType 分享视频的类别
  * @param uploadToken 上传票据
  * @param desc 分享描述信息
  * @param param 服务器参数 例如 image audio video 等
  * @param responseHandler 响应处理
  * @param listener 网络异常监听
  */
 public void requestUploadFile(
     Context context,
     File file,
     String uid,
     int shareType,
     String uploadToken,
     String desc,
     String param,
     ResponseHandler responseHandler,
     Client.NetworkUnavailableListener listener) {
   ShareRequest share = new ShareRequest();
   share.setUid(uid);
   share.setShareType(shareType);
   share.setUploadToken(uploadToken);
   share.setDesc(desc);
   RequestParams params = new RequestParams();
   params.put(CONTENT, share.getContent());
   try {
     params.put(param, file);
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
   Client.INSTANCE.request(context, params, ShareRequest.PATH, responseHandler, listener);
 }
Exemplo n.º 7
0
  public boolean startTurn() {
    iteration++;
    int count = 0;
    count = Client.INSTANCE.getPlayerCount(connection);
    players = new Player[count];
    for (int i = 0; i < count; i++) {
      players[i] = new Player(Client.INSTANCE.getPlayer(connection, i));
    }
    count = Client.INSTANCE.getMappableCount(connection);
    mappables = new Mappable[count];
    for (int i = 0; i < count; i++) {
      mappables[i] = new Mappable(Client.INSTANCE.getMappable(connection, i));
    }
    count = Client.INSTANCE.getTileCount(connection);
    tiles = new Tile[count];
    for (int i = 0; i < count; i++) {
      tiles[i] = new Tile(Client.INSTANCE.getTile(connection, i));
    }
    count = Client.INSTANCE.getTrapCount(connection);
    traps = new Trap[count];
    for (int i = 0; i < count; i++) {
      traps[i] = new Trap(Client.INSTANCE.getTrap(connection, i));
    }
    count = Client.INSTANCE.getThiefCount(connection);
    thieves = new Thief[count];
    for (int i = 0; i < count; i++) {
      thieves[i] = new Thief(Client.INSTANCE.getThief(connection, i));
    }
    count = Client.INSTANCE.getThiefTypeCount(connection);
    thiefTypes = new ThiefType[count];
    for (int i = 0; i < count; i++) {
      thiefTypes[i] = new ThiefType(Client.INSTANCE.getThiefType(connection, i));
    }
    count = Client.INSTANCE.getTrapTypeCount(connection);
    trapTypes = new TrapType[count];
    for (int i = 0; i < count; i++) {
      trapTypes[i] = new TrapType(Client.INSTANCE.getTrapType(connection, i));
    }

    if (!initialized) {
      initialized = true;
      init();
    }
    return run();
  }
Exemplo n.º 8
0
 /// The number of sarcophagi each player will start with each round.
 int numberOfSarcophagi() {
   return Client.INSTANCE.getNumberOfSarcophagi(connection);
 }
Exemplo n.º 9
0
 /// What type this robot will be
 public Pointer getType() {
   validify();
   return Client.INSTANCE.frameGetType(ptr);
 }
Exemplo n.º 10
0
 /// The width of the map (max X value)
 int width() {
   return Client.INSTANCE.getWidth(connection);
 }
Exemplo n.º 11
0
 /// BaseCost used in the virus price formula
 int baseCost() {
   return Client.INSTANCE.getBaseCost(connection);
 }
Exemplo n.º 12
0
 /// Player Number; either 0 or 1 (0 is player 1, 1 is player 2)
 int playerID() {
   return Client.INSTANCE.getPlayerID(connection);
 }
Exemplo n.º 13
0
 /// The length of one side of this robot, such that size^2 = number of bots combined into this bot
 public int getSize() {
   validify();
   return Client.INSTANCE.frameGetSize(ptr);
 }
Exemplo n.º 14
0
 /// The width of the total map.
 int mapWidth() {
   return Client.INSTANCE.getMapWidth(connection);
 }
Exemplo n.º 15
0
 public Mappable(Pointer p) {
   ptr = p;
   ID = Client.INSTANCE.mappableGetId(ptr);
   iteration = BaseAI.iteration;
 }
Exemplo n.º 16
0
 /// The Y position of this object.  Y is vertical, with 0,0 as the top left corner
 public int getY() {
   validify();
   return Client.INSTANCE.mappableGetY(ptr);
 }
Exemplo n.º 17
0
 public Frame(Pointer p) {
   ptr = p;
   ID = Client.INSTANCE.frameGetId(ptr);
   iteration = BaseAI.iteration;
 }
Exemplo n.º 18
0
 /// How many of your turns until this frame becomes a robot
 public int getCompletionTime() {
   validify();
   return Client.INSTANCE.frameGetCompletionTime(ptr);
 }
Exemplo n.º 19
0
 /// The height of the total map.
 int mapHeight() {
   return Client.INSTANCE.getMapHeight(connection);
 }
Exemplo n.º 20
0
 /// The maximum number of Traps allowed per player.
 int maxTraps() {
   return Client.INSTANCE.getMaxTraps(connection);
 }
Exemplo n.º 21
0
 /// How many turns it has been since the beginning of the game
 int turnNumber() {
   return Client.INSTANCE.getTurnNumber(connection);
 }
Exemplo n.º 22
0
 /// What round of the game this is.
 int roundNumber() {
   return Client.INSTANCE.getRoundNumber(connection);
 }
Exemplo n.º 23
0
 /// What number game this is for the server
 int gameNumber() {
   return Client.INSTANCE.getGameNumber(connection);
 }
Exemplo n.º 24
0
 /// The scarabs given to a player to purchase thieves per round.
 int scarabsForThieves() {
   return Client.INSTANCE.getScarabsForThieves(connection);
 }
Exemplo n.º 25
0
 /// Scalar used in the virus price formula
 float scaleCost() {
   return Client.INSTANCE.getScaleCost(connection);
 }
Exemplo n.º 26
0
 /// The number of won rounds required to win.
 int roundsToWin() {
   return Client.INSTANCE.getRoundsToWin(connection);
 }
Exemplo n.º 27
0
 /// The height of the map (max Y value)
 int height() {
   return Client.INSTANCE.getHeight(connection);
 }
Exemplo n.º 28
0
 /// The maximum number of round turns before a winner is decided.
 int roundTurnLimit() {
   return Client.INSTANCE.getRoundTurnLimit(connection);
 }
Exemplo n.º 29
0
 /**
  * 取消请求
  *
  * @param context 上下文
  */
 public void cancelRequests(Context context) {
   Client.INSTANCE.cancelRequests(context, true);
 }
Exemplo n.º 30
0
 /// The maximum amount of health this unit can ever have
 public int getMaxHealth() {
   validify();
   return Client.INSTANCE.frameGetMaxHealth(ptr);
 }