Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No recpoint calculation #60

Open
JAM-564 opened this issue Feb 28, 2023 · 0 comments
Open

No recpoint calculation #60

JAM-564 opened this issue Feb 28, 2023 · 0 comments

Comments

@JAM-564
Copy link
Contributor

JAM-564 commented Feb 28, 2023

Hello y’all, I tried my hand at moving Loggy’s understanding of the executables without any background understanding of javascript. So yeah, failed, though not sure how. Like once I got it to stop crashing when I run it on localhost, a couple of ways of trying to do it loaded everything except the unit cards, and a couple ways got it stuck perpetually downloading data even when it had already done that according to cmnd.

Anyway, that was about two months ago and I’ve not returned to it since, so I’m making this Issue incase anyone else looking at this repository wants to take a stab at javascripting it in, here are my notes.

COPIED FROM LOGGY’S ILLWIKI PAGE:
Recpoint autocalc - applies to non-commanders, or commanders with a set RP cost of <7. Those with 7+ use different rules I don't understand yet
If set RP is less than 500, use that and don't do any more of this.
A = (RPcost + 500)/1000, rounded down, to a minimum of 1.
A2 = A, unless it is less than 1, in which case A2 = 1.
B = (unit's base gold cost, not autocalced) - 10000
if unit's base gold cost ⇐ 5000, B = the base gold cost instead
C = ((B - A2)*100)/A2, to a maximum value of 100
If the unit has the Standard ability, C instead has a maximum value of 50
D = sqrt(unit's start age, modified by unknown stuff * 4)
E = 1 + D + base RP cost - (A * 1000) + (C * 20)/100
If the unit is undisciplined, divide E by 2.
If the unit is a slave (but not also undisciplined), subtract E/4 rounded down.
If the unit is mounted, add 15 to E.
If the unit is slow to recruit, multiply E by 2.
If E is less than 2, set it to 2.
E is the final RP cost.

.

MY DRAFT OF UNDERSTANDING IT WITH CONSISTENT VARIABLES
Final RPcost = (RPcost) if the listed RPcost is less than 500, otherwise proceed with calculating variables A,B,C,D,E
A = ((RPcost + 500)/1000), rounded down, to a minimum of 1
B = (base gold cost) if the unit's base gold cost < 5000, otherwise: B = ((unit's base gold cost, not autocalced) - 10000)
C = (((B - A)*100)/A), rounded down, to a maximum value of 100, if the unit has the Standard ability the maximum value is 50
D = (sqrt(unit's start age (modified by unknown stuff) * 4))
E = (1 + D + base RP cost - (A * 1000) + (C * 20)/100) rounded down, then (in this order) divide by 2 if undisciplined, subtract (E/4) rounded down if slave and not undisciplined, add 15 if Mounted, multiply by 2 if Slow to Recruit, then if E has a minimum value of 2
Final RPcost = (E)

.

MOST RECENT FAILED ATTEMPT AT CODING IT IN

			'rpcost',	'rec points', function(v,o){
				//if (parseInt(o.rpcost) > 1000) {
					//return (parseInt(o.rpcost)/1000);
				//	return '1';
				//}
				return o.rpcost;

(replace that which is above with:)

			'rpcost', 'rec points', function(v, o) {
			 let rpcostE = 0;
		  If(o.rpcost < 500); {
			  rpcostE = o.rpcost;
			 }
			 Else; {
			  let rpcostA = 0;
		   let rpcostB = 0;
		   let rpcostC = 0;
		   let rpcostD = 0;
	    rpcostA = Math.max(Math.floor((o.rpcost + 500) / 1000), 1);
		   rpcostB = o.goldcost < 5000 ? o.goldcost : (o.goldcost - 10000);
			  rpcostC = o.standard ? Math.min(Math.floor(((rpcostB - rpcostA) * 100) / rpcostA), 100) : Math.min(Math.floor(((rpcostB - rpcostA) * 100) / rpcostA), 50);
			  rpcostD = Math.floor(Math.sqrt(startage * 4)); // The startage is actually suppossed to be modified by some stuff, though what exactly that is is unknown yet.
		   rpcostE = (1 + rpcostD + o.rpcost - (rpcostA * 1000) + Math.floor((rpcostC * 20) / 100));
	    rpcostE = o.undisciplined ? Math.floor(rpcostE / 2) : rpcostE;
	    rpcostE = (o.slave && o.undisciplined) ? (rpcostE - Math.floor(rpcostE / 4)) : rpcostE;
			  rpcostE = o.mounted ? (rpcostE + 15) : rpcostE;
			  rpcostE = o.slow_to_recruit ? (rpcostE * 2) : rpcostE;
		   rpcostE = (rpcostE < 2) ? 2 : rpcostE;
			 }
			 return o.rpcostE;
			},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant