public static String getGoalText( final ChallengeGoalData goal, final ChallengeData data, final ChallengeDataModel model) { String rawText = goal.getFormattedString(); if (rawText == null || rawText.length() == 0) { return null; } rawText = (String) ChallengeFormatter.extractValue( rawText, ChallengeFormatter.Type.STRING, model.getParams()); for (Matcher match = ChallengeGoalView.GOAL_BREED_PATTERN.matcher(rawText); match.find(); match = ChallengeGoalView.GOAL_BREED_PATTERN.matcher(rawText)) { final String name = WakfuTranslator.getInstance() .getString(7, PrimitiveConverter.getInteger(match.group(1)), new Object[0]); rawText = match.replaceFirst(name); } for (Matcher match = ChallengeGoalView.GOAL_RESOURCE_PATTERN.matcher(rawText); match.find(); match = ChallengeGoalView.GOAL_RESOURCE_PATTERN.matcher(rawText)) { final String name = WakfuTranslator.getInstance() .getString(12, PrimitiveConverter.getInteger(match.group(1)), new Object[0]); rawText = match.replaceFirst(name); } for (Matcher match = ChallengeGoalView.GOAL_VAR_PATTERN.matcher(rawText); match.find(); match = ChallengeGoalView.GOAL_VAR_PATTERN.matcher(rawText)) { final Long value = data.getVarValue(match.group().substring(1, match.group().length() - 1)); rawText = match.replaceFirst(value.toString()); } return rawText; }
@Override protected boolean isCompleted() { final ChallengeData challengeData = ChallengeManager.getInstance().getChallengeData(this.m_challengeId); final ChallengeDataModel model = ChallengeManager.getInstance().getChallengeDataModel(this.m_challengeId); final ChallengeGoalData goalData = model.getGoal(this.m_goalId); return challengeData == null || challengeData.getGoalStatus(goalData) == 2; }
protected static String getGoalDescription(final ChallengeDataModel model) { final String desc = model.getChallengeDescription(); if (desc != null && desc.length() == 0) { return null; } return desc; }
@Override protected String getDescription() { final ChallengeData challengeData = ChallengeManager.getInstance().getChallengeData(this.m_challengeId); final ChallengeDataModel model = ChallengeManager.getInstance().getChallengeDataModel(this.m_challengeId); final ChallengeGoalData goalData = model.getGoal(this.m_goalId); long score = 0L; final String jaugeVarName = goalData.getJaugeVarName(); if (challengeData != null && jaugeVarName != null && jaugeVarName.length() > 0) { score = challengeData.getVarValue(jaugeVarName); } if (score == 0L || challengeData.isProposed()) { return getGoalDescription(model); } if (challengeData.getGoalStatus(goalData) == 1) { final String text = getGoalText(goalData, challengeData, model); if (text != null) { return text; } } return null; }