From da9acd5977d6d77b711f35098a7cbc751f137dff Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Wed, 2 Sep 2020 18:55:35 -0700 Subject: [PATCH] Created StatListFlags to store stat list flags (copied from Item) --- .../com/riiablo/attributes/GemAttributes.java | 4 +- .../com/riiablo/attributes/StatListFlags.java | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 core/src/com/riiablo/attributes/StatListFlags.java diff --git a/core/src/com/riiablo/attributes/GemAttributes.java b/core/src/com/riiablo/attributes/GemAttributes.java index eb73439e..1f0b66f4 100644 --- a/core/src/com/riiablo/attributes/GemAttributes.java +++ b/core/src/com/riiablo/attributes/GemAttributes.java @@ -1,10 +1,8 @@ package com.riiablo.attributes; public class GemAttributes extends Attributes { - private static final int NUM_GEMPROPS = 3; // TODO: move this somewhere else - GemAttributes() { - super(StatList.obtain(NUM_GEMPROPS)); + super(StatList.obtain(StatListFlags.NUM_GEMPROPS)); } @Override diff --git a/core/src/com/riiablo/attributes/StatListFlags.java b/core/src/com/riiablo/attributes/StatListFlags.java new file mode 100644 index 00000000..f5667c68 --- /dev/null +++ b/core/src/com/riiablo/attributes/StatListFlags.java @@ -0,0 +1,59 @@ +package com.riiablo.attributes; + +import com.riiablo.logger.LogManager; +import com.riiablo.logger.Logger; + +public class StatListFlags { + private static final Logger log = LogManager.getLogger(StatListFlags.class); + + static final int MAGIC_LIST = 0; + static final int SET_LIST = 1; + static final int RUNE_LIST = 6; + static final int NUM_LISTS = 7; + + static final int MAGIC = 1 << MAGIC_LIST; + static final int SET_2 = 1 << SET_LIST + 0; + static final int SET_3 = 1 << SET_LIST + 1; + static final int SET_4 = 1 << SET_LIST + 2; + static final int SET_5 = 1 << SET_LIST + 3; + static final int SET_6 = 1 << SET_LIST + 4; + static final int RUNE = 1 << RUNE_LIST; + + static final int GEMPROPS_WEAPON = 0; + static final int GEMPROPS_ARMOR = 1; + static final int GEMPROPS_SHIELD = 2; + static final int NUM_GEMPROPS = 3; + + static String toString(int i) { + switch (i) { + case MAGIC_LIST: return "MAGIC_LIST"; + case SET_LIST: + case SET_LIST + 1: + case SET_LIST + 2: + case SET_LIST + 3: + case SET_LIST + 4: + return "SET_LIST (" + (i + 1) + " items)"; + case RUNE_LIST: + return "RUNE_LIST"; + default: + assert false : "i(" + i + ") is not a valid prop list id!"; + return String.valueOf(i); + } + } + + public int getSetFlags(int numItems) { + int flags = 0; + switch (numItems) { + default: + log.warn("numItems({}) not within [2..6]", numItems); + case 6: flags |= SET_6; // fall-through + case 5: flags |= SET_5; // fall-through + case 4: flags |= SET_4; // fall-through + case 3: flags |= SET_3; // fall-through + case 2: flags |= SET_2; + return flags; + } + } + + private StatListFlags() {} +}