diff --git a/res/weapons.txt b/res/weapons.txt index 2adf900..f6da708 100644 --- a/res/weapons.txt +++ b/res/weapons.txt @@ -1,85 +1,85 @@ -#Name Type Range Mt Hit Crit Uses Worth Effect Pref Mod -Tree Branch Sword 1 1 100 0 20 1 - - - -Iron Sword Sword 1 5 90 0 23 460 - - - -Steel Sword Sword 1 8 75 0 15 600 - - - -Silver Sword Sword 1 13 80 0 10 1500 - - - -Killing Edge Sword 1 9 75 30 10 1300 - - - -Armorslayer Sword 1 8 80 0 9 1260 Armor - - -Longsword Sword 1 6 85 0 9 1260 Mount - - -Lancereaver Sword 1 9 75 5 7 1800 - - - -Brave Sword Sword 1 9 75 0 15 8000 - - - -Audhulma Sword 1 18 85 0 15 10000 - - Res 5 -Wo Dao Sword 1 8 75 35 10 1200 - - - -Durandal Sword 1 17 90 0 10 - - Eliwood Str 5 -Sol Katti Sword 1 12 95 25 15 - Mount Lyn Res 5 -Sieglinde Sword 1 16 90 0 15 - - Eirika Str 5 -Falchion Sword 1 15 90 20 15 - - Marth Skl 5 -Ragnell Sword 1-2 14 85 0 10 - - Ike Def 5 -Sealed Sword Sword 1-2 16 95 10 10 - - Roy Res 5 -Log Lance 1 1 100 0 20 1 - - - -Iron Lance Lance 1 7 80 0 22 360 - - - -Steel Lance Lance 1 10 70 0 15 480 - - - -Silver Lance Lance 1 14 75 0 10 1200 - - - -Javelin Lance 1-2 6 65 0 10 400 - - - -Short Spear Lance 1-2 9 60 0 9 900 - - - -Killer Lance Lance 1 10 70 30 10 1200 - - - -Heavy Spear Lance 1 9 70 0 8 1200 Armor - - -Horseslayer Lance 1 7 70 0 8 1040 Mount - - -Axereaver Lance 1 10 70 5 7 1950 - - - -Brave Lance Lance 1 10 70 0 15 7500 - - - -Gradivus Lance 1-2 15 85 0 15 10000 - - Def 5 -Siegmund Lance 1 17 80 0 15 - - Ephraim Str 5 +#Name Type Range Mt Hit Crit Uses Worth Effect Pref Mod Class +Tree Branch Sword 1 1 100 0 20 1 - - - - +Iron Sword Sword 1 5 90 0 23 460 - - - - +Steel Sword Sword 1 8 75 0 15 600 - - - - +Silver Sword Sword 1 13 80 0 10 1500 - - - - +Killing Edge Sword 1 9 75 30 10 1300 - - - Killer +Armorslayer Sword 1 8 80 0 9 1260 Armor - - Slayer +Longsword Sword 1 6 85 0 9 1260 Mount - - Slayer +Lancereaver Sword 1 9 75 5 7 1800 - - - Reaver +Brave Sword Sword 1 9 75 0 15 8000 - - - Brave +Audhulma Sword 1 18 85 0 15 10000 - - Res 5 Legend +Wo Dao Sword 1 8 75 35 10 1200 - - - Killer +Durandal Sword 1 17 90 0 10 - - Eliwood Str 5 - +Sol Katti Sword 1 12 95 25 15 - Mount Lyn Res 5 - +Sieglinde Sword 1 16 90 0 15 - - Eirika Str 5 - +Falchion Sword 1 15 90 20 15 - - Marth Skl 5 - +Ragnell Sword 1-2 14 85 0 10 - - Ike Def 5 - +Sealed Sword Sword 1-2 16 95 10 10 - - Roy Res 5 - +Log Lance 1 1 100 0 20 1 - - - - +Iron Lance Lance 1 7 80 0 22 360 - - - - +Steel Lance Lance 1 10 70 0 15 480 - - - - +Silver Lance Lance 1 14 75 0 10 1200 - - - - +Javelin Lance 1-2 6 65 0 10 400 - - - Throw +Short Spear Lance 1-2 9 60 0 9 900 - - - Throw +Killer Lance Lance 1 10 70 30 10 1200 - - - Killer +Heavy Spear Lance 1 9 70 0 8 1200 Armor - - Slayer +Horseslayer Lance 1 7 70 0 8 1040 Mount - - Slayer +Axereaver Lance 1 10 70 5 7 1950 - - - Reaver +Brave Lance Lance 1 10 70 0 15 7500 - - - Brave +Gradivus Lance 1-2 15 85 0 15 10000 - - Def 5 Legend +Siegmund Lance 1 17 80 0 15 - - Ephraim Str 5 - # -#Name Type Range Mt Hit Crit Uses Worth Effect Pref Mod -Ladle Axe 1 1 100 0 20 1 - - - -Iron Axe Axe 1 8 75 0 22 270 - - - -Steel Axe Axe 1 11 65 0 15 360 - - - -Silver Axe Axe 1 15 70 0 10 1000 - - - -Hand Axe Axe 1-2 7 60 0 10 300 - - - -Tomahawk Axe 1-2 13 65 0 7 3000 - - - -Killer Axe Axe 1 11 65 30 10 1000 - - - -Hammer Axe 1 10 55 0 10 800 Armor - - -Halberd Axe 1 10 60 0 8 810 Mount - - -Swordreaver Axe 1 11 65 5 7 2100 - - - -Brave Axe Axe 1 10 65 0 15 7500 - - - -Garm Axe 1 20 75 0 15 10000 - - Spd 5 -Armads Axe 1 18 85 0 12 - - Hector Def 5 -Iron Bow Bow 2 6 85 0 22 540 Flier - - -Steel Bow Bow 2 9 70 0 15 720 Flier - - -Silver Bow Bow 2 13 75 0 10 1600 Flier - - -Killer Bow Bow 2 9 75 30 10 1400 Flier - - -Brave Bow Bow 2 10 70 0 15 7500 Flier - - -Debug Short Bow Bow 1-2 5 85 10 11 1760 Flier - - -Longbow Bow 2-3 5 65 0 10 2000 Flier - - -Double Bow Bow 2-3 18 85 5 12 10000 Flier - Str 5 -Bowgun Crossbow 1-2 24 100 0 12 2000 Flier - - -Crossbow Crossbow 1-2 28 100 0 10 3000 Flier - - -Aqqar Crossbow 1-2 32 100 0 8 5000 Flier - - -Arbalest Crossbow 1-2 38 100 15 10 10000 Flier - - -Fire Anima 1-2 5 90 0 20 560 - - - -Elfire Anima 1-2 10 85 0 15 1200 - - - -Fimbulvetr Anima 1-2 13 80 0 10 6000 - - - -Excalibur Anima 1-2 18 90 10 15 15000 Flier - Spd 5 -Lightning Light 1-2 4 95 5 17 630 - - - -Divine Light 1-2 8 85 10 12 2500 - - - -Debug Purge Light 3-10 10 70 5 2 3000 - - - -Aura Light 1-2 12 85 15 10 8000 - - - -Aureola Light 1-2 15 90 5 10 15000 - - Res 5 -Flux Dark 1-2 7 80 0 22 900 - - - -Eclipse Dark 3-10 0 10 -900 2 4000 - - - -Lunase Dark 1-2 0 50 0 17 4200 - - - -Nosferatu Dark 1-2 10 70 0 10 3200 - - - -Debug Fenrir Dark 1-2 15 70 0 10 9000 - - - -Ereshkigal Dark 1-2 20 95 0 12 15000 - - Skl 5 -Heal Staff 1 10 100 0 15 600 - - - -Mend Staff 1 20 100 0 10 1000 - - - -Recover Staff 1 99 100 0 7 2250 - - - -Physic Staff 1-Mag/2 10 100 0 4 7500 - - - +#Name Type Range Mt Hit Crit Uses Worth Effect Pref Mod Class +Ladle Axe 1 1 100 0 20 1 - - - - +Iron Axe Axe 1 8 75 0 22 270 - - - - +Steel Axe Axe 1 11 65 0 15 360 - - - - +Silver Axe Axe 1 15 70 0 10 1000 - - - - +Hand Axe Axe 1-2 7 60 0 10 300 - - - Throw +Tomahawk Axe 1-2 13 65 0 7 3000 - - - Throw +Killer Axe Axe 1 11 65 30 10 1000 - - - Killer +Hammer Axe 1 10 55 0 10 800 Armor - - Slayer +Halberd Axe 1 10 60 0 8 810 Mount - - Slayer +Swordreaver Axe 1 11 65 5 7 2100 - - - Reaver +Brave Axe Axe 1 10 65 0 15 7500 - - - Brave +Garm Axe 1 20 75 0 15 10000 - - Spd 5 Legend +Armads Axe 1 18 85 0 12 - - Hector Def 5 - +Iron Bow Bow 2 6 85 0 22 540 Flier - - - +Steel Bow Bow 2 9 70 0 15 720 Flier - - - +Silver Bow Bow 2 13 75 0 10 1600 Flier - - - +Killer Bow Bow 2 9 75 30 10 1400 Flier - - Killer +Brave Bow Bow 2 10 70 0 15 7500 Flier - - Brave +Debug Short Bow Bow 1-2 5 85 10 11 1760 Flier - - - +Longbow Bow 2-3 5 65 0 10 2000 Flier - - - +Double Bow Bow 2-3 18 85 5 12 10000 Flier - Str 5 Legend +Bowgun Crossbow 1-2 24 100 0 12 2000 Flier - - - +Crossbow Crossbow 1-2 28 100 0 10 3000 Flier - - - +Aqqar Crossbow 1-2 32 100 0 8 5000 Flier - - - +Arbalest Crossbow 1-2 38 100 15 10 10000 Flier - - Legend +Fire Anima 1-2 5 90 0 20 560 - - - - +Elfire Anima 1-2 10 85 0 15 1200 - - - - +Fimbulvetr Anima 1-2 13 80 0 10 6000 - - - - +Excalibur Anima 1-2 18 90 10 15 15000 Flier - Spd 5 Legend +Lightning Light 1-2 4 95 5 17 630 - - - - +Divine Light 1-2 8 85 10 12 2500 - - - 0 +Debug Purge Light 3-10 10 70 5 2 3000 - - - Siege +Aura Light 1-2 12 85 15 10 8000 - - - - +Aureola Light 1-2 15 90 5 10 15000 - - Res 5 Legend +Flux Dark 1-2 7 80 0 22 900 - - - - +Eclipse Dark 3-10 0 10 -900 2 4000 - - - Siege +Lunase Dark 1-2 0 50 0 17 4200 - - - - +Nosferatu Dark 1-2 10 70 0 10 3200 - - - - +Debug Fenrir Dark 1-2 15 70 0 10 9000 - - - - +Ereshkigal Dark 1-2 20 95 0 12 15000 - - Skl 5 Legend +Heal Staff 1 10 100 0 15 600 - - - Healing +Mend Staff 1 20 100 0 10 1000 - - - Healing +Recover Staff 1 99 100 0 7 2250 - - - Healing +Physic Staff 1-Mag/2 10 100 0 4 7500 - - - Healing # Debug items -Debug Sword Sword 1 10 100 200 20 1000 - - - -Debug Axe Axe 1 10 100 200 20 1000 - - - -Debug Bow Bow 1-3 10 100 0 1 1000 - - - -Debug Lance Lance 1 10 100 200 20 1000 - - - -Debug Javelin Lance 1-2 10 100 200 20 1000 - - - -Debug Noodle Axe 1 1 100 0 2 9999 - - - -Debug Aether Sword 1 1 100 -900 20 1000 - - Skl 999 \ No newline at end of file +Debug Sword Sword 1 10 100 200 20 1000 - - - - +Debug Axe Axe 1 10 100 200 20 1000 - - - - +Debug Bow Bow 1-3 10 100 0 1 1000 - - - - +Debug Lance Lance 1 10 100 200 20 1000 - - - - +Debug Javelin Lance 1-2 10 100 200 20 1000 - - - - +Debug Noodle Axe 1 1 100 0 2 9999 - - - - +Debug Aether Sword 1 1 100 -900 20 1000 - - Skl 999 - \ No newline at end of file diff --git a/src/net/fe/builderStage/ClientWaitStage.java b/src/net/fe/builderStage/ClientWaitStage.java index 1f0c6dc..5364dcc 100644 --- a/src/net/fe/builderStage/ClientWaitStage.java +++ b/src/net/fe/builderStage/ClientWaitStage.java @@ -37,6 +37,7 @@ public ClientWaitStage(Session s) { super("preparations"); start = false; session = s; + } /* (non-Javadoc) diff --git a/src/net/fe/builderStage/ShopInventory.java b/src/net/fe/builderStage/ShopInventory.java new file mode 100644 index 0000000..3827ceb --- /dev/null +++ b/src/net/fe/builderStage/ShopInventory.java @@ -0,0 +1,154 @@ +package net.fe.builderStage; +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Map; + +import net.fe.builderStage.ShopInventory; +import net.fe.modifier.Modifier; +import net.fe.unit.Item; +import net.fe.unit.Unit; +import net.fe.unit.Weapon; + +public class ShopInventory { + private static ShopInventory obj; + + private Map inventory; + private Map classInventory; + + public ShopInventory(Iterable mods){ + inventory = new HashMap(); + classInventory = new HashMap(); + + for(Item i : Item.getAllItems()){ + inventory.put(i.name, -1); + if(i.getItemClass() != "" && !inventory.containsKey(i.getItemClass())){ + classInventory.put(i.getItemClass(), -1); + } + } + + if(mods != null){ + + for(Modifier m : mods){ + m.setShopLimits(inventory, classInventory); + } + } + } + + + /** + * Takes the item name of the item the player is trying to buy. Returns true and decrements the remaining + * stock (both from class and item) if it succeeds, false if the weapon can't be bought. + * + * @param itemName - The name of the item to buy + * @return + */ + public boolean buyItem(Item item){ + if(classInventory.get(item.getItemClass()) != null){ + + if(inventory.get(item.name) != 0 && classInventory.get(item.getItemClass()) != 0){ + if(inventory.get(item.name) != -1){ + inventory.put(item.name, inventory.get(item.name) - 1); + } + + if(classInventory.get(item.getItemClass()) != -1){ + classInventory.put(item.getItemClass(), classInventory.get(item.getItemClass())-1); + } + + return true; + } + return false; + } + else{ + if(inventory.get(item.name) != 0){ + if(inventory.get(item.name) != -1){ + inventory.put(item.name, inventory.get(item.name) - 1); + } + + return true; + } + return false; + } + } + + /** + * Returns true if the item is still in stock, false otherwise. + * + * @param itemName + * @return + */ + public boolean itemInStock(Item item){ + if(classInventory.get(item.getItemClass()) != null){ + return ((inventory.get(item.name) != 0) && (classInventory.get(item.getItemClass()) != 0)); + + } + else{ + return inventory.get(item.name) != 0; + } + + } + + /** + * Returns the items that this unit has to the shop inventory. Does not remove the items from + * the unit! + * + * @param unit + */ + public void refundItems(Unit unit){ + System.out.println("Refunding items on: " + unit.name); + for(Item i : unit.getInventory()){ + System.out.println("Refunding: " + i.name); + if(!(i instanceof Weapon && ((Weapon) i).pref != null)){ + if(inventory.get(i.name) != -1){ + System.out.println("+1 : " + i.name + " available"); + inventory.put(i.name, inventory.get(i.name) + 1); + } + if(classInventory.get(i.getItemClass()) != null && classInventory.get(i.getItemClass()) != -1){ + System.out.println("+1 : " + i.getItemClass() + " available"); + classInventory.put(i.getItemClass(), classInventory.get(i.getItemClass()) + 1); + } + } + + } + } + + /** + * Increases the stock of a single item by 1. + * + * @param item + */ + public void returnItem(Item item){ + if(inventory.get(item.name) != -1){ + inventory.put(item.name, inventory.get(item.name) + 1); + } + if(classInventory.get(item.getItemClass()) != null && classInventory.get(item.getItemClass()) != -1){ + classInventory.put(item.getItemClass(), classInventory.get(item.getItemClass()) + 1); + } + } + + /** + * Takes in an item and returns the number currently available. Returns -1 if there are infinitely many left. + * + * @param itemName + * @return + */ + public int countOf(Item item){ + //If it has a class, check it. Otherwise, return the individual value. + if(classInventory.get(item.getItemClass()) != null){ + + //If both are infinite, it's infinite + if(inventory.get(item.name) <= -1 && classInventory.get(item.getItemClass()) <= -1){ + return -1; + } + //If one is -1, the other (higher) value should be returned. + if(inventory.get(item.name) <= -1 || classInventory.get(item.getItemClass()) <= -1){ + return Math.max(inventory.get(item.name), classInventory.get(item.getItemClass())); + } + else{ + return Math.min(inventory.get(item.name), classInventory.get(item.getItemClass())); + } + } + else{ + return inventory.get(item.name); + } + } +} diff --git a/src/net/fe/builderStage/ShopMenu.java b/src/net/fe/builderStage/ShopMenu.java index 78f00f2..705b801 100644 --- a/src/net/fe/builderStage/ShopMenu.java +++ b/src/net/fe/builderStage/ShopMenu.java @@ -9,6 +9,7 @@ import net.fe.unit.Item; import net.fe.unit.ItemDisplay; import net.fe.unit.RiseTome; +import net.fe.unit.Unit; import net.fe.unit.Weapon; import net.fe.unit.WeaponFactory; @@ -31,6 +32,9 @@ public class ShopMenu extends Entity { /** The shop icons. */ private Texture[] shopIcons; + /** The shop inventory */ + private ShopInventory shopInventory; + /** The selected. */ private int selected; @@ -53,10 +57,12 @@ public class ShopMenu extends Entity { * @param y the y * @param s the s */ - public ShopMenu(float x, float y, Set ms) { + public ShopMenu(float x, float y, Set ms, ShopInventory si) { super(x, y); + System.out.println("new shop"); shops = new ItemMenu[9]; shopIcons = new Texture[9]; + shopInventory = si; for(int i = 0; i < shops.length; i++){ shops[i] = new ItemMenu(x + 140*i,y){{ drawCost = true; @@ -149,6 +155,43 @@ public Item getItem(){ return getSelectedShop().getSelection().getItem().getCopy(); } + /** + * Reduce the number available by 1. False if there isn't enough stock left. + * + * @return + */ + public boolean buyItem(){ + return shopInventory.buyItem(getSelectedShop().getSelection().getItem()); + } + + /** + * Returns true if the currently selected item can be gotten (if the inventory is present) + * + * @return + */ + public boolean canGetItem(){ + return shopInventory.itemInStock(getSelectedShop().getSelection().getItem()); + } + + /** + * Returns the item i to the shop's inventory. + * + * @param i + */ + public void returnItem(Item i){ + shopInventory.returnItem(i); + } + + + /** + * Returns all items possessed by this unit to the shop's inventory. + * + * @param u + */ + public void massReturnItem(Unit u){ + shopInventory.refundItems(u); + } + /** * Left. */ diff --git a/src/net/fe/builderStage/TeamBuilderStage.java b/src/net/fe/builderStage/TeamBuilderStage.java index 93cafc3..e5d2197 100644 --- a/src/net/fe/builderStage/TeamBuilderStage.java +++ b/src/net/fe/builderStage/TeamBuilderStage.java @@ -38,58 +38,64 @@ * The Class TeamBuilderStage. */ public class TeamBuilderStage extends Stage { - + /** The units. */ private List units; - + /** The cursor. */ private Cursor cursor; - + /** The repeat timers. */ private final float[] repeatTimers; - + /** The funds. */ private int funds; - + /** The exp. */ private int exp; - + /** The select. */ private final TeamSelectionStage select; - + /** The buttons. */ private final List