Skip to content

Commit

Permalink
introducing foodmill a tool to squash apples wish for the moment
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrid Sawatzky committed Mar 13, 2009
1 parent 393b15f commit c96dfcd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data/conf/items/drinks.xml
@@ -1,6 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<items xmlns="stendhal" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="stendhal ../items.xsd ">

<item name="apple juice">
<type class="drink" subclass="red_juice" tileid="-1"/>
<description>You see apple juice. On a hot summer day, it would taste great.</description>
<implementation class-name="games.stendhal.server.entity.item.Drink"/> <attributes>
<amount value="30"/>
<frequency value="12"/>
<quantity value="1"/>
<regen value="3"/>
</attributes>
<weight value="1.0"/>
<value value="1"/>
<equipable>
<slot name="lhand"/>
<slot name="rhand"/>
<slot name="bag"/>
</equipable>
</item>

<item name="beer">
<type class="drink" subclass="beer" tileid="-1"/>
<description>You see a beer. On a hot summer day, it would taste great.</description>
Expand Down
14 changes: 14 additions & 0 deletions data/conf/items/tools.xml
Expand Up @@ -2,6 +2,20 @@
<items xmlns="stendhal" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="stendhal ../items.xsd ">

<item name="food mill">
<type class="tool" subclass="foodmill" tileid="-1"/>
<description>You see a food mill. It is the traditional tool to mill food.</description>
<implementation class-name="games.stendhal.server.entity.item.FoodMill"/> <attributes>
</attributes>
<weight value="10.0"/>
<value value="1"/>
<equipable>
<slot name="bag"/>
<slot name="lhand"/>
<slot name="rhand"/>
</equipable>
</item>

<item name="gold pan">
<type class="tool" subclass="gold_pan" tileid="-1"/>
<description>You see a gold pan. It is the traditional tool to prospect for gold.</description>
Expand Down
Binary file added data/sprites/items/drink/red_juice.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/sprites/items/tool/foodmill.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/games/stendhal/client/entity/factory/EntityMap.java
Expand Up @@ -113,6 +113,7 @@ private static void register() {
register("item", "drink", null, UseableItem.class);
register("item", "flower", null, StackableItem.class);
register("item", "food", null, UseableItem.class);
register("item", "tool", "foodmill", UseableItem.class);
register("item", "herb", null, StackableItem.class);
register("item", "misc", null, StackableItem.class);
register("item", "money", null, StackableItem.class);
Expand Down
55 changes: 55 additions & 0 deletions src/games/stendhal/server/entity/item/FoodMill.java
@@ -0,0 +1,55 @@
package games.stendhal.server.entity.item;

import games.stendhal.server.core.engine.SingletonRepository;
import games.stendhal.server.core.events.UseListener;
import games.stendhal.server.entity.RPEntity;

import java.util.Map;

import marauroa.common.game.RPObject;

public class FoodMill extends Item implements UseListener {

public FoodMill(final String name, final String clazz,
final String subclass, final Map<String, String> attributes) {
super(name, clazz, subclass, attributes);
}

public FoodMill(final FoodMill item) {
super(item);
}

public boolean onUsed(final RPEntity user) {
if (isContained()) {
final String slotName = getContainerSlot().getName();
if (slotName.endsWith("hand")) {
String otherhand;
if ("rhand".equals(slotName)) {
otherhand = "lhand";
} else {
otherhand = "rhand";
}
final RPObject first = user.getSlot(otherhand).getFirst();
if (first != null) {
if ("apple".equals(first.get("name"))) {
if (user.isEquipped("flask")) {

final Item item = SingletonRepository
.getEntityManager().getItem("apple juice");


user.drop("apple");
user.drop("flask");
user.equip(item, true);
}
}
}

}
return true;
} else {
return false;
}
}

}

0 comments on commit c96dfcd

Please sign in to comment.