Skip to content

Commit

Permalink
add new condition which checks the total number of (loggable) quests …
Browse files Browse the repository at this point in the history
…done, and an achievement for it
  • Loading branch information
Katie Russell committed May 22, 2011
1 parent 50f7ea5 commit f44356b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public Collection<Achievement> createAchievements() {
// have completed all quests in Ados City?
questAchievements.add(createAchievement("quest.special.ados", "Helper of Ados city dwellers", "Complete all quests in Ados City",
Achievement.MEDIUM_BASE_SCORE, true, new QuestsInRegionCompletedCondition(Region.ADOS_CITY)));

// complete nearly all the quests in the game?
questAchievements.add(createAchievement("quest.count.80", "Quest Junkie","Complete at least 80 quests",
Achievement.MEDIUM_BASE_SCORE, true, new QuestCountCompletedCondition(80)));

return questAchievements;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package games.stendhal.server.core.rp.achievement.factory;

import games.stendhal.common.parser.Sentence;
import games.stendhal.server.core.engine.SingletonRepository;
import games.stendhal.server.entity.Entity;
import games.stendhal.server.entity.npc.ChatCondition;
import games.stendhal.server.entity.player.Player;

import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Were this many quests completed?
*
* @author kymara
*/
public class QuestCountCompletedCondition implements ChatCondition {

private final int count;

/**
* Creates a new QuestCountCompletedCondition.
*
* @param count
* number of quests to check
*/
public QuestCountCompletedCondition(final int count) {
this.count = count;
}

public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
List<String> quests = SingletonRepository.getStendhalQuestSystem().getCompletedQuests(player);
if (quests.size()>=count) {
return true;
}
return false;
}

@Override
public String toString() {
return "QuestCountCompletedCondition <" + count + ">";
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

@Override
public boolean equals(final Object obj) {
return EqualsBuilder.reflectionEquals(this, obj, false,
QuestCountCompletedCondition.class);
}
}

0 comments on commit f44356b

Please sign in to comment.