Skip to content

Commit

Permalink
Move common function lang functions to base class
Browse files Browse the repository at this point in the history
Also, should rename all class functions to start with lower case
for consistency, but not in this patch to avoid causing conflicts.
  • Loading branch information
quisquous committed Dec 28, 2017
1 parent 5a6f44f commit 30888c4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 66 deletions.
66 changes: 1 addition & 65 deletions resources/lang-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,70 +82,6 @@ class CactbotLanguageEn extends CactbotLanguage {
Pull: 'Pull',
});

// Due to this bug: https://github.com/ravahn/FFXIV_ACT_Plugin/issues/100
// We can not look for log messages from FFXIV "You use X" here. Instead we
// look for the actual ability usage provided by the XIV plugin.
// Also, the networked parse info is given much quicker than the lines from the game.
this.youUseAbilityRegex = function() {
var ids = this.AbilitiesToIds.apply(this, arguments);
return Regexes.Parse(' 1[56]:\\y{ObjectId}:' + this.playerName + ':' + Regexes.AnyOf(ids) + ':');
};
this.youStartUsingRegex = function() {
var ids = this.AbilitiesToIds.apply(this, arguments);
return Regexes.Parse(' 14:' + Regexes.AnyOf(ids) + ':' + this.playerName + ' starts using ');
};
this.youGainEffectRegex = function() {
var effects = [];
for (var i = 0; i < arguments.length; ++i) {
var effect = arguments[i];
this.ValidateEffect(effect);
effects.push(effect);
}
return Regexes.Parse(' 1A:' + this.playerName + ' gains the effect of ' + Regexes.AnyOf(effects) + ' from .* for (\\y{Float}) Seconds\.');
};
this.youLoseEffectRegex = function() {
var effects = [];
for (var i = 0; i < arguments.length; ++i) {
var effect = arguments[i];
this.ValidateEffect(effect);
effects.push(effect);
}
return Regexes.Parse(' 1E:' + this.playerName + ' loses the effect of ' + Regexes.AnyOf(effects) + ' from .*\.');
};

this.abilityRegex = function(abilityName, attacker, target, flags) {
this.ValidateAbility(abilityName);
if (!attacker)
attacker = '[^:]*';
// type:attackerId:attackerName:abilityId:abilityName:targetId:targetName:flags:
var r = ' 1[56]:\\y{ObjectId}:' + attacker + ':' + this.kAbilNameToId[abilityName] + ':';
if (target || flags) {
if (!target)
target = '[^:]*';
if (!flags)
flags = '[^:]*';
r += '[^:]*:\\y{ObjectId}:' + target + ':' + flags + ':';
}
return Regexes.Parse(r);
};

this.gainsEffectRegex = function(effect, target, attacker) {
this.ValidateEffect(effect);
if (!target)
target = '[^:]*';
if (!attacker)
attacker = '[^:]*';
return Regexes.Parse(' 1A:' + target + ' gains the effect of ' + effect + ' from ' + attacker + ' for (\\y{Float}) Seconds\.');
};
this.losesEffectRegex = function(effect, target, attacker) {
this.ValidateEffect(effect);
if (!target)
target = '[^:]*';
if (!attacker)
attacker = '[^:]*';
return Regexes.Parse(' 1E:' + target + ' loses the effect of ' + effect + ' from ' + attacker + '.*\.');
};

this.countdownStartRegex = function() {
return Regexes.Parse(/Battle commencing in (\y{Float}) seconds!/);
};
Expand All @@ -162,4 +98,4 @@ document.addEventListener("onPlayerChangedEvent", function (e) {
if (gLang.playerName != e.detail.name)
gLang.OnPlayerNameChange(e.detail.name);
}
});
});
67 changes: 66 additions & 1 deletion resources/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,69 @@ class CactbotLanguage {
Object.freeze(this.kAbilNameToId);
Object.freeze(this.kAbilIdToName);
}
};

// Due to this bug: https://github.com/ravahn/FFXIV_ACT_Plugin/issues/100
// We can not look for log messages from FFXIV "You use X" here. Instead we
// look for the actual ability usage provided by the XIV plugin.
// Also, the networked parse info is given much quicker than the lines from the game.
youUseAbilityRegex() {
var ids = this.AbilitiesToIds.apply(this, arguments);
return Regexes.Parse(' 1[56]:\\y{ObjectId}:' + this.playerName + ':' + Regexes.AnyOf(ids) + ':');
};
youStartUsingRegex() {
var ids = this.AbilitiesToIds.apply(this, arguments);
return Regexes.Parse(' 14:' + Regexes.AnyOf(ids) + ':' + this.playerName + ' starts using ');
};
youGainEffectRegex() {
var effects = [];
for (var i = 0; i < arguments.length; ++i) {
var effect = arguments[i];
this.ValidateEffect(effect);
effects.push(effect);
}
return Regexes.Parse(' 1A:' + this.playerName + ' gains the effect of ' + Regexes.AnyOf(effects) + ' from .* for (\\y{Float}) Seconds\.');
};
youLoseEffectRegex() {
var effects = [];
for (var i = 0; i < arguments.length; ++i) {
var effect = arguments[i];
this.ValidateEffect(effect);
effects.push(effect);
}
return Regexes.Parse(' 1E:' + this.playerName + ' loses the effect of ' + Regexes.AnyOf(effects) + ' from .*\.');
};

abilityRegex(abilityName, attacker, target, flags) {
this.ValidateAbility(abilityName);
if (!attacker)
attacker = '[^:]*';
// type:attackerId:attackerName:abilityId:abilityName:targetId:targetName:flags:
var r = ' 1[56]:\\y{ObjectId}:' + attacker + ':' + this.kAbilNameToId[abilityName] + ':';
if (target || flags) {
if (!target)
target = '[^:]*';
if (!flags)
flags = '[^:]*';
r += '[^:]*:\\y{ObjectId}:' + target + ':' + flags + ':';
}
return Regexes.Parse(r);
};

gainsEffectRegex(effect, target, attacker) {
this.ValidateEffect(effect);
if (!target)
target = '[^:]*';
if (!attacker)
attacker = '[^:]*';
return Regexes.Parse(' 1A:' + target + ' gains the effect of ' + effect + ' from ' + attacker + ' for (\\y{Float}) Seconds\.');
};

losesEffectRegex(effect, target, attacker) {
this.ValidateEffect(effect);
if (!target)
target = '[^:]*';
if (!attacker)
attacker = '[^:]*';
return Regexes.Parse(' 1E:' + target + ' loses the effect of ' + effect + ' from ' + attacker + '.*\.');
};
};

0 comments on commit 30888c4

Please sign in to comment.