From: <boo...@us...> - 2006-06-20 00:40:22
|
Revision: 1089 Author: boomer70 Date: 2006-06-19 17:40:17 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1089&view=rev Log Message: ----------- Fix for [ 1507499 ] SPELLLEVEL:CLASS bug Modified Paths: -------------- Branches/5.10.x/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java Modified: Branches/5.10.x/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java =================================================================== --- Branches/5.10.x/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java 2006-06-19 01:20:25 UTC (rev 1088) +++ Branches/5.10.x/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java 2006-06-20 00:40:17 UTC (rev 1089) @@ -84,7 +84,7 @@ 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - // there are two roots. One for available spells + // there are two roots. One for available spells // and one for selected spells (spellbooks) private PObjectNode theRoot; @@ -98,15 +98,15 @@ private boolean includeRace = false; private PlayerCharacter pc; private boolean available = false; - + /** * Creates a SpellModel for a particular character. - * - * @param primaryMode The primary sort order + * + * @param primaryMode The primary sort order * @param secondaryMode The secondary sort order * @param available Is this an available (true) or selected (false) list * @param bookList The list of books to be displayed. - * @param currSpellBook The name of the currently selected spell book + * @param currSpellBook The name of the currently selected spell book * @param fullSpellList Should we display a full list of available spells? * @param pc The character we are building the spell list for. * @param spellTab The tab the list is being displayed upon. @@ -284,7 +284,7 @@ /** * Returns boolean if can edit a cell. (SpellModel) * @param node The model node being checked - * @param column The index of the column to be checked. + * @param column The index of the column to be checked. * @return true if cell editable **/ public boolean isCellEditable(Object node, int column) @@ -546,12 +546,12 @@ /** * This assumes the SpellModel exists but * needs branches and nodes to be repopulated - * - * @param primaryMode The primary sort order + * + * @param primaryMode The primary sort order * @param secondaryMode The secondary sort order * @param available Is this an available (true) or selected (false) list * @param bookList The list of books to be displayed. - * @param currSpellBook The name of the currently selected spell book + * @param currSpellBook The name of the currently selected spell book * @param spellListType Should we display known only/all available spells or all spells? * @param spellTab The tab the list is being displayed upon. * @param emptyMessage The message to be displayed if the model is empty @@ -571,14 +571,14 @@ theRoot = new PObjectNode(); setRoot(theRoot); - if (pc == null) + if (pc == null) { - return; + return; } - + boolean knownSpellsOnly = spellListType == GuiConstants.INFOSPELLS_AVAIL_KNOWN; - if (knownSpellsOnly) + if (knownSpellsOnly) { bookNodes = new PObjectNode [bookList.size()]; int ix = 0; @@ -615,7 +615,7 @@ spellList.add(charSpell); } } - + } ix++; } @@ -671,7 +671,7 @@ if (knownSpellsOnly && ix == bookList.size()) break; if (!knownSpellsOnly && ix>0) { - break; + break; } // default currently selected spellbook String bookName = currSpellBook; @@ -708,7 +708,7 @@ { case GuiConstants.INFOSPELLS_VIEW_CLASS: // By Class aClass = (PObject)classList.get(pindex); - primaryMatch = (spell.getFirstLevelForKey(aClass.getSpellKey(), pc) >= 0); + primaryMatch = spell.levelForKeyContains(aClass.getSpellKey(), iLev, pc); if (cs != null) { if (aClass instanceof Race) @@ -737,7 +737,9 @@ si = cs.getSpellInfoFor(bookName, iLev, -1); } if (si == null) + { primaryMatch = spell.isLevel(iLev, pc); + } else if (!knownSpellsOnly && si != null && si.getFeatList()!=null) continue; break; @@ -757,8 +759,8 @@ primaryMatch = spell.getSchools().contains(primaryNodes[pindex].toString()); break; } - - if (secondaryMode == GuiConstants.INFOSPELLS_VIEW_NOTHING) + + if (secondaryMode == GuiConstants.INFOSPELLS_VIEW_NOTHING) { if (!firstPass && !primaryMatch) continue; @@ -797,7 +799,10 @@ si = cs.getSpellInfoFor(bookName, iLev, -1); } if (si == null && primaryMatch) - spellMatch = spell.isLevel(iLev, pc); + { +// spellMatch = spell.isLevel(iLev, pc); + spellMatch = spell.levelForKeyContains(aClass.getSpellKey(), iLev, pc); + } if (!knownSpellsOnly && si != null && si.getFeatList()!=null) continue; break; @@ -927,23 +932,23 @@ } - /** - * @param spellListType - * @param classList - * @param spellList - */ - private void getSpellcastingClasses(int spellListType, List classList, List spellList, InfoSpellsSubTab spellTab) - { - // get the list of spell casting Classes - Iterator iClass = null; - if (spellListType == GuiConstants.INFOSPELLS_AVAIL_ALL_SPELL_LISTS) - { - iClass = Globals.getClassList().iterator(); - } - else - { - iClass = pc.getClassList().iterator(); - } + /** + * @param spellListType + * @param classList + * @param spellList + */ + private void getSpellcastingClasses(int spellListType, List classList, List spellList, InfoSpellsSubTab spellTab) + { + // get the list of spell casting Classes + Iterator iClass = null; + if (spellListType == GuiConstants.INFOSPELLS_AVAIL_ALL_SPELL_LISTS) + { + iClass = Globals.getClassList().iterator(); + } + else + { + iClass = pc.getClassList().iterator(); + } for (; iClass.hasNext();) { @@ -991,54 +996,54 @@ else { spell = (Spell) tempSpell; - } + } if (spellTab.shouldDisplayThis(spell)) { spellList.add(spell); } - + } } } } - } + } - /** - * @param primaryMode - * @param classList - * @return PObjectNode[] - */ - private PObjectNode[] getNodesByMode(int primaryMode, List classList) { - PObjectNode[] primaryNodes = null; - switch (primaryMode) - { - case GuiConstants.INFOSPELLS_VIEW_CLASS: // By Class - primaryNodes = getClassNameNodes(classList); - break; - case GuiConstants.INFOSPELLS_VIEW_LEVEL: // By Level - primaryNodes = getLevelNodes(); - break; - case GuiConstants.INFOSPELLS_VIEW_DESCRIPTOR: // By Descriptor - primaryNodes = getDescriptorNodes(); - break; - case GuiConstants.INFOSPELLS_VIEW_RANGE: // By Range - primaryNodes = getRangeNodes(); - break; - case GuiConstants.INFOSPELLS_VIEW_DURATION: // By Duration - primaryNodes = getDurationNodes(); - break; - case GuiConstants.INFOSPELLS_VIEW_TYPE: // By Type - primaryNodes = getTypeNodes(); - break; - case GuiConstants.INFOSPELLS_VIEW_SCHOOL: // By School - primaryNodes = getSchoolNodes(); - break; - } - return primaryNodes; - } + /** + * @param primaryMode + * @param classList + * @return PObjectNode[] + */ + private PObjectNode[] getNodesByMode(int primaryMode, List classList) { + PObjectNode[] primaryNodes = null; + switch (primaryMode) + { + case GuiConstants.INFOSPELLS_VIEW_CLASS: // By Class + primaryNodes = getClassNameNodes(classList); + break; + case GuiConstants.INFOSPELLS_VIEW_LEVEL: // By Level + primaryNodes = getLevelNodes(); + break; + case GuiConstants.INFOSPELLS_VIEW_DESCRIPTOR: // By Descriptor + primaryNodes = getDescriptorNodes(); + break; + case GuiConstants.INFOSPELLS_VIEW_RANGE: // By Range + primaryNodes = getRangeNodes(); + break; + case GuiConstants.INFOSPELLS_VIEW_DURATION: // By Duration + primaryNodes = getDurationNodes(); + break; + case GuiConstants.INFOSPELLS_VIEW_TYPE: // By Type + primaryNodes = getTypeNodes(); + break; + case GuiConstants.INFOSPELLS_VIEW_SCHOOL: // By School + primaryNodes = getSchoolNodes(); + break; + } + return primaryNodes; + } - private PObjectNode [] getClassNameNodes(List classList) + private PObjectNode [] getClassNameNodes(List classList) { PObjectNode [] tempNodes = new PObjectNode[classList.size()]; for (int ix = 0; ix < classList.size(); ++ix) @@ -1051,21 +1056,21 @@ return tempNodes; } - private PObjectNode [] getLevelNodes() - { - PObjectNode [] tempNodes = new PObjectNode[20]; - for (int ix = 0; ix < 20; ++ix) - { - tempNodes[ix] = new PObjectNode(); - String ix2 = ""+ix; - if (ix < 10) - { - ix2 = " " + ix2; - } - tempNodes[ix].setItem("level " + ix2); - } - return tempNodes; - } + private PObjectNode [] getLevelNodes() + { + PObjectNode [] tempNodes = new PObjectNode[20]; + for (int ix = 0; ix < 20; ++ix) + { + tempNodes[ix] = new PObjectNode(); + String ix2 = ""+ix; + if (ix < 10) + { + ix2 = " " + ix2; + } + tempNodes[ix].setItem("level " + ix2); + } + return tempNodes; + } private PObjectNode [] getDescriptorNodes() @@ -1128,7 +1133,7 @@ return tempNodes; } - /** + /** * @param pc */ public void setCharacter(PlayerCharacter pc) @@ -1171,15 +1176,15 @@ public void setMColumnDefaultWidth(int col, int width) { SettingsHandler.setPCGenOption(getOptionName() + "sizecol." + colNameList[col], width); } - + private boolean getColumnViewOption(String colName, boolean defaultVal) { return SettingsHandler.getPCGenOption(getOptionName() + "viewcol." + colName, defaultVal); } - + private void setColumnViewOption(String colName, boolean val) { SettingsHandler.setPCGenOption(getOptionName() + "viewcol." + colName, val); } - + private String getOptionName() { StringBuffer nameSb = new StringBuffer("InfoSpells."); if(available) { @@ -1194,6 +1199,6 @@ public void resetMColumn(int col, TableColumn column) { // TODO Auto-generated method stub - + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |