Exemple #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();
  }
Exemple #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();
   }
 }
Exemple #3
0
    @Override
    protected Boolean doInBackground(String... params) {
      try {

        return Client.INSTANCE.logout();
      } catch (Exception e) {
        Log.e(mContext, e);
        ex = e;
        return false;
      }
    }
Exemple #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;
      }
    }
    @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;
      }
    }
 /**
  * 上传文件
  *
  * @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);
 }
Exemple #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();
  }
Exemple #8
0
 /// The number of sarcophagi each player will start with each round.
 int numberOfSarcophagi() {
   return Client.INSTANCE.getNumberOfSarcophagi(connection);
 }
Exemple #9
0
 /// What type this robot will be
 public Pointer getType() {
   validify();
   return Client.INSTANCE.frameGetType(ptr);
 }
Exemple #10
0
 /// The width of the map (max X value)
 int width() {
   return Client.INSTANCE.getWidth(connection);
 }
Exemple #11
0
 /// BaseCost used in the virus price formula
 int baseCost() {
   return Client.INSTANCE.getBaseCost(connection);
 }
Exemple #12
0
 /// Player Number; either 0 or 1 (0 is player 1, 1 is player 2)
 int playerID() {
   return Client.INSTANCE.getPlayerID(connection);
 }
Exemple #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);
 }
Exemple #14
0
 /// The width of the total map.
 int mapWidth() {
   return Client.INSTANCE.getMapWidth(connection);
 }
Exemple #15
0
 public Mappable(Pointer p) {
   ptr = p;
   ID = Client.INSTANCE.mappableGetId(ptr);
   iteration = BaseAI.iteration;
 }
Exemple #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);
 }
Exemple #17
0
 public Frame(Pointer p) {
   ptr = p;
   ID = Client.INSTANCE.frameGetId(ptr);
   iteration = BaseAI.iteration;
 }
Exemple #18
0
 /// How many of your turns until this frame becomes a robot
 public int getCompletionTime() {
   validify();
   return Client.INSTANCE.frameGetCompletionTime(ptr);
 }
Exemple #19
0
 /// The height of the total map.
 int mapHeight() {
   return Client.INSTANCE.getMapHeight(connection);
 }
Exemple #20
0
 /// The maximum number of Traps allowed per player.
 int maxTraps() {
   return Client.INSTANCE.getMaxTraps(connection);
 }
Exemple #21
0
 /// How many turns it has been since the beginning of the game
 int turnNumber() {
   return Client.INSTANCE.getTurnNumber(connection);
 }
Exemple #22
0
 /// What round of the game this is.
 int roundNumber() {
   return Client.INSTANCE.getRoundNumber(connection);
 }
Exemple #23
0
 /// What number game this is for the server
 int gameNumber() {
   return Client.INSTANCE.getGameNumber(connection);
 }
Exemple #24
0
 /// The scarabs given to a player to purchase thieves per round.
 int scarabsForThieves() {
   return Client.INSTANCE.getScarabsForThieves(connection);
 }
Exemple #25
0
 /// Scalar used in the virus price formula
 float scaleCost() {
   return Client.INSTANCE.getScaleCost(connection);
 }
Exemple #26
0
 /// The number of won rounds required to win.
 int roundsToWin() {
   return Client.INSTANCE.getRoundsToWin(connection);
 }
Exemple #27
0
 /// The height of the map (max Y value)
 int height() {
   return Client.INSTANCE.getHeight(connection);
 }
Exemple #28
0
 /// The maximum number of round turns before a winner is decided.
 int roundTurnLimit() {
   return Client.INSTANCE.getRoundTurnLimit(connection);
 }
 /**
  * 取消请求
  *
  * @param context 上下文
  */
 public void cancelRequests(Context context) {
   Client.INSTANCE.cancelRequests(context, true);
 }
Exemple #30
0
 /// The maximum amount of health this unit can ever have
 public int getMaxHealth() {
   validify();
   return Client.INSTANCE.frameGetMaxHealth(ptr);
 }