Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WeaponExample {
- Weapon weapon = new Weapon();
- public WeaponExample()
- {
- weapon.name = "sword";
- weapon.damage = 10;
- weapon.levelRequirement = 4;
- //create a modifier that adds extra strength to the character
- Modifier modifier1 = new Modifier();
- modifier1.type = "strength";
- modifier1.amount = 5;
- //create a modifier for 10% extra damage against undead
- Modifier modifier2 = new Modifier();
- modifier2.type = "undead";
- modifier2.percentage = 10;
- //add them to the weapon
- weapon.modifiers.add(modifier1);
- weapon.modifiers.add(modifier2);
- //serialize weapon.modifiers to store in database.
- //..
- }
- }
- class Weapon {
- //Basic weapon data
- public String name;
- public int damage;
- public int levelRequirement;
- //... etc
- //Data to be serialized to binary and stored
- List<Modifier> modifiers;
- }
- class Modifier {
- public String type;
- public int percentage;
- public int amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement