Browse Source

Change commands for new AcediaCore version

feature_improvement
Anton Tarasenko 2 years ago
parent
commit
04eb5744cc
  1. 32
      sources/Commands/ACommandDB.uc
  2. 88
      sources/Commands/ACommandDosh.uc
  3. 4
      sources/Commands/ACommandInventory.uc
  4. 2
      sources/Futility_Feature.uc
  5. 29
      sources/Tools/InventoryTool.uc

32
sources/Commands/ACommandDB.uc

@ -1,6 +1,6 @@
/** /**
* Command for working with databases. * Command for working with databases.
* Copyright 2021 Anton Tarasenko * Copyright 2021-2022 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.
* *
@ -188,7 +188,7 @@ protected function Executed(CallData result, EPlayer callerPlayer)
pair = TryLoadingDB(result.parameters.GetText(T(TDATABASE_LINK))); pair = TryLoadingDB(result.parameters.GetText(T(TDATABASE_LINK)));
if (pair.database == none) if (pair.database == none)
{ {
callerPlayer.BorrowConsole().WriteLine(T(TBAD_DBLINK)); callerConsole.WriteLine(T(TBAD_DBLINK));
return; return;
} }
// Remember the last player we are making a query to and make that query // Remember the last player we are making a query to and make that query
@ -230,7 +230,7 @@ private function bool TryAPICallCommands(
{ {
if (subCommand.IsEmpty()) if (subCommand.IsEmpty())
{ {
callerPlayer.BorrowConsole().WriteLine(T(TNO_DEFAULT_COMMAND)); callerConsole.WriteLine(T(TNO_DEFAULT_COMMAND));
return true; return true;
} }
else if (subCommand.Compare(T(TLIST))) else if (subCommand.Compare(T(TLIST)))
@ -275,14 +275,14 @@ protected function CreateDatabase(EPlayer callerPlayer, Text databaseName)
} }
if (_.db.ExistsLocal(databaseName)) if (_.db.ExistsLocal(databaseName))
{ {
callerPlayer.BorrowConsole().WriteLine(T(TDB_ALREADY_EXISTS)); callerConsole.WriteLine(T(TDB_ALREADY_EXISTS));
return; return;
} }
if (_.db.NewLocal(databaseName) != none) { if (_.db.NewLocal(databaseName) != none) {
callerPlayer.BorrowConsole().WriteLine(T(TDB_CREATED)); callerConsole.WriteLine(T(TDB_CREATED));
} }
else { else {
callerPlayer.BorrowConsole().WriteLine(T(TDB_CANNOT_BE_CREATED)); callerConsole.WriteLine(T(TDB_CANNOT_BE_CREATED));
} }
} }
@ -292,10 +292,10 @@ protected function DeleteDatabase(EPlayer callerPlayer, Text databaseName)
return; return;
} }
if (_.db.DeleteLocal(databaseName)) { if (_.db.DeleteLocal(databaseName)) {
callerPlayer.BorrowConsole().WriteLine(T(TDA_DELETED)); callerConsole.WriteLine(T(TDA_DELETED));
} }
else { else {
callerPlayer.BorrowConsole().WriteLine(T(TDB_DOESNT_EXIST)); callerConsole.WriteLine(T(TDB_DOESNT_EXIST));
} }
} }
@ -308,7 +308,7 @@ protected function ListDatabases(EPlayer callerPlayer)
return; return;
} }
availableDatabases = _.db.ListLocal(); availableDatabases = _.db.ListLocal();
console = callerPlayer.BorrowConsole(); console = callerConsole;
console.Write(T(TAVAILABLE_DATABASES)); console.Write(T(TAVAILABLE_DATABASES));
for (i = 0; i < availableDatabases.length; i += 1) for (i = 0; i < availableDatabases.length; i += 1)
{ {
@ -329,16 +329,16 @@ protected function OutputStatus(
return; return;
} }
if (error == DBR_Success) { if (error == DBR_Success) {
callerPlayer.BorrowConsole().WriteLine(T(TQUERY_COMPLETED)); callerConsole.WriteLine(T(TQUERY_COMPLETED));
} }
if (error == DBR_InvalidPointer) { if (error == DBR_InvalidPointer) {
callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_POINTER)); callerConsole.WriteLine(T(TQUERY_INVALID_POINTER));
} }
if (error == DBR_InvalidDatabase) { if (error == DBR_InvalidDatabase) {
callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_DB)); callerConsole.WriteLine(T(TQUERY_INVALID_DB));
} }
if (error == DBR_InvalidData) { if (error == DBR_InvalidData) {
callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_DATA)); callerConsole.WriteLine(T(TQUERY_INVALID_DATA));
} }
} }
@ -355,7 +355,7 @@ protected function DisplayData(
if (callerPlayer != none && result == DBR_Success) if (callerPlayer != none && result == DBR_Success)
{ {
printedJSON = _.json.PrettyPrint(data); printedJSON = _.json.PrettyPrint(data);
callerPlayer.BorrowConsole().Write(printedJSON).Flush(); callerConsole.Write(printedJSON).Flush();
_.memory.Free(printedJSON); _.memory.Free(printedJSON);
_.memory.Free(callerPlayer); _.memory.Free(callerPlayer);
callerPlayer = none; callerPlayer = none;
@ -379,7 +379,7 @@ protected function DisplaySize(
if (callerPlayer != none && result == DBR_Success) if (callerPlayer != none && result == DBR_Success)
{ {
sizeAsText = _.text.FromInt(size); sizeAsText = _.text.FromInt(size);
callerPlayer.BorrowConsole() callerConsole
.Write(T(TOBJECT_SIZE_IS)) .Write(T(TOBJECT_SIZE_IS))
.Write(sizeAsText) .Write(sizeAsText)
.Flush(); .Flush();
@ -404,7 +404,7 @@ protected function DisplayKeys(
} }
if (callerPlayer != none && result == DBR_Success) if (callerPlayer != none && result == DBR_Success)
{ {
console = callerPlayer.BorrowConsole(); console = callerConsole;
console.Write(T(TOBJECT_KEYS_ARE)); console.Write(T(TOBJECT_KEYS_ARE));
for (i = 0; i < keys.GetLength(); i += 1) for (i = 0; i < keys.GetLength(); i += 1)
{ {

88
sources/Commands/ACommandDosh.uc

@ -19,7 +19,9 @@
*/ */
class ACommandDosh extends Command; class ACommandDosh extends Command;
var protected const int TGOTTEN, TLOST, TDOSH; var protected const int TGOTTEN, TLOST, TYOU_GAVE, TYOU_TAKEN, TOTHER_GAVE;
var protected const int TOTHER_TAKEN, TDOSH_FROM, TDOSH_TO, TYOURSELF, TDOSH;
var protected const int TTHEMSELVES;
protected function BuildData(CommandDataBuilder builder) protected function BuildData(CommandDataBuilder builder)
{ {
@ -31,9 +33,6 @@ protected function BuildData(CommandDataBuilder builder)
builder.SubCommand(P("set")) builder.SubCommand(P("set"))
.ParamInteger(P("amount")) .ParamInteger(P("amount"))
.Describe(P("Sets player's money to a specified <amount>.")); .Describe(P("Sets player's money to a specified <amount>."));
builder.Option(P("silent"))
.Describe(P("If specified - players won't receive a notification about"
@ "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"
@ -72,40 +71,97 @@ protected function ExecutedFor(
newAmount = Clamp(newAmount, minValue, maxValue); newAmount = Clamp(newAmount, minValue, maxValue);
// Announce dosh change, if necessary // Announce dosh change, if necessary
if (!result.options.HasKey(P("silent"))) { if (!result.options.HasKey(P("silent"))) {
AnnounceDoshChange(player.BorrowConsole(), oldAmount, newAmount); AnnounceDoshChange(player, callerPlayer, oldAmount, newAmount);
} }
player.SetDosh(newAmount); player.SetDosh(newAmount);
} }
protected function AnnounceDoshChange( protected function AnnounceDoshChange(
ConsoleWriter console, EPlayer player,
int oldAmount, EPlayer callerPlayer,
int newAmount) int oldAmount,
int newAmount)
{ {
local bool affectingSelf;
local Text amountDeltaAsText; local Text amountDeltaAsText;
local Text targetName, yourTargetName, callerName;
callerName = callerPlayer.GetName();
affectingSelf = callerPlayer.SameAs(player);
if (affectingSelf)
{
yourTargetName = T(TYOURSELF).Copy();
targetName = player.GetName();
}
else
{
yourTargetName = T(TTHEMSELVES).Copy();
targetName = player.GetName();
}
if (newAmount > oldAmount) if (newAmount > oldAmount)
{ {
amountDeltaAsText = _.text.FromInt(newAmount - oldAmount); amountDeltaAsText = _.text.FromInt(newAmount - oldAmount);
console.Write(T(TGOTTEN)) if (!affectingSelf)
{
targetConsole.Write(T(TGOTTEN))
.Write(amountDeltaAsText)
.WriteLine(T(TDOSH));
}
callerConsole.Write(T(TYOU_GAVE))
.Write(amountDeltaAsText)
.Write(T(TDOSH_TO))
.WriteLine(yourTargetName);
othersConsole.Write(callerName)
.Write(T(TOTHER_GAVE))
.Write(amountDeltaAsText) .Write(amountDeltaAsText)
.WriteLine(T(TDOSH)); .Write(T(TDOSH_TO))
.WriteLine(targetName);
} }
if (newAmount < oldAmount) if (newAmount < oldAmount)
{ {
amountDeltaAsText = _.text.FromInt(oldAmount - newAmount); amountDeltaAsText = _.text.FromInt(oldAmount - newAmount);
console.Write(T(TLOST)) if (!affectingSelf)
{
targetConsole.Write(T(TLOST))
.Write(amountDeltaAsText)
.WriteLine(T(TDOSH));
}
callerConsole.Write(T(TYOU_TAKEN))
.Write(amountDeltaAsText)
.Write(T(TDOSH_FROM))
.WriteLine(yourTargetName);
othersConsole.Write(callerName)
.Write(T(TOTHER_TAKEN))
.Write(amountDeltaAsText) .Write(amountDeltaAsText)
.WriteLine(T(TDOSH)); .Write(T(TDOSH_FROM))
.WriteLine(targetName);
} }
_.memory.Free(amountDeltaAsText); _.memory.Free(amountDeltaAsText);
_.memory.Free(targetname);
_.memory.Free(callerName);
} }
defaultproperties defaultproperties
{ {
TGOTTEN = 0 TGOTTEN = 0
stringConstants(0) = "You've {$TextPositive gotten} " stringConstants(0) = "You've {$TextPositive gotten} "
TLOST = 1 TLOST = 1
stringConstants(1) = "You've {$TextNegative lost} " stringConstants(1) = "You've {$TextNegative lost} "
TDOSH = 2 TYOU_GAVE = 2
stringConstants(2) = " dosh!" stringConstants(2) = "You {$TextPositive gave} "
TYOU_TAKEN = 3
stringConstants(3) = "You {$TextNegative took} "
TOTHER_GAVE = 4
stringConstants(4) = " {$TextPositive gave} "
TOTHER_TAKEN = 5
stringConstants(5) = " {$TextNegative taken} "
TDOSH = 6
stringConstants(6) = " dosh"
TDOSH_FROM = 7
stringConstants(7) = " dosh from "
TDOSH_TO = 8
stringConstants(8) = " dosh to "
TYOURSELF = 9
stringConstants(9) = "yourself"
TTHEMSELVES = 10
stringConstants(10) = "themselves"
} }

4
sources/Commands/ACommandInventory.uc

@ -119,8 +119,10 @@ protected function ExecutedFor(
tool.RemoveAllItems(flagKeep, flagForce, flagHidden); tool.RemoveAllItems(flagKeep, flagForce, flagHidden);
SubCommandAdd(tool, itemsArray, specifiedLists); SubCommandAdd(tool, itemsArray, specifiedLists);
} }
if (!callerPlayer.SameAs(player)) {
tool.ReportChanges(callerPlayer, targetConsole, IRT_Target);
}
tool.ReportChanges(callerPlayer, callerConsole, IRT_Caller); tool.ReportChanges(callerPlayer, callerConsole, IRT_Caller);
tool.ReportChanges(callerPlayer, targetConsole, IRT_Target);
tool.ReportChanges(callerPlayer, othersConsole, IRT_Others); tool.ReportChanges(callerPlayer, othersConsole, IRT_Others);
_.memory.Free(tool); _.memory.Free(tool);
} }

