Skip to content

Instantly share code, notes, and snippets.

@xpdlf1004
Created May 15, 2018 09:27
Show Gist options
  • Save xpdlf1004/3c909dc9515b335bdc57635db81b10e7 to your computer and use it in GitHub Desktop.
Save xpdlf1004/3c909dc9515b335bdc57635db81b10e7 to your computer and use it in GitHub Desktop.
function _getPlayerEventScore(bytes data, uint playerIndex, EventType eventType, EventColor _eventMajorColor, EventColor _eventMinorColor) internal pure returns(uint) {
uint partOffset = (PLAYER_SIZE * playerIndex) + PLAYER_BASE_SIZE + (uint256(eventType) * PART_SIZE);
uint level = _getPartLevel(data, partOffset);
uint majorSkillSum = 0;
uint minorSkillSum = 0;
byte eventMajorColor = byte(uint8(_eventMajorColor));
byte eventMinorColor = byte(uint8(_eventMinorColor));
for (uint i = 0; i < 3; i++) {
byte skillColor = _getPartSkillColor(data, partOffset, i);
if (skillColor == eventMajorColor) {
majorSkillSum += _getPartSkillLevel(data, partOffset, i);
} else if (skillColor == eventMinorColor) {
minorSkillSum += _getPartSkillLevel(data, partOffset, i);
}
}
byte playerThemeEffect = _getPlayerThemeEffect(data, PLAYER_SIZE * playerIndex);
if (playerThemeEffect != 0) {
return level + (majorSkillSum * 4) + (minorSkillSum * 2);
} else {
return level + (majorSkillSum * 3) + (minorSkillSum * 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment