Exemplo n.º 1
0
  /** 每提升10级,需要的钻石数量+10颗,颜色每提升1个等级,则需要1.2倍钻石数量 1 1 2 10 3 45 4 80 5 125 6 180 7 245 8 320 9 405 */
  public static ScriptResult func(Object[] parameters) {
    ScriptResult result = ScriptManager.checkParameters(parameters, 2);
    if (result != null) {
      return result;
    }

    User user = (User) parameters[0];
    PropData propData = (PropData) parameters[1];
    int count = 0;
    WeaponPojo weapon = EquipManager.getInstance().getWeaponById(propData.getItemId());
    if (weapon != null) {
      int userLevel = weapon.getUserLevel();
      if (userLevel == 0) {
        count = 1;
      } else if (userLevel == 10) {
        count = 10;
      } else if (userLevel < 90) {
        count = (userLevel / 10 + 1) * (userLevel / 10 + 1) * 5;
        int colorIndex = propData.getWeaponColor().ordinal();
        if (colorIndex > 0) {
          count = Math.round(count * 1.2f * colorIndex);
        }
      }
    }

    List list = new ArrayList();
    list.add(count);
    result = new ScriptResult();
    result.setType(ScriptResult.Type.SUCCESS_RETURN);
    result.setResult(list);
    return result;
  }
  /**
   * 在每回合开始时,检查战斗用户的状态, 1. 如果用户处于冰冻状态,并且回合数尚未达到解冻条件,则自动蓄力 2. 如果用户处于隐身状态,并且回合数尚未达到显示条件,则继续隐身
   *
   * @param parameters
   * @return
   */
  public static ScriptResult func(Object[] parameters) {
    ScriptResult result = ScriptManager.checkParameters(parameters, 2);
    if (result != null) {
      return result;
    }
    Battle battle = (Battle) parameters[0];
    BattleUser battleUser = (BattleUser) parameters[1];

    checkBattle(battle, battleUser);

    result = new ScriptResult();
    result.setType(ScriptResult.Type.SUCCESS);
    result.setResult(null);
    return result;
  }
  public static ScriptResult func(Object[] parameters) {
    ScriptResult result = ScriptManager.checkParameters(parameters, 2);
    if (result != null) {
      return result;
    }

    User user = (User) parameters[0];
    int slot = (Integer) parameters[1];

    ArrayList rewards = new ArrayList(slot * 2);

    result = new ScriptResult();
    result.setType(ScriptResult.Type.SUCCESS_RETURN);
    result.setResult(rewards);
    return result;
  }
  @Test
  public void testBagUnwear() {
    ScriptManager manager = ScriptManager.getInstance();
    User user = UserManager.getInstance().createDefaultUser();
    User expectUser = UserManager.getInstance().createDefaultUser();

    WeaponPojo weapon = new WeaponPojo();
    weapon.setAddAttack(10);
    weapon.setAddDefend(20);
    weapon.setAddAgility(30);
    weapon.setAddLuck(40);
    weapon.setAddBlood(50);
    weapon.setAddBloodPercent(60);
    weapon.setAddThew(70);
    weapon.setAddDamage(80);
    weapon.setAddSkin(90);

    user.getBag().removeOtherPropDatas(Bag.BAG_WEAR_COUNT);
    user.getBag().addOtherPropDatas(weapon.toPropData(30, WeaponColor.WHITE));
    user.getBag().wearPropData(Bag.BAG_WEAR_COUNT, PropDataEquipIndex.WEAPON.index());

    // default power = 2980
    assertTrue(user.getPower() > 0);
    assertEquals(expectUser.getAttack() + weapon.getAddAttack(), user.getAttack());
    assertEquals(expectUser.getDefend() + weapon.getAddDefend(), user.getDefend());
    assertEquals(expectUser.getAgility() + weapon.getAddAgility(), user.getAgility());
    assertEquals(expectUser.getLuck() + weapon.getAddLuck(), user.getLuck());
    assertEquals(
        (int)
            ((expectUser.getBlood() + weapon.getAddBlood())
                * (1.0 + weapon.getAddBloodPercent() / 100.0)),
        user.getBlood());
    assertEquals(expectUser.getTkew() + weapon.getAddThew() + 6, user.getTkew());
    assertEquals(expectUser.getDamage() + weapon.getAddDamage(), user.getDamage());
    assertEquals(expectUser.getSkin() + weapon.getAddSkin(), user.getSkin());

    user.getBag().wearPropData(PropDataEquipIndex.WEAPON.index(), Bag.BAG_WEAR_COUNT);

    assertEquals(expectUser.getAttack(), user.getAttack());
    assertEquals(expectUser.getDefend(), user.getDefend());
    assertEquals(expectUser.getAgility(), user.getAgility());
    assertEquals(expectUser.getLuck(), user.getLuck());
    assertEquals(expectUser.getTkew(), user.getTkew());
    assertEquals(expectUser.getDamage(), user.getDamage());
    assertEquals(expectUser.getSkin(), user.getSkin());
  }
Exemplo n.º 5
0
  public static ScriptResult func(Object[] parameters) {
    ScriptResult result = ScriptManager.checkParameters(parameters, 1);
    if (result != null) {
      return result;
    }
    try {
      BattleUser roundOwner = findRoundOwner(parameters);

      ArrayList list = new ArrayList();
      list.add(roundOwner);

      result = new ScriptResult();
      result.setResult(list);
      result.setType(Type.SUCCESS_RETURN);

      return result;
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }
Exemplo n.º 6
0
  public static ScriptResult func(Object[] parameters) {
    ScriptResult result = ScriptManager.checkParameters(parameters, 3);
    if (result != null) {
      return result;
    }
    User user = (User) parameters[0];
    TaskPojo task = (TaskPojo) parameters[1];
    TaskHook hook = (TaskHook) parameters[2];
    if (hook == TaskHook.WEIBO) {
      Object[] array = (Object[]) parameters[3];
      WeiboOpType weiboType = (WeiboOpType) array[0];

      if (weiboType == WeiboOpType.COMBAT) {
        TaskStep.step(task, user);
      }
    }

    result = new ScriptResult();
    result.setType(ScriptResult.Type.SUCCESS);
    result.setResult(null);
    return result;
  }
  @Test
  public void testWearAndUnWearBloodPercentEquip() {
    ScriptManager manager = ScriptManager.getInstance();
    User user = UserManager.getInstance().createDefaultUser();
    user.setBlood(100);
    User expectUser = UserManager.getInstance().createDefaultUser();
    expectUser.setBlood(100);

    WeaponPojo weapon = new WeaponPojo();
    weapon.setAddBloodPercent(15);

    user.getBag().removeOtherPropDatas(Bag.BAG_WEAR_COUNT);
    user.getBag().addOtherPropDatas(weapon.toPropData(30, WeaponColor.WHITE));
    user.getBag().wearPropData(Bag.BAG_WEAR_COUNT, PropDataEquipIndex.WEAPON.index());

    // default power = 2980
    assertEquals(Math.round(expectUser.getBlood() * 1.15), user.getBlood());

    user.getBag().wearPropData(PropDataEquipIndex.WEAPON.index(), -1);

    assertEquals(expectUser.getBlood(), user.getBlood());
  }