Ver Fonte

Solve issue for Spontaneous casters having negation spells remaining.

Sam Jaffe há 8 anos atrás
pai
commit
487eaf0e4c

+ 3 - 0
src/org/leumasjaffe/charsheet/model/magic/impl/Spontaneous.java

@@ -47,6 +47,9 @@ public class Spontaneous implements DDSpellbook {
 
 	@Override
 	public void castSpell(int level, DDSpell spell) {
+		if (numSpellsPerDayRemainingAtLevel(level) == 0) {
+			throw new IllegalStateException("Attempting to cast a spell while out of slots");
+		}
 		--spellInfo.get( level ).spellsPerDayRemaining;
 	}
 }

+ 5 - 0
src/org/leumasjaffe/charsheet/view/magic/SpellMenu.java

@@ -8,6 +8,7 @@ import org.leumasjaffe.charsheet.model.magic.DDSpellbook;
 
 import javax.swing.JFrame;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 
 class SpellMenu extends JPopupMenu {
 
@@ -32,6 +33,10 @@ class SpellMenu extends JPopupMenu {
 			JMenuItem mntmCast = new JMenuItem("Cast");
 			mntmCast.addActionListener(e -> {
 				final DDSpellbook book = dclass.getSpellBook().get();
+				if (book.numSpellsPerDayRemainingAtLevel(spellLevel) == 0) {
+					JOptionPane.showMessageDialog(null, "Cannot cast any more spells");
+					return;
+				}
 				book.castSpell(spellLevel, spell);
 				((SpellLevelPerDayPanel) this.getInvoker().getParent().getParent()).reload();
 			});