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

Redundant battle logic could use a rewrite #33

Open
winsomniak opened this issue Jan 7, 2018 · 2 comments
Open

Redundant battle logic could use a rewrite #33

winsomniak opened this issue Jan 7, 2018 · 2 comments

Comments

@winsomniak
Copy link
Owner

@Lorenzooone and myself have rewritten a couple sections of code to be better, but an architecture change would be ideal.

Right now there are a lot of places in the codebase where code is copy/pasted and does exactly the same thing, but against a different property.

One of my slightly better implementations is to iterate over a list of properties to check, so we only needed to write the actual logic once. This is not super efficient, though. Ideally, we don't need to "check all the hero properties for subproperties", but have a hash map of properties associated with the hero that we can check instantly.

Here's an example of something that will spawn more copy pasta if move type effectiveness is added for passives:

// super effectiveness against movement types
	if (attacker.weaponData.hasOwnProperty("move_effective") && defender.moveType.includes(attacker.weaponData.move_effective)) {
		if (defender.passiveAData.hasOwnProperty("cancel_effective")) {
			battleInfo.logMsg += "Effectiveness against " + defender.moveType + " neutralized by opponent [" + skillInfo['a'][defender.passiveA].name + "]. ";
		} else {
			atkPower = roundNum(atkPower * 1.5, false);
			battleInfo.logMsg += "Effectiveness against " + defender.moveType + " boosts attack by 50% [" + weaponInfo[attacker.weaponName].name + "]. ";
		}
	}

As you can see, the logic specifically checks the weapon data of the hero for this section of the combat logic. I propose a mapping of properties currently affecting a hero such that we don't need to check weapon data, check passiveA data, check passiveC data etc etc.

@Lorenzooone
Copy link
Collaborator

Yeah, this type of logic would be ideal with refinements too... I can't work on such a heavy rewrite of the code until the 19th though.

@winsomniak
Copy link
Owner Author

No sweat @Lorenzooone, you've been a big help so far regardless. I won't be able to do much until this weekend, and I'll likely be focused on integrating everyone's changes and testing on KageroChart. Possibly a banner update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants