OSDN Git Service

修正・変更
[chemicraft/chemicraft.git] / common / pcc / chemicraft / util / Formula.java
index 0250b77..620f06c 100644 (file)
@@ -39,7 +39,7 @@ public class Formula {
                for (int i = 0; i < var2.length; i++) {
                        if (var2[i] == '・') {
                                if (this.lastSpell != null) {
-                                       setAtom(this.lastSpell, this.magnification);
+                                       setAtom(this.lastSpell, 1);
                                }
                                setAtoms(new Formula(new String(var2, ++i, var2.length - i)));
                                return;
@@ -47,8 +47,8 @@ public class Formula {
                                // 括弧対応はまだ未完成です。 --WIP--
                        } else if (Character.isDigit(var2[i])) {
                                if (this.lastIndex > 0) {
-                                       this.amonts.set(this.amonts.size() - 1, this.magnification
-                                                       * (this.lastIndex = this.lastIndex * 10 + Integer.valueOf(Character.toString(var2[i]))));
+                                       this.amonts.set(this.amonts.size() - 1,
+                                                       this.lastIndex = this.lastIndex * 10 + Integer.valueOf(Character.toString(var2[i])));
                                } else if (this.lastSpell != null) {
                                        setAtom(this.lastSpell, this.lastIndex = Integer.valueOf(Character.toString(var2[i])));
                                } else {
@@ -58,7 +58,7 @@ public class Formula {
                        } else if (Character.isLetter(var2[i])) {
                                if (Character.isUpperCase(var2[i])) {
                                        if (this.lastSpell != null) {
-                                               setAtom(this.lastSpell, this.magnification);
+                                               setAtom(this.lastSpell, 1);
                                        }
                                        this.lastSpell = Character.toString(var2[i]);
                                } else if (Character.isLowerCase(var2[i])) {
@@ -66,16 +66,15 @@ public class Formula {
                                                throw new IllegalArgumentException();
                                        }
                                        this.lastSpell = this.lastSpell.concat(Character.toString(var2[i]));
-
-                                       if (var2.length <= i + 1) {
-                                               setAtom(this.lastSpell, this.magnification);
-                                       }
                                }
                                this.lastIndex = 0;
                        } else {
                                throw new IllegalArgumentException();
                        }
                }
+               if (this.lastSpell != null) {
+                       setAtom(this.lastSpell, 1);
+               }
        }
 
        public boolean isAtom(String par1) {
@@ -89,6 +88,7 @@ public class Formula {
 
        public void setAtom(String par1,  int par2) {
                if (isAtom(par1)) {
+                       par2 *= this.magnification;
                        int var3 = this.atoms.indexOf(par1);
                        if (var3 == -1) {
                                this.atoms.add(par1);