|
From: JIRA (f. D. R. B. ) <ji...@pc...> - 2011-07-12 23:51:04
|
[CODE] Have all formula parsing done with JEP
---------------------------------------------
Key: CODE-699
URL: http://jira.pcgen.org/browse/CODE-699
Project: Code
Issue Type: New Feature
Components: Needs Verification Review
Reporter: David R. Bender
SF - ID: 873758
Last Update: Settings changed ( thpr )
Details:
Equipment.getBaseCost already uses JEP to calculate
the costs.
It would be nice if Playercharacter.getVariableValue()
could also use JEP to give more readable formulas.
It would mean that getVariableValue can be cut down
from the current 1400 lines and will also mean that
the furmluas will be more in line with what newbies
expect (no more .TRUNC applying to the wrong thing
errors).
Submitted:
Frugal ( frugal ) - 2004-01-09 08:57:01 EST
Priority:
Status:
Resolution:
Tracker:
Assigned:
(admin)
Category:
(admin)
Group:
(admin)
Visibility:
Private
Response:
(admin)
Comment:
Comments ( 5 )
Add a comment
Date: 2008-07-29 22:48:03 EDT
Sender: thprProject Admin & Donor
Hide
requires validation/conversion method - arch work
Date: 2005-09-15 11:41:29 EDT
Sender: soulcatcher
Hide
Logged In: YES
user_id=107647
well, we need to do this, but I think we'll get some objections.
we need to eliminate the old varaible parsing system and
only use jep. my position righ tnow is that for 6.0, we
will create a clean pcgen lst api that has no cruft and then
I will do my best to permanently support the 6.0 syntax into
the future.
To me this means finally eliminating the old wonky things
liek the old variable system.
Devon
Date: 2005-09-15 11:04:23 EDT
Sender: kariannaSourceForge.net DonorProject Admin & DonorAccepting Donations
Hide
Logged In: YES
user_id=252169
Is this desirable? - K
Date: 2004-02-03 03:56:50 EST
Sender: frugal
Hide
Logged In: YES
user_id=4807
JEP is indeed a mathematical expression parser. It also
allows you to add extra functions as you need them. At
the moment the Equipment Modifier cost calulations are
done using JEP, so that would be a good place to look for
more information. If you Google for "Java Expression
Parser" JEP is the first entry.
There are 2 main issues:
1 - The current code hardcodes the available variables into
2 groups, the actual variables a character has, and a big if-
elseif ladder containing all of the things like COUNT[FEAT],
CASTER.TOTALLEVEL etc. this code must be separated
out.
2 - A system must be put in place to ensure backward
compatability with the old syntax for at least 1 major
revision.
3 - A syntax created to ensure that all variable names are
treated correctly under JEP. i.e. COUNT[FEATS] is not a
valid variable name under JEP, but we can create a
function Count() that takes an argument and we can
evaulate that however we wish.
The way I would go about tackling this problem is:
1- in Playercharacter.getVariableValue(): separate out the
code that does variable lookups from the code that parses
the formula. (I would stick it all in a separate class that
gets passed a PlayerCharacter object to try make
PlayerCharacter a bit smaller). This will be the major piece
of the work.
2 - Write some JEP functions for things like Count().
3- At the start of PlayerCharacter.getVariableValue try to
parse the formula as a JEP equation. If it does not parse
then use the old style.
4- If the formula is a JEP equation then get the names of
all of the variables from the parsed equation and populat
them with the appropriate values. Then execute the
equation.
I would say Step 1 should be about 10 man hours; Step 2
about 5 man hours depending on how many functions
need writing; step 3 and Step 4 should only take a couple
of man hours. To do the job properly there would be
several more man hours of testing at the end of this.
(Why is it that when calculating man hours for Open
Source projects I do not feel the need to multiply the
estimates by 2-4 ;O)
Date: 2004-02-02 23:30:11 EST
Sender: kariannaSourceForge.net DonorProject Admin & DonorAccepting Donations
Hide
Logged In: YES
user_id=252169
Right, so JEP is a Java mathematical expression parser :-).
OK, what actually needs to be done here Frugal? A matter of
changing a few lines of code or??
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.pcgen.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|