forked from arianne/stendhal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new condition which checks the total number of (loggable) quests …
…done, and an achievement for it
- Loading branch information
Katie Russell
committed
May 22, 2011
1 parent
50f7ea5
commit f44356b
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/games/stendhal/server/core/rp/achievement/factory/QuestCountCompletedCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |