RuneScape 2 Development > Server Tutorials
[PI]Bob repairing broken barrows
<<< (2/4) >>>
Sessy Pk3r:
I think it would be more efficient to add a degradable field in the item definitions as well as a repair price that way you could extend it to even more items without writing a bunch of code every time you want to add a new degradable item.
matzie:
#msg4138446
Could make use of this :P
sk8rdude461:

--- Quote from: matzie on July 20, 2016, 12:48:38 PM ---#msg4138446
Could make use of this :P

--- End quote ---
Those loops though...
lare69:
yeah, tables should definitely be used for this. for Java, an enum sounds about right


--- Quote from: sk8rdude461 on November 03, 2015, 12:57:35 PM ---
--- Code: Java ---import java.util.Arrays; public enum BarrowsItem {                DHAROKS_HELM(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_BODY(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_LEGS(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_AXE(25000, 0000, 0001, 0002, 0003, 0004);                private int costPerLevel, fixedForm;        private int[] degradedForms;                BarrowsItem(int costPerLevel, int fixedForm, int... degradedForms) {                this.costPerLevel = costPerLevel;                this.fixedForm = fixedForm;                this.degradedForms = degradedForms;        }                public BarrowsItem getForDegrade(int id) {                for(BarrowsItem b : BarrowsItem.values()) {                        if(b.degradedForms != null &&                                        Arrays.asList(b.degradedForms).contains(id)) {                                return b;                        }                }                return null;        }}
--- End quote ---
so basically this, but iirc the price per degradation level is the same across all barrows items so those values aren't needed
sk8rdude461:

--- Quote from: lare69 on July 20, 2016, 04:26:02 PM ---yeah, tables should definitely be used for this. for Java, an enum sounds about right


--- Quote from: sk8rdude461 on November 03, 2015, 12:57:35 PM ---
--- Code: Java ---import java.util.Arrays; public enum BarrowsItem {                DHAROKS_HELM(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_BODY(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_LEGS(25000, 0000, 0001, 0002, 0003, 0004),        DHAROKS_AXE(25000, 0000, 0001, 0002, 0003, 0004);                private int costPerLevel, fixedForm;        private int[] degradedForms;                BarrowsItem(int costPerLevel, int fixedForm, int... degradedForms) {                this.costPerLevel = costPerLevel;                this.fixedForm = fixedForm;                this.degradedForms = degradedForms;        }                public BarrowsItem getForDegrade(int id) {                for(BarrowsItem b : BarrowsItem.values()) {                        if(b.degradedForms != null &&                                        Arrays.asList(b.degradedForms).contains(id)) {                                return b;                        }                }                return null;        }}
--- End quote ---
so basically this, but iirc the price per degradation level is the same across all barrows items so those values aren't needed

--- End quote ---
I did prices like that because you could expand the system to be more than just barrows gear.

I.E crystal bows, pvp armour, so on.
Navigation
Message Index
Next page
Previous page

Go to full version
Powered by SMFPacks SEO Pro Mod |