Browse Source

Add color to help command messages

pull/8/head
Anton Tarasenko 4 years ago
parent
commit
6c3c5eb7c7
  1. 24
      sources/Commands/BuiltInCommands/ACommandDosh.uc

24
sources/Commands/BuiltInCommands/ACommandDosh.uc

@ -19,30 +19,29 @@
*/ */
class ACommandDosh extends Command; class ACommandDosh extends Command;
//'dosh' for giving dosh (subcommand for setting it, options for min/max resulting value, silent)
protected function BuildData(CommandDataBuilder builder) protected function BuildData(CommandDataBuilder builder)
{ {
builder.Name(P("dosh")).Summary(P("Changes how much money player has.")); builder.Name(P("dosh")).Summary(P("Changes amount of money."));
builder.RequireTarget(); builder.RequireTarget();
builder.ParamInteger(P("amount")) builder.ParamInteger(P("amount"))
.Describe(P("Gives (takes if negative) players a specified <amount>" .Describe(P("Gives (or takes if negative) players a specified <amount>"
@ "of money.")); @ "of money."));
builder.SubCommand(P("set")) builder.SubCommand(P("set"))
.ParamInteger(P("amount")) .ParamInteger(P("amount"))
.Describe(P("Sets players' money to a specified <amount>.")); .Describe(P("Sets player's money to a specified <amount>."));
builder.Option(P("silent")) builder.Option(P("silent"))
.Describe(P("If specified - players won't receive a notification about" .Describe(P("If specified - players won't receive a notification about"
@ "obtaining/losing dosh.")); @ "obtaining/losing dosh."));
builder.Option(P("min")) builder.Option(P("min"))
.ParamInteger(P("minValue")) .ParamInteger(P("minValue"))
.Describe(F("Players will retain at least this amount of dosh after" .Describe(F("Players will retain at least this amount of dosh after"
@ "the command's execution. In case of conflict overrides" @ "the command's execution. In case of conflict, overrides"
@ "'{$TextEmphasis --max}' option. `0` is assumed by default.")); @ "'{$TextEmphasis --max}' option. `0` is assumed by default."));
builder.Option(P("max"), P("M")) builder.Option(P("max"), P("M"))
.ParamInteger(P("maxValue")) .ParamInteger(P("maxValue"))
.Describe(F("Players will have at most this amount of dosh after" .Describe(F("Players will have at most this amount of dosh after"
@ "the command's execution. In case of conflict is overridden by" @ "the command's execution. In case of conflict, it is overridden"
@ "'{$TextEmphasis --min}' option.")); @ "by '{$TextEmphasis --min}' option."));
} }
protected function ExecutedFor(APlayer player, CommandCall result) protected function ExecutedFor(APlayer player, CommandCall result)
@ -76,22 +75,17 @@ protected function ExecutedFor(APlayer player, CommandCall result)
newAmount = amount; newAmount = amount;
} }
// Enforce min/max bounds // Enforce min/max bounds
if (newAmount > maxValue) { newAmount = Clamp(newAmount, minValue, maxValue);
newAmount = maxValue;
}
if (newAmount < minValue) {
newAmount = minValue;
}
if (!commandOptions.HasKey(P("silent"))) if (!commandOptions.HasKey(P("silent")))
{ {
if (newAmount > oldAmount) if (newAmount > oldAmount)
{ {
player.Console().WriteLine(P("You've gotten" player.Console().Say(F("You've {$TextPositive gotten}"
@ newAmount - oldAmount @ "dosh!")); @ newAmount - oldAmount @ "dosh!"));
} }
if (newAmount < oldAmount) if (newAmount < oldAmount)
{ {
player.Console().WriteLine(P("You've lost" player.Console().Say(F("You've {$TextNegative lost}"
@ oldAmount - newAmount @ "dosh!")); @ oldAmount - newAmount @ "dosh!"));
} }
} }

Loading…
Cancel
Save