mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-16 16:46:35 +01:00
Persist inventories of vendors in savegame file. Restock merchants when map respawns.
This commit is contained in:
@@ -20,7 +20,7 @@ public final class AndorsTrailApplication extends Application {
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = true;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = true;
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || true;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 30;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 31;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.7.0dev";
|
||||
|
||||
public final WorldContext world = new WorldContext();
|
||||
|
||||
@@ -213,6 +213,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/shop"));
|
||||
Dialogs.addMonsterIdentifiers(intent, npc);
|
||||
startActivityForResult(intent, MainActivity.INTENTREQUEST_SHOP);
|
||||
ConversationActivity.this.finish();
|
||||
return;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_ATTACK)) {
|
||||
ConversationActivity.this.setResult(ACTIVITYRESULT_ATTACK);
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class DebugInterface {
|
||||
@@ -114,6 +115,16 @@ public final class DebugInterface {
|
||||
mainActivity.showToast("DEBUG: given 10000 exp", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})*/
|
||||
,new DebugButton("reset", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
for(PredefinedMap map : world.maps.predefinedMaps) {
|
||||
map.lastVisitTime = 1;
|
||||
map.resetIfNotRecentlyVisited();
|
||||
}
|
||||
mainActivity.showToast("DEBUG: maps respawned", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("hp", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
|
||||
@@ -70,9 +69,7 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
shoplist_buy = (ListView) h.findViewById(R.id.shop_buy_list);
|
||||
shoplist_sell = (ListView) h.findViewById(R.id.shop_sell_list);
|
||||
|
||||
Loot merchantLoot = new Loot();
|
||||
npc.dropList.createRandomLoot(merchantLoot, player);
|
||||
container_buy = merchantLoot.items;
|
||||
container_buy = npc.getShopItems(player);
|
||||
|
||||
HashSet<Integer> iconIDs = world.tileManager.getTileIDsFor(container_buy);
|
||||
iconIDs.addAll(world.tileManager.getTileIDsFor(player.inventory));
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropList;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
@@ -25,6 +26,7 @@ public final class Monster extends Actor {
|
||||
public final int exp;
|
||||
public final DropList dropList;
|
||||
public final String faction;
|
||||
private ItemContainer shopItems = null;
|
||||
public final int monsterClass;
|
||||
|
||||
public Monster(MonsterType monsterType, Coord position) {
|
||||
@@ -47,6 +49,16 @@ public final class Monster extends Actor {
|
||||
if (this.dropList == null) return;
|
||||
this.dropList.createRandomLoot(container, player);
|
||||
}
|
||||
public ItemContainer getShopItems(Player player) {
|
||||
if (shopItems != null) return shopItems;
|
||||
Loot loot = new Loot();
|
||||
shopItems = loot.items;
|
||||
this.dropList.createRandomLoot(loot, player);
|
||||
return shopItems;
|
||||
}
|
||||
public void resetShopItems() {
|
||||
this.shopItems = null;
|
||||
}
|
||||
|
||||
public boolean isAgressive() {
|
||||
return phraseID == null || forceAggressive;
|
||||
@@ -78,6 +90,11 @@ public final class Monster extends Actor {
|
||||
this.forceAggressive = src.readBoolean();
|
||||
this.faction = monsterType.faction;
|
||||
this.monsterClass = monsterType.monsterClass;
|
||||
if (fileversion >= 31) {
|
||||
if (src.readBoolean()) {
|
||||
this.shopItems = new ItemContainer(src, world, fileversion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Monster readFromParcel_pre_v0610(DataInputStream src, int fileversion, MonsterType monsterType) throws IOException {
|
||||
@@ -95,5 +112,11 @@ public final class Monster extends Actor {
|
||||
dest.writeUTF(monsterTypeID);
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeBoolean(forceAggressive);
|
||||
if (shopItems != null) {
|
||||
dest.writeBoolean(true);
|
||||
shopItems.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,12 @@ public final class MonsterSpawnArea {
|
||||
monsters.clear();
|
||||
quantity.current = 0;
|
||||
}
|
||||
|
||||
public void resetShops() {
|
||||
for (Monster m : monsters) {
|
||||
m.resetShopItems();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
@@ -232,7 +232,8 @@ public final class PredefinedMap {
|
||||
|
||||
// We reset all non-unique spawn areas. This keeps the savegame file smaller, thus reducing load and save times. Also keeps the running memory usage slightly lower.
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
if (!a.isUnique) a.reset();
|
||||
if (a.isUnique) a.resetShops();
|
||||
else a.reset();
|
||||
}
|
||||
splatters.clear();
|
||||
lastVisitTime = VISIT_RESET;
|
||||
|
||||
Reference in New Issue
Block a user