2
sources/Futility_Feature.uc

@ -33,7 +33,6 @@ protected function OnEnabled()
return; return;
} }
commandsFeature.RegisterCommand(class'ACommandDosh'); commandsFeature.RegisterCommand(class'ACommandDosh');
commandsFeature.RegisterCommand(class'ACommandGive');
commandsFeature.RegisterCommand(class'ACommandNick'); commandsFeature.RegisterCommand(class'ACommandNick');
commandsFeature.RegisterCommand(class'ACommandTrader'); commandsFeature.RegisterCommand(class'ACommandTrader');
commandsFeature.RegisterCommand(class'ACommandDB'); commandsFeature.RegisterCommand(class'ACommandDB');
@ -48,7 +47,6 @@ protected function OnDisabled()
if (commandsFeature != none) if (commandsFeature != none)
{ {
commandsFeature.RemoveCommand(class'ACommandDosh'); commandsFeature.RemoveCommand(class'ACommandDosh');
commandsFeature.RemoveCommand(class'ACommandGive');
commandsFeature.RemoveCommand(class'ACommandNick'); commandsFeature.RemoveCommand(class'ACommandNick');
commandsFeature.RemoveCommand(class'ACommandTrader'); commandsFeature.RemoveCommand(class'ACommandTrader');
commandsFeature.RemoveCommand(class'ACommandDB'); commandsFeature.RemoveCommand(class'ACommandDB');

29
sources/Tools/InventoryTool.uc

@ -70,6 +70,7 @@ var const int TRESOLVED_INTO, TTILDE_QUOTE, TFAULTY_INVENTORY_IMPLEMENTATION;
var const int TITEM_MISSING, TITEM_NOT_REMOVABLE, TUNKNOWN, TVISIBLE; var const int TITEM_MISSING, TITEM_NOT_REMOVABLE, TUNKNOWN, TVISIBLE;
var const int TDISPLAYING_INVENTORY, THEADER_COLON, TDOT_SPACE, TCOLON_SPACE; var const int TDISPLAYING_INVENTORY, THEADER_COLON, TDOT_SPACE, TCOLON_SPACE;
var const int TCOMMA_SPACE, TSPACE, TOUT_OF, THIDDEN_ITEMS, TDOLLAR, TYOU; var const int TCOMMA_SPACE, TSPACE, TOUT_OF, THIDDEN_ITEMS, TDOLLAR, TYOU;
var const int TYOURSELF, TTHEMSELVES;
protected function Constructor() protected function Constructor()
{ {
@ -479,12 +480,21 @@ public final function ReportChanges(
InventoryReportTarget reportTarget) InventoryReportTarget reportTarget)
{ {
local Text blamedName, targetName; local Text blamedName, targetName;
if (TargetPlayerIsInvalid()) { if (TargetPlayerIsInvalid()) return;
return; if (blamedPlayer == none) return;
blamedName = blamedPlayer.GetName();
if (!targetPlayer.SameAs(blamedPlayer)) {
targetName = targetPlayer.GetName();
} }
targetName = targetPlayer.GetName(); else
if (blamedPlayer != none) { {
blamedName = blamedPlayer.GetName(); if (reportTarget == IRT_Caller) {
targetName = T(TYOURSELF).Copy();
}
else {
targetName = T(TTHEMSELVES).Copy();
}
} }
if (reportTarget == IRT_Others) if (reportTarget == IRT_Others)
{ {
@ -498,6 +508,11 @@ public final function ReportChanges(
} }
else if (reportTarget == IRT_Caller) else if (reportTarget == IRT_Caller)
{ {
if (targetPlayer.SameAs(blamedPlayer))
{
_.memory.Free(targetName);
targetName = T(TYOURSELF).Copy();
}
itemsAddedPrivate.Report(writer, blamedName, targetName); itemsAddedPrivate.Report(writer, blamedName, targetName);
itemsRemovedPrivate.Report(writer, blamedName, targetName); itemsRemovedPrivate.Report(writer, blamedName, targetName);
itemsAdditionFailed.Report(writer, blamedName, targetName); itemsAdditionFailed.Report(writer, blamedName, targetName);
@ -675,4 +690,8 @@ defaultproperties
stringConstants(21) = "$" stringConstants(21) = "$"
TYOU = 22 TYOU = 22
stringConstants(22) = "you" stringConstants(22) = "you"
TYOURSELF = 23
stringConstants(23) = "yourself"
TTHEMSELVES = 24
stringConstants(24) = "themselves"
} }
Loading…
Cancel
Save