// 容错过期时间(单写一方法在此调用) public static void checkGoodsExpiredTime(RoleGoods roleGoods) { try { GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == goodsBase) { return; } if (goodsBase.isForever()) { return; } int bagType = roleGoods.getStorageType(); boolean on = bagType == StorageType.hero.getType(); boolean mustActive = (goodsBase.getActivateType() == 1) || (goodsBase.getActivateType() == 0 && on); if (mustActive) { if (!Util.isEmpty(roleGoods.getExpiredTime())) { return; } Date endDate = DateUtil.add(new Date(), Calendar.MINUTE, goodsBase.getDeadline()); roleGoods.setExpiredTime(endDate); return; } if (roleGoods.getDeadline() > 0) { return; } roleGoods.setDeadline(goodsBase.getDeadline()); } catch (Exception e) { e.printStackTrace(); } }
/** 添加合成的时间 */ public static void addComposeTime(RoleGoods roleGoods, int minute, boolean endGoodsIsActivate) { if (isExpired(roleGoods)) { roleGoods.setExpiredTime(DateUtil.add(new Date(), Calendar.MINUTE, minute)); return; } if (isActivate(roleGoods)) { roleGoods.setExpiredTime(DateUtil.add(roleGoods.getExpiredTime(), Calendar.MINUTE, minute)); return; } if (endGoodsIsActivate) { roleGoods.setExpiredTime( DateUtil.add(new Date(), Calendar.MINUTE, roleGoods.getDeadline() + minute)); return; } roleGoods.setDeadline(roleGoods.getDeadline() + minute); }