2 Commits
Author SHA1 Message Date
Ondřej Hruška d98b8b9730 increased weapon durability slightly 2014-05-22 20:15:37 +02:00
Ondřej Hruška 36cda65699 better balanced, fixed items not saving damage (not backwards
compatible!)
2014-05-22 20:13:09 +02:00
8 changed files with 31 additions and 20 deletions
@@ -65,12 +65,12 @@ public class EntityBrownRat extends Entity {
{ {
// drop rat stuff // drop rat stuff
if (Calc.rand.nextInt(2) == 0) { if (Calc.rand.nextInt(2) != 0) {
getLevel().dropNear(getCoord(), Items.MEAT.createItem()); getLevel().dropNear(getCoord(), Items.MEAT.createItem());
return; return;
} }
if (Calc.rand.nextInt(4) == 0) { if (Calc.rand.nextInt(3) == 0) {
getLevel().dropNear(getCoord(), Items.CHEESE.createItem()); getLevel().dropNear(getCoord(), Items.CHEESE.createItem());
return; return;
} }
@@ -17,12 +17,15 @@ public class StorageRoom extends SecretRoom {
{ {
int maxStuff = Calc.randInt(rand, 3, 5); int maxStuff = Calc.randInt(rand, 3, 5);
for (int i = 0; i < Calc.randInt(rand, 0, 2); i++) { // at least one meat or cheese.
boolean oneMeat = rand.nextBoolean();
for (int i = 0; i < Calc.randInt(rand, oneMeat ? 1 : 0, 3); i++) {
map.addItemInArea(Items.MEAT.createItem(), min, max, 50); map.addItemInArea(Items.MEAT.createItem(), min, max, 50);
if (--maxStuff == 0) return; if (--maxStuff == 0) return;
} }
for (int i = 0; i < Calc.randInt(rand, 0, 2); i++) { for (int i = 0; i < Calc.randInt(rand, oneMeat ? 0 : 1, 2); i++) {
map.addItemInArea(Items.CHEESE.createItem(), min, max, 50); map.addItemInArea(Items.CHEESE.createItem(), min, max, 50);
if (--maxStuff == 0) return; if (--maxStuff == 0) return;
} }
+9 -5
View File
@@ -5,15 +5,17 @@ import java.io.IOException;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.ion.IonBundle;
import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonInput;
import mightypork.gamecore.util.ion.IonObjBlob; import mightypork.gamecore.util.ion.IonObjBlob;
import mightypork.gamecore.util.ion.IonObjBundled;
import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.ion.IonOutput;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.PlayerFacade;
public abstract class Item implements IonObjBlob { public abstract class Item implements IonObjBundled {
private final ItemModel model; private final ItemModel model;
private ItemRenderer renderer; private ItemRenderer renderer;
@@ -42,17 +44,19 @@ public abstract class Item implements IonObjBlob {
@Override @Override
@DefaultImpl @DefaultImpl
public void save(IonOutput out) throws IOException public void save(IonBundle out) throws IOException
{ {
out.writeIntShort(amount); out.put("c", amount);
out.put("u", uses);
} }
@Override @Override
@DefaultImpl @DefaultImpl
public void load(IonInput in) throws IOException public void load(IonBundle in) throws IOException
{ {
amount = in.readIntShort(); amount = in.get("c", amount);
uses = in.get("u", uses);
} }
@@ -3,6 +3,8 @@ package mightypork.rogue.world.item;
import java.io.IOException; import java.io.IOException;
import mightypork.gamecore.util.ion.Ion;
import mightypork.gamecore.util.ion.IonBundle;
import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonInput;
import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.ion.IonOutput;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
@@ -46,7 +48,7 @@ public final class ItemModel {
} }
public Item loadItem(IonInput in) throws IOException public Item loadItem(IonBundle in) throws IOException
{ {
final Item t = createItem(); final Item t = createItem();
t.load(in); t.load(in);
@@ -54,11 +56,10 @@ public final class ItemModel {
} }
public void saveItem(IonOutput out, Item tile) throws IOException public void saveItem(IonBundle out, Item item) throws IOException
{ {
if (itemClass != tile.getClass()) throw new RuntimeException("Item class mismatch."); if (itemClass != item.getClass()) throw new RuntimeException("Item class mismatch.");
item.save(out);
tile.save(out);
} }
+6 -3
View File
@@ -4,6 +4,7 @@ package mightypork.rogue.world.item;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import mightypork.gamecore.util.ion.IonBundle;
import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonInput;
import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.ion.IonOutput;
import mightypork.rogue.world.item.impl.active.ItemHeartPiece; import mightypork.rogue.world.item.impl.active.ItemHeartPiece;
@@ -64,9 +65,8 @@ public final class Items {
public static Item loadItem(IonInput in) throws IOException public static Item loadItem(IonInput in) throws IOException
{ {
final int id = in.readIntByte(); final int id = in.readIntByte();
final ItemModel model = get(id); final ItemModel model = get(id);
return model.loadItem(in); return model.loadItem(in.readBundle());
} }
@@ -75,7 +75,10 @@ public final class Items {
final ItemModel model = item.getModel(); final ItemModel model = item.getModel();
out.writeIntByte(model.id); out.writeIntByte(model.id);
model.saveItem(out, item);
IonBundle ib = new IonBundle();
model.saveItem(ib, item);
out.writeBundle(ib);
} }
@@ -33,7 +33,7 @@ public class ItemKnife extends ItemBaseWeapon {
@Override @Override
public int getMaxUses() public int getMaxUses()
{ {
return 60; return 70;
} }
@@ -33,7 +33,7 @@ public class ItemRock extends ItemBaseWeapon {
@Override @Override
public int getMaxUses() public int getMaxUses()
{ {
return 30; return 35;
} }
@@ -33,7 +33,7 @@ public class ItemSword extends ItemBaseWeapon {
@Override @Override
public int getMaxUses() public int getMaxUses()
{ {
return 200; return 210;
} }