Skip to content

Commit

Permalink
Cap the message letter count (128 length), to allow 1.11 messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Nov 27, 2016
1 parent a97ae01 commit 4fdca46
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -155,6 +155,7 @@ private boolean unsafeCheck(final Player player, final String message, final ICa

// Upper case.
if (letterCounts.fullCount.upperCase > msgLen / 3) {
// TODO: Regard chunks of 48 or so letters of the message for this?
final float wUpperCase = 0.6f * letterCounts.fullCount.getUpperCaseRatio();
score += wUpperCase * cc.textMessageUpperCase;
}
Expand All @@ -163,7 +164,11 @@ private boolean unsafeCheck(final Player player, final String message, final ICa
if (msgLen > 4) {
final float fullRep = letterCounts.fullCount.getLetterCountRatio();
// Long messages: very small and very big are bad !
final float wRepetition = (float) msgLen / 15.0f * Math.abs(0.5f - fullRep);
/*
* TODO: 128 is a quick attempt to make one long message possible on
* 1.11.
*/
final float wRepetition = (float) Math.min(msgLen, 128) / 15.0f * Math.abs(0.5f - fullRep);
score += wRepetition * cc.textMessageLetterCount;

// Number of words vs. length of message
Expand Down Expand Up @@ -233,7 +238,9 @@ private boolean unsafeCheck(final Player player, final String message, final ICa
wWords /= (float) letterCounts.words.length;
score += wWords;

if (debug && score > 0f) debugParts.add("Simple score: " + StringUtil.fdec3.format(score));
if (debug && score > 0f) {
debugParts.add("Simple score: " + StringUtil.fdec3.format(score));
}

// Engine:
// TODO: more fine grained sync !
Expand All @@ -244,8 +251,12 @@ private boolean unsafeCheck(final Player player, final String message, final ICa
// TODO: more fine grained sync !s
// TODO: different methods (add or max or add+max or something else).
for (final Float res : engMap.values()) {
if (cc.textEngineMaximum) wEngine = Math.max(wEngine, res.floatValue());
else wEngine += res.floatValue();
if (cc.textEngineMaximum) {
wEngine = Math.max(wEngine, res.floatValue());
}
else {
wEngine += res.floatValue();
}
}
}
score += wEngine;
Expand Down

1 comment on commit 4fdca46

@MyPictures
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Please sign in to comment